Re: Unwanted definite-integral complex result from real integrand

*To*: mathgroup at smc.vnet.net*Subject*: [mg21497] Re: Unwanted definite-integral complex result from real integrand*From*: Paul Abbott <paul at physics.uwa.edu.au>*Date*: Wed, 12 Jan 2000 08:35:41 -0500 (EST)*Organization*: University of Western Australia*References*: <851esl$4bp@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Tom Crane wrote: > I am trying to do a > definite integral on a real expression but Mathematica always returns a complex > result. I need a real result and believe the result should be real. Why do you need a real result? It is not always the simplest representation. > Moveover, I want to produce a Fortran function of the result and even if I > were to use Fortran's complex datatype, terms of the form CosIntegal(x+Iy) > in the result are a problem since I want to use external functions (eg. NAG > library) to evaluate these special functions. Why? For many problems, Mathematica's numerics should be fast enough. What exactly do you want to do with the result? > My integrand is, > > (g*t1*(t - t1 + t*t1^2*(wa + wb)^2 + t1^3*(wa + wb)^2))/ > (1 + t1^2*(wa + wb)^2)^2 - > (g*t1^2*((-1 + t1^2*(wa + wb)^2)*Cos[t*(wa + wb)] + > 2*t1*(wa + wb)*Sin[t*(wa + wb)]))/(E^(t/t1)*(1 + t1^2*(wa + wb)^2)^2) > > and the integral is, eg. > > Integrate[%,{wa,-a,a}] > > By expanding the integrand into partial fractions I can partially > understand what going on w.r.t. the trig containing terms - they comprise, > something like, eg. Sin[t*(wa+wb)]/<a polynomial in wa>. I imagine that > Mathematica then tries to shoehorn this expression into the Sine Integral, the > complex terms arising from the manipulations/solutions of the polynomial > in the denominator?? None of this gets me anywhere and in any case > imaginary terms appear elsewhere in the integrated result. To better see what is going on, consider integrating (a Sin[a])/(a^2 + 1), which is, essentially, one term in your integrand: In[1]:= Simplify[Integrate[(a Sin[a])/(a^2 + 1), a]] Out[1]= (I*CosIntegral[-I + a]*Sinh[1] - I*CosIntegral[I + a]* Sinh[1] + Cosh[1]*(SinIntegral[-I + a] + SinIntegral[I + a]))/2 In[2]:= Collect[%, {Sinh[_], Cosh[_]}] Out[2]= ((I*CosIntegral[-I + a] - I*CosIntegral[I + a])*Sinh[1])/2 + (Cosh[1]*(SinIntegral[-I + a] + SinIntegral[I + a]))/2 This result is indeed real for real a. You can explicitly show this by employing the Symmetry Relations for Si and Ci (see Abramowitz and Stegun 5.2.19-20). E.g., Si(a+I)+Si(a-I) is real because Si(a-I) is the complex conjugate of Si(a+I) for real a. However, there is no simple expression (i.e., no other built-in special function) for the real and imaginary parts of Si(a+b I) etc., and hence (without the introduction of new special functions) there is no way to write Si(a+I)+Si(a-I) as an explicit real function of a. > Essentially, the thing I need to tell Mathematica is: Do the Integral, feel free > to use your knowledge of special functions etc. to make a more useful > result, but *don't* introduce any complex arithmetic. How can I persuade > it to do this? And as you have effectively discovered, this is not always (mathematically) possible! Cheers, Paul