Re: stange result with complex numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg36263] Re: [mg36251] stange result with complex numbers
- From: BobHanlon at aol.com
- Date: Thu, 29 Aug 2002 01:37:46 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 8/28/02 5:47:55 AM, pnagy at gwdg.de writes: > I am having a strange problem with a function giving a complex number as > a result. I did the following: > - define a function: > denom[x_, p_, d_] := Sqrt[1 + (x*Tan[p]/d)^2] > > Integrate and simplify it with the assumption that d is larger than 0: > FullSimplify[Integrate[denom[x, p, d], {x, 0, d}], d > 0] > > The result of the above line is > d/2*(1+i*Sqrt[2]*d*Cos[p]^2)*Sqrt[Sec[p]^2] where i is Sqrt[-1] > > I assing it to a function called peter in the following way: > peter[p_, d_] := FullSimplify[Integrate[denom[x, p, d], {x, 0, d}], d>0] > > and check the value of the function at [0,1] > peter[0,1] > > and the result is 1. > How is it possible that the result doesn't have an imaginary part??? > I would expect the result to be 0.5+Sqrt[2]/2*i > You are evaluating the integral each time that you call peter. When you call it with p=0 denom is evaluated to 1 before the integration. Define peter with Evaluate or else don't use a delayed set. denom[x_,p_,d_]:=Sqrt[1+(x*Tan[p]/d)^2]; peter[p_,d_]:=Evaluate[FullSimplify[Integrate[denom[x,p,d],{x,0,d}],d>0]]; peter2[p_,d_]:=FullSimplify[Integrate[denom[x,p,d],{x,0,d}],d>0]; peter[0,1] (1/2)*(1 + I*Sqrt[2]) peter2[0,1] 1 peter2[10^-6,1]//N 0.5 + 0.707107*I peter2[-10^-6,1]//N 0.5 + 0.707107*I Bob Hanlon Chantilly, VA USA