       Re: Absolute value

• To: mathgroup at smc.vnet.net
• Subject: [mg110696] Re: Absolute value
• From: Andrzej Kozlowski <akozlowski at gmail.com>
• Date: Fri, 2 Jul 2010 07:26:55 -0400 (EDT)

```Or perhaps you might prefer:

Collect[
ComplexExpand[Abs[(1/2)*(A1*E^(I*\[Phi]1) - A2*E^(I*\[Phi]2) +
A1*E^(I*\[Phi]1)*Cos[Sqrt*c*z] + A2*E^(I*\[Phi]2)*
Cos[Sqrt*c*z])]]^2, Cos[Sqrt*c*z], FullSimplify]

(1/4)*Cos[Sqrt*c*z]^2*(A1^2 +
2*A1*A2*Cos[\[Phi]1 - \[Phi]2] + A2^2) +
(1/4)*(A1^2 - 2*A1*A2*Cos[\[Phi]1 - \[Phi]2] + A2^2) +
(1/2)*(A1 - A2)*(A1 + A2)*Cos[Sqrt*c*z]

Andrzej Kozlowski

On 2 Jul 2010, at 17:40, Andrzej Kozlowski wrote:

> I am not sure if I understand exactly what you want but perhaps this might help:
>
> FullSimplify[
> ComplexExpand[Abs[(1/2)*(A1*E^(I*\[Phi]1) - A2*E^(I*\[Phi]2) +
>              A1*E^(I*\[Phi]1)*Cos[Sqrt*c*z] + A2*E^(I*\[Phi]2)*
>                Cos[Sqrt*c*z])]]^2,
> ExcludedForms -> Cos[Sqrt*c*z]]
>
> (1/4)*(A1^2*(Cos[Sqrt*c*z] + 1)^2 +
>      2*A1*A2*(Cos[Sqrt*c*z]^2 - 1)*Cos[\[Phi]1 - \[Phi]2] +
>      A2^2*(Cos[Sqrt*c*z] - 1)^2)
>
> Andrzej Kozlowski
>
>
> On 28 Jun 2010, at 15:30, Marco Masi wrote:
>
>> Yes, thank you, that brough me a step forward (and yes, I forgot to square the Abs value in the previous example... sorry for that).
>>
>> However, there is still a step which I can't accomplish. Please try the following:
>> FullSimplify[ ComplexExpand[ Abs[1/2 (A1 E^(I \[Phi]1) - A2 E^(I \[Phi]2) + A1 E^(I \[Phi]1) Cos[Sqrt c z] + A2 E^(I \[Phi]2) Cos[Sqrt c z])]]^2]
>>
>> I would like to have Mathematica avoiding one of the resulting Cos[2 Sqrt c z] expression, and maintain both as Cos[Sqrt c z], and then simplify. How should I proceed?
>>
>> Regards, Mark.
>>
>>
>> --- Dom 27/6/10, Murray Eisenberg <murray at math.umass.edu> ha scritto:
>>
>> Da: Murray Eisenberg <murray at math.umass.edu>
>> Oggetto: Re: [mg110596] Absolute value
>> A: mathgroup at smc.vnet.net
>> Data: Domenica 27 giugno 2010, 17:37
>>
>> 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 at 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
>

```

• Prev by Date: Re: Absolute value
• Next by Date: Re: Need to Speed up Position[]
• Previous by thread: Re: Absolute value