Re: complex numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg105910] Re: [mg105904] complex numbers
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 24 Dec 2009 20:59:21 -0500 (EST)
- Reply-to: hanlonr at cox.net
Clear[x, y, z]; z = x + I*y; {Re[z], Im[z], Abs[z]} {Re[x] - Im[y], Im[x] + Re[y], Abs[x + I*y]} Use assumptions to target specific variables as Real Assuming[{Element[{x, y}, Reals]}, #[{Re[z], Im[z], Abs[z]}] & /@ {Simplify, FullSimplify}] {{x, y, Abs[x + I*y]}, {x, y, Abs[x + I*y]}} Assuming[{Element[{x, y}, Reals]}, #[{Re[z], Im[z], Abs[z]}] & /@ {Simplify, FullSimplify}] {{x, y, Abs[x + I*y]}, {x, y, Abs[x + I*y]}} If appropriate (i.e., all variables are Real), use ComplexExpand {Re[z], Im[z], Abs[z]} // ComplexExpand {x, y, Sqrt[x^2 + y^2]} Use TagSet for x and y x /: Im[x] = 0; x /: Re[x] = x; y /: Im[y] = 0; y /: Re[y] = y; {Re[z], Im[z], Abs[z]} {x, y, Abs[x + I*y]} Bob Hanlon ---- Jon Joseph <josco.jon at gmail.com> wrote: ============= All: Something fundamental about complex number initialization I am failing to understand. I wish to define a complex number z=x+ I y where x and y are both reals. Can someone tell me the proper way to tell Mathematica that x, y are real so that Re[z] returns x and Im[z] returns y? Much appreciated, Jon.