From: Marco Masi on
Thanks, this gave some insight. And yet I'm struggling to get it in another form. I have to work with an expression like:

FullSimplify[
Collect[ComplexExpand[
Abs[A1 E^(I \[Phi]1) ((1 + Cos[Sqrt[2] c z])/2) +
AD E^(I \[Phi]D) I/Sqrt[2] Sin[Sqrt[2] c z] +
A2 E^(I \[Phi]2) ((Cos[Sqrt[2] c z] - 1)/2)]^2,
TargetFunctions -> {Re, Im}], A1 | A2 | AD], TrigFactor]

Which does not separate A1, A2 and AD. I would like to have an output in a form like:

A1^2*f1[Cos[Sqrt[2] c z],Sin[Sqrt[2] c z]] + A2^2*f2[Cos[Sqrt[2] c z],Sin[Sqrt[2] c z]] + AD^2*f3[Cos[Sqrt[2] c z],Sin[Sqrt[2] c z]],

where f1, f2, and f3 are some functions of Cos[Sqrt[2] c z] and Sin[Sqrt[2] c z]. Is this possible?

Regards, Mark.


--- Lun 28/6/10, Peter Pein <petsie(a)dordos.net> ha scritto:

Da: Peter Pein <petsie(a)dordos.net>
Oggetto: Re: Absolute value
A:
Data: Luned=EC 28 giugno 2010, 09:05

Am Mon, 28 Jun 2010 06:30:57 +0000 (UTC)
schrieb Marco Masi <marco.masi(a)ymail.com>:

> 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[2] c z] + A2 E^(I
> \[Phi]2) Cos[Sqrt[2] c z])]]^2]
>
> I would like to have Mathematica avoiding one of the resulting Cos[2
> Sqrt[2] c z] expression, and maintain both as Cos[Sqrt[2] c z], and
> then simplify. How should I proceed?
>
> Regards, Mark.
>

Hi Mark,

try squaring the absolute value before using ComplexExpand:
FullSimplify[ComplexExpand[
Abs[(1/2)*(A1*E^(I*\[Phi]1) - A2*E^(I*\[Phi]2) +
A1*E^(I*\[Phi]1)*Cos[Sqrt[2]*c*z] +
A2*E^(I*\[Phi]2)*Cos[Sqrt[2]*c*z])]^2]]

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

but I would prefer:

Collect[
ComplexExpand[
Abs[(1/2)*(A1*E^(I*\[Phi]1) -
A2*E^(I*\[Phi]2) + A1*E^(I*\[Phi]1)*Cos[Sqrt[2]*c*z] +
A2*E^(I*\[Phi]2)*Cos[Sqrt[2]*c*z])]^2,
TargetFunctions -> {Re,Im}],
A1 | A2, TrigFactor]

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

Peter
From: Alexei Boulbitch on
Hi, Mark,
the most important part you have already done, the rest may be done like this:


(* This is your starting expression *)
startingExpression =
ComplexExpand[
Abs[A1 E^(I \[Phi]1) ((1 + Cos[Sqrt[2] c z])/2) +
AD E^(I \[Phi]D) I/Sqrt[2] Sin[Sqrt[2] c z] +
A2 E^(I \[Phi]2) ((Cos[Sqrt[2] c z] - 1)/2)]^2,
TargetFunctions -> {Re, Im}];

(* Here each term, i.e. ~ A1^2, A2^2 and AD^2, is separated out *)

expr1 = startingExpression /. {A2 -> 0, AD -> 0} // Factor;
expr2 = startingExpression /. {A1 -> 0, AD -> 0} // Factor;
expr3 = startingExpression /. {A2 -> 0, A1 -> 0} // Factor;

(* done *)

finalExpression = expr1 + expr2 + expr3

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

Have fun, Alexei





Thanks, this gave some insight. And yet I'm struggling to get it in another form. I have to work with an expression like:

FullSimplify[
Collect[ComplexExpand[
Abs[A1 E^(I \[Phi]1) ((1 + Cos[Sqrt[2] c z])/2) +
AD E^(I \[Phi]D) I/Sqrt[2] Sin[Sqrt[2] c z] +
A2 E^(I \[Phi]2) ((Cos[Sqrt[2] c z] - 1)/2)]^2,
TargetFunctions -> {Re, Im}], A1 | A2 | AD], TrigFactor]

Which does not separate A1, A2 and AD. I would like to have an output in a form like:

A1^2*f1[Cos[Sqrt[2] c z],Sin[Sqrt[2] c z]] + A2^2*f2[Cos[Sqrt[2] c z],Sin[Sqrt[2] c z]] + AD^2*f3[Cos[Sqrt[2] c z],Sin[Sqrt[2] c z]],

where f1, f2, and f3 are some functions of Cos[Sqrt[2] c z] and Sin[Sqrt[2] c z]. Is this possible?

Regards, Mark.

--
Alexei Boulbitch, Dr. habil.
Senior Scientist
Material Development

IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 CONTERN
Luxembourg

Tel: +352 2454 2566
Fax: +352 2454 3566
Mobile: +49 (0) 151 52 40 66 44

e-mail: alexei.boulbitch(a)iee.lu

www.iee.lu

--

This e-mail may contain trade secrets or privileged, undisclosed or
otherwise confidential information. If you are not the intended
recipient and have received this e-mail in error, you are hereby
notified that any review, copying or distribution of it is strictly
prohibited. Please inform us immediately and destroy the original
transmittal from your system. Thank you for your co-operation.


From: Andrzej Kozlowski on
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[2]*c*z] + A2*E^(I*\[Phi]2)*
Cos[Sqrt[2]*c*z])]]^2, Cos[Sqrt[2]*c*z], FullSimplify]

(1/4)*Cos[Sqrt[2]*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[2]*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[2]*c*z] + A2*E^(I*\[Phi]2)*
> Cos[Sqrt[2]*c*z])]]^2,
> ExcludedForms -> Cos[Sqrt[2]*c*z]]
>
> (1/4)*(A1^2*(Cos[Sqrt[2]*c*z] + 1)^2 +
> 2*A1*A2*(Cos[Sqrt[2]*c*z]^2 - 1)*Cos[\[Phi]1 - \[Phi]2] +
> A2^2*(Cos[Sqrt[2]*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[2] c z] + A2 E^(I \[Phi]2) Cos[Sqrt[2] c z])]]^2]
>>
>> I would like to have Mathematica avoiding one of the resulting Cos[2 Sqrt[2] c z] expression, and maintain both as Cos[Sqrt[2] c z], and then simplify. How should I proceed?
>>
>> Regards, Mark.
>>
>>
>> --- Dom 27/6/10, Murray Eisenberg <murray(a)math.umass.edu> ha scritto:
>>
>> Da: Murray Eisenberg <murray(a)math.umass.edu>
>> Oggetto: Re: Absolute value
>> A: mathgroup(a)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(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: Andrzej Kozlowski on
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[2]*c*z] + A2*E^(I*\[Phi]2)*
Cos[Sqrt[2]*c*z])]]^2,
ExcludedForms -> Cos[Sqrt[2]*c*z]]

(1/4)*(A1^2*(Cos[Sqrt[2]*c*z] + 1)^2 +
2*A1*A2*(Cos[Sqrt[2]*c*z]^2 - 1)*Cos[\[Phi]1 - \[Phi]2] +
A2^2*(Cos[Sqrt[2]*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[2] c z] + A2 E^(I \[Phi]2) Cos[Sqrt[2] c z])]]^2]
>
> I would like to have Mathematica avoiding one of the resulting Cos[2 Sqrt[2] c z] expression, and maintain both as Cos[Sqrt[2] c z], and then simplify. How should I proceed?
>
> Regards, Mark.
>
>
> --- Dom 27/6/10, Murray Eisenberg <murray(a)math.umass.edu> ha scritto:
>
> Da: Murray Eisenberg <murray(a)math.umass.edu>
> Oggetto: Re: Absolute value
> A: mathgroup(a)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(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