Re: Real integrand->complex result.
- To: mathgroup at smc.vnet.net
- Subject: [mg20304] Re: [mg20293] Real integrand->complex result.
- From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
- Date: Fri, 15 Oct 1999 20:20:38 -0400
- Sender: owner-wri-mathgroup at wolfram.com
The tiny imaginary parts that you often get in Mathematica computations involving non-exact numbers can be got rid of using the function Chop. (I would also recommend that if you want people to seriously look at examples you send by e-mail you should either use InputForm or paste in a complete notebook as a NotebookExpression). -- Andrzej Kozlowski Toyama International University JAPAN http://sigma.tuins.ac.jp http://eri2.tuins.ac.jp ---------- >From: William Golz <wgolz at attglobal.net> >To: mathgroup at smc.vnet.net >Subject: [mg20304] [mg20293] Real integrand->complex result. >Date: Tue, 12 Oct 1999 03:39:30 -0400 > > Synopsis of the problem: > 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))\)\) > > and for n=2, > > \!\(TraditionalForm > \`\(-\(1\/6\)\)\ \[ExponentialE]\^\(\(\(-3\)\ > \[Tau]\)/2\)\ > \((\((3 + 2\ \[Pi]\^2)\)\ \(cos(\[Pi]\ x)\) - > 6\ \[ExponentialE]\^\(x/2\) + 3)\)\ > \((cos(6.58302641111680308`\ x) + > sin(6.58302641111680308`\ x))\)\) > > I get the result for n=1,2, respectively > > \!\(TraditionalForm > \`\((\(-2.34710341268466837`\) + 0.`\ \[ImaginaryI])\)\ > > \[ExponentialE]\^\(\(\(-3\)\ \[Tau]\)/2\)\) > > \!\(TraditionalForm > \`2\[InvisibleSpace]'' ''\[InvisibleSpace]\(\(( > \(-1.26446964467229783`\) + 0.`\ \[ImaginaryI])\)\ > \[ExponentialE]\^\(\(\(-3\)\ \[Tau]\)/2\)\)\) > > For simple functions F, the product F*phi can be integrated by parts, > where the result contains no potential for complex coefficients when the > variables are real valued. However, evaluating an identical integrand in > Mathematica will give the result f(t)=(a+0.i)g(t). There does not seem > to be any way to avert this, either by defining the variables to be real > and the functions to be real valued (for real arguments). > > 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 > >