Prev: Automatic Differentiation of mathematica code
Next: Export[] hi-res JPEG not affecting Axes|Plot Label->
From: Marco Masi on 27 Jun 2010 04:56 I would like to calculate the absolute value of complex quantities. For example Abs[Exp[I phi1]+Exp[I*phi2]], which sould give 2 (1+cos(phi1-phi2)). However it does not work. I tried to use real numbers as assumtion, but it always answers "Abs[Exp[I phi1]+Exp[I*phi2]]". What am I doing wrong? Regards, Mark.
From: J. Batista on 28 Jun 2010 02:29 On Sun, Jun 27, 2010 at 4:55 AM, Marco Masi <marco.masi(a)ymail.com> wrote: > I would like to calculate the absolute value of complex quantities. For > example Abs[Exp[I phi1]+Exp[I*phi2]], which sould give 2 (1+cos(phi1-phi2)). > However it does not work. I tried to use real numbers as assumtion, but it > always answers "Abs[Exp[I phi1]+Exp[I*phi2]]". What am I doing wrong? > > Regards, Mark. > > Mark, the modulus or absolute value (Abs[Z]) of a complex number Z = a + j*b is the distance from the origin. Hence, if Z = a + j*b, then Abs[Z] = Sqrt[a^2 + b^2]. Therefore, I believe that your answer is missing the squared root (it should be Sqrt[2 (1 + Cos(phi1 - phi2))]. According to Mathematica, Abs [Z] is left unevaluated if Z is not a numeric quantity. Therefore, it doesn't look like you are doing anything particularly wrong in your hand calculations. However, the function you are calling (Abs) does not seem to support your intended approach, i.e. use with algebraic expressions. This is indicated by the Mathematica documentation (see Abs in the documentation center, pay close attention to the 'more information' section). Regards, J. Batista
From: Peter Pein on 28 Jun 2010 02:30 Am Sun, 27 Jun 2010 08:56:04 +0000 (UTC) schrieb Marco Masi <marco.masi(a)ymail.com>: > I would like to calculate the absolute value of complex quantities. > For example Abs[Exp[I phi1]+Exp[I*phi2]], which sould give 2 > (1+cos(phi1-phi2)). However it does not work. I tried to use real > numbers as assumtion, but it always answers "Abs[Exp[I > phi1]+Exp[I*phi2]]". What am I doing wrong? > > Regards, Mark. > Hi Mark, 1.) you forgot the Sqrt around 2(1+cos(phi1-phi2)) in your posting. 2.) you did not use ComplexExpand: ComplexExpand[Abs[Exp[I phi1] + Exp[I phi2]]] // TrigFactor will return Sqrt[2] Sqrt[1 + Cos[phi1 - phi2]] Peter
From: Murray Eisenberg on 28 Jun 2010 02:30 Actually, the correct answer should be the square-root of what you claim is the answer. In such problems, remember the crucial fact that Mathematica does not "know" that you intended phi1 and phi2 to be real, and hence it does not attempt further simplification. By default, symbolic quantities in Mathematica are interpreted as potentially complex rather than real when they appear in expressions involving complex numbers. In such situations, ComplexExpand is your friend: ComplexExpand[Abs[Exp[I phi1] + Exp[I*phi2]]] // InputForm Sqrt[(Cos[phi1] + Cos[phi2])^2 + (Sin[phi1] + Sin[phi2])^2] ComplexExpand[Abs[Exp[I phi1]+Exp[I*phi2]]] // Simplify // InputForm Sqrt[2 + 2*Cos[phi1]*Cos[phi2] + 2*Sin[phi1]*Sin[phi2]] (I used InputForm here only in order to create one-dimensional output. In actual use you wouldn't do that, so you'd actually see the two-dimensional square-root notation.) On 6/27/2010 4:55 AM, Marco Masi wrote: > I would like to calculate the absolute value of complex quantities. For example Abs[Exp[I phi1]+Exp[I*phi2]], which sould give 2 (1+cos(phi1-phi2)). However it does not work. I tried to use real numbers as assumtion, but it always answers "Abs[Exp[I phi1]+Exp[I*phi2]]". What am I doing wrong? > > Regards, Mark. > -- Murray Eisenberg murray(a)math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
From: DC on 28 Jun 2010 02:30 Try ComplexExpand as in : In[9]:= Simplify[ ComplexExpand[Abs[Exp[I phi1] + Exp[I*phi2]]]] // TrigReduce Out[9]= Sqrt[2] Sqrt[1 + Cos[phi1 - phi2]] -Francesco On 06/27/2010 09:56 AM, Marco Masi wrote: > I would like to calculate the absolute value of complex quantities. For example Abs[Exp[I phi1]+Exp[I*phi2]], which sould give 2 (1+cos(phi1-phi2)). However it does not work. I tried to use real numbers as assumtion, but it always answers "Abs[Exp[I phi1]+Exp[I*phi2]]". What am I doing wrong? > > Regards, Mark. >
|
Next
|
Last
Pages: 1 2 3 Prev: Automatic Differentiation of mathematica code Next: Export[] hi-res JPEG not affecting Axes|Plot Label-> |