MathGroup Archive 1999

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

Search the Archive

Re: Real integrand->complex result.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20308] Re: [mg20293] Real integrand->complex result.
  • From: David Withoff <withoff at wolfram.com>
  • Date: Fri, 15 Oct 1999 20:20:40 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

> I get a complex result of the form f(t)=(a+bi)g(t) when evaluating a
> real integrand F(x,t)*phi(x) over the interval {x:0<x<L). All of the
> variables have been properly declared as real and the functions have
> been declared as real for real arguments (using the package "ReIm").
>
> To see the problem more clearly, the code can be copied into Mathematica
> (3 or 4) and executed. (The Traditional or Standard Forms will not paste
> into a text document such as this)
> 
>  When evaluating the integral
> 
>   \!\(\[Integral]\_0\%\[ScriptL]\( simpF\[CurlyPhi]\_n\) \[DifferentialD]x\)
> 
> over the interval (0,ScriptL) where ScriptL=1. The integrand
>   \!\(simpF\[CurlyPhi]\_n\ is, for n=1, given by
> 
>   \!\(TraditionalForm
>   \`\(-\(1\/6\)\)\ \[ExponentialE]\^\(\(\(-3\)\ \[Tau]\)/2\)\
>   \((\((3 + 2\ \[Pi]\^2)\)\ \(cos(\[Pi]\ x)\) -
>   6\ \[ExponentialE]\^\(x/2\) + 3)\)\ \((cos(3.66558239083868908`\ x) +
>   sin(3.66558239083868908`\ x))\)\)
> 
> The evaluation of the integral is also quite slow, even for n=2, even
> when the expression is simplified as much as possible, and the final
> program will need to evaluate a larger number of terms.
> 
> Thanks in advance, Bill

The imaginary 0.0 I parts are an artifact of numerical error.  You can
discard those parts using Chop.  For example:

In[1]:= Integrate[(-(1/6) (3 - 6 E^(x/2) + (3 + 2 Pi^2) Cos[Pi x])*
            (Cos[3.665582390838689 x] + Sin[3.665582390838689 x]))/
                   E^((3 tau)/2), {x, 0, L}] //Chop


Out[1]= -(22.7991 + 1.38775 (-0.589747 Cos[3.66558 L] + 
 
               0.5 L
>          1. E      Cos[3.66558 L] - 16.839 Cos[3.14159 L] Cos[3.66558 L] - 
 
>          14.4319 Cos[3.66558 L] Sin[3.14159 L] + 0.589747 Sin[3.66558 L] - 
 
                   0.5 L
>          1.3159 E      Sin[3.66558 L] + 
 
>          16.839 Cos[3.14159 L] Sin[3.66558 L] - 
 
                                                         (3 tau)/2
>          14.4319 Sin[3.14159 L] Sin[3.66558 L])) / (6 E         )

That calculation finished in a fraction of a second when I tried it.
The slowness in your calculation is almost certainly due to the ReIm
package, which will consume a lot of time and will not be helpful,
because there isn't anything that this or any other package can do to
avoid numerical error.

Dave Withoff
Wolfram Research


  • Prev by Date: Composing a stiffness matrix
  • Next by Date: Solving trig equations - Tan[x] = Sqrt[3]
  • Previous by thread: Real integrand->complex result.
  • Next by thread: Re: Real integrand->complex result.