Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Exponential form
Hi,
When I operate with complex numbers in Exponential Form, Mathematica
yields in complex form. How can I operate with Exponential Form. For
example,

In: h=a E^(I b)+ c E^(I d)
Out: f E^(I g)

I tried with Abs[h] E^(Arg[h]) but it does not work

Thanks


Report this thread to moderator Post Follow-up to this message
Old Post
Miguel
08-30-05 08:57 AM


Re: Exponential form
You can use ComplexExpand to develop expressions for the modulus f and the
argument g.

h = a E^(I b) + c E^(I d);

ComplexExpand[Abs[h]];
f = Simplify[%]
Sqrt[a^2 + c^2 + 2*a*c*Cos[b - d]]

g = ComplexExpand[Arg[h], TargetFunctions -> {Re, Im}]
ArcTan[a Cos[b] + c Cos[d], a Sin[b] + c Sin[d]]

These can then be combined in a definition for the exponential form.

expform[a_, b_, c_, d_] = f*E^(I*g)
E^(I*ArcTan[a*Cos[b] + c*Cos[d], a*Sin[b] +
c*Sin[d]])*Sqrt[a^2 + c^2 + 2*a*c*Cos[b - d]]

As long as you use exact input you will obtain the exponential form.

expform[1, 1, 1, 1]
2*E^I

expform[3, 2, -5, 2]
2*E^(I*(2 - Pi))

But if you enter an approximate number, then Mathematica will reduce to a
complex number.

expform[3.0, 2, -5, 2]
0.832294 - 1.81859 I

An alternative is not to combine the modulus and argument into one
expression but write a routine that keeps them separate.

modulusarg[a_, b_, c_, d_] = {f, g}
{Sqrt[a^2 + c^2 + 2*a*c*Cos[b - d]],
ArcTan[a*Cos[b] + c*Cos[d], a*Sin[b] + c*Sin[d]]}

Then

modulusarg[3.0, 2, -5, 2]
{2., -1.14159}

Or we could write a definition that puts the modulus and argument in
HoldForm to prevent full evaluation by Mathematica.

expform2[a_, b_, c_, d_] :=
With[{modulus = Sqrt[a^2 + c^2 + 2*a*c*Cos[b - d]],
arg = ArcTan[a*Cos[b] + c*Cos[d],
a*Sin[b] + c*Sin[d]]}, HoldForm[modulus]*
Exp[I*HoldForm[arg]]]

You then have to do a ReleaseHold to obtain the final numerical expression.

expform2[3.0, 2, -5, 2]
% // ReleaseHold
E^(-1.14159 I)2.
0.832294 - 1.81859 I

David Park
djmp@earthlink.net
http://home.earthlink.net/~djmp/



From: Miguel [mailto:m.glanda@iberdrola.es]


Hi,
When I operate with complex numbers in Exponential Form, Mathematica
yields in complex form. How can I operate with Exponential Form. For
example,

In: h=a E^(I b)+ c E^(I d)
Out: f E^(I g)

I tried with Abs[h] E^(Arg[h]) but it does not work

Thanks





Report this thread to moderator Post Follow-up to this message
Old Post
David Park
08-31-05 08:59 AM


Re: Exponential form
Miguel schrieb:
> Hi,
> When I operate with complex numbers in Exponential Form, Mathematica
> yields in complex form. How can I operate with Exponential Form. For
> example,
>
> In: h=a E^(I b)+ c E^(I d)
> Out: f E^(I g)
>
> I tried with Abs[h] E^(Arg[h]) but it does not work
>
> Thanks
>
{f,g} = Simplify[ComplexExpand[#[a*E^(I*b) + c*E^(I*d)]& /@ {Abs, Arg}]]

-->
{Sqrt[a^2 + c^2 + 2*a*c*Cos[b - d]],
ArcTan[a*Cos[b] + c*Cos[d], a*Sin[b] + c*Sin[d]]}

--
Peter Pein, Berlin
GnuPG Key ID: 0xA34C5A82
http://people.freenet.de/Peter_Berlin/


Report this thread to moderator Post Follow-up to this message
Old Post
Peter Pein
08-31-05 08:59 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Mathematica archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:19 AM.

 

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.