Re: Complex variables

*To*: mathgroup at christensen.cybernetics.net*Subject*: [mg1497] Re: [mg1478] Complex variables*From*: Allan Hayes <hay at haystack.demon.co.uk>*Date*: Mon, 19 Jun 1995 02:06:13 -0400

Stephen Resenbloom in [mg1478] Complex variables Wrote > In Mathematica is there a way to specify that given variables are purely real? i.e. if f= x + I y and one can specify that x and y are purely real variables, then Mathematica should be able to calculate Re[f] = x and Im[f]=y. So far I have found no way to do this. > Stephen, I'll come to your specific query below, but you may find the system function ComplexExpand useful: it assume that variable are real unless told other wise. f = x + I y; ComplexExpand[{Re[f], Im[f], Conjugate[f], Abs[f]}] 2 2 {x, y, x - I y, Sqrt[x + y ]} ComplexExpand[{Re[g], Im[g], Conjugate[g], Abs[g]},{g}] {Re[g], Im[g], -I Im[g] + Re[g], Abs[g]} ComplexExpand has an option TargetFunctions which lets you specify the kind of reduction you would like: ComplexExpand[ Conjugate[g], {g}, TargetFunctions -> {Abs}]//Simplify 2 Abs[g] ------- g The package << Algebra`ReIm` Lets you specify which variable are real, as you want (note that we use up definitions to localize the effect and avoid the need to unprotect Im and Re). Im[x]^= Im[y]^= 0; {Re[f], Im[f], Conjugate[f], Abs[f]} {x, y, x - I y, Abs[x + I y]} The result for Abs is rather surprising. Here is a little more ComplexExpand[a^b, {a}]//Factor (*{a} says that a is complex*) b Abs[a] (Cos[b Arg[a]] + I Sin[b Arg[a]]) We can use <<Algebra`Trigonometry` to put this in a more compact form TrigToComplex[%]//Simplify I b Arg[a] b E Abs[a] Allan Hayes hay at haystack.demon.co.uk