Re: HELP: specifying range for a variable?
- To: mathgroup at smc.vnet.net
- Subject: [mg17359] Re: [mg17336] HELP: specifying range for a variable?
- From: BobHanlon at aol.com
- Date: Mon, 3 May 1999 01:45:58 -0400
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 5/1/99 8:57:03 AM, iaz at cs.umd.edu writes: >How do I tell Mathematica that a variable that I define >should be real? Suppose I write something like > > c[a_,b_] = a+b*I; > >I want Mathematica to treat a and b as purely real >numbers so that, for instance, if I do > > Im[c[a,b]] > >I will get b as the answer. However, I haven't found any >way of limiting the range of a variable. > Ilya, c[a_,b_] := a+b*I; Im[c[a,b]] Im(a)+Re(b) Load the standard package Algebra`ReIm` then declare a and b as real by defining their imaginary parts as zero Needs["Algebra`ReIm`"]; a/: Im[a] = 0; (* alternatively, Im[a] ^= 0 *) b/: Im[b] = 0; Im[c[a,b]] b Bob Hanlon