Re: Complex Numbers

• To: mathgroup at smc.vnet.net
• Subject: [mg47448] Re: Complex Numbers
• From: Jon Harrop <jdh30 at cam.ac.uk>
• Date: Mon, 12 Apr 2004 03:45:02 -0400 (EDT)
• Organization: University of Cambridge
• References: <c5b0tc\$7lc\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Alejandro Vizcarra wrote:
> I always have problems when dealing with complex numbers.  How can i
> work with Mathematica in such a way that every expression will
> be considered real unless it is declared explicitly complex (like a = 3 +
> 4 I ) ?

The best recommendation that I can make is to routinely simplify expressions
using something like:

In  := assume = Im[a] == 0 && Im[b] == 0;
In  := FullSimplify[-Im[Sin[a + b]] + Re[Cos[a + b]], assume]
Out := Cos[a + b]

But this requires FullSimplify rather than Simplify and FullSimplify is very
time consuming on large expressions.

An alternative is to define up-values associated with the variables to
declare that their real parts are themselves and their imaginary parts are
zero, rather than keeping and passing my "assume" variable around:

In  := Re[a] ^= a; Im[a] ^= 0; Re[b] ^= b; Im[b] ^= 0;
In  := FullSimplify[-Im[Sin[a + b]] + Re[Cos[a + b]]]
Out := Cos[a + b]

But I have a hunch that this won't be as powerful at simplifying the
expressions as the "assume" approach.

I do not know of any way to manifestly declare something as being
real-valued. I believe this would be a bad idea anyway, as the current
method enforces mathematical rigour. Whilst checking a proof for my PhD
thesis, for example, Mathematica's pedantry led me to make two of my
assumptions explicit. Although the assumptions may have been "obvious" to a
human reader, it can be nice to have that kind of pedantry. :)

HTH.

Cheers,
Jon.

```

• Prev by Date: When Is Precision[ ] \$MachinePrecision, And When Is It Not?
• Next by Date: Format Style
• Previous by thread: RE: Complex Numbers
• Next by thread: Re: Complex Numbers