MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re[a + I b] = a



> how can I tell mathematica that the variable a and b is real, so that
> Re[a+ I  b] results to a?

ComplexExpand assumes that a and b are real unless you tell it
otherwise.

In[2]:= ?ComplexExpand
ComplexExpand[expr] expands expr assuming that all variables are real.
   ComplexExpand[expr, {x1, x2, ... }] expands expr assuming that
variables
   matching any of the xi are complex.

In[3]:= ComplexExpand[ Re[a + I b] ]

Out[3]= a

> or: n a integer number and Sin[n x] results to 0?
>
> I am using mathematica 2.2

Algorithmically, this is a much harder (and largely unsolved) problem.
If your needs are not too elaborate, though, you may be able to program
it yourself, as in

In[4]:= Unprotect[Sin] ;

In[5]:= Sin[p_ Pi] := 0 /; IntegerQ[p]

In[6]:= Protect[Sin] ;

In[7]:= IntegerQ[n] ^= True ;

In[8]:= Sin[n Pi]

Out[8]= 0

Dave Withoff
Wolfram Research



  • Prev by Date: Re: ValueList command
  • Next by Date: define function of functions
  • Prev by thread: Re: Re[a + I b] = a
  • Next by thread: RE: Re[a + I b] = a