Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: Integration Problems

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13929] Re: Integration Problems
  • From: "Allan Hayes" <hay at haystack.demon.cc.uk>
  • Date: Tue, 8 Sep 1998 02:52:28 -0400
  • References: <6svrm3$s40@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Georgios Kotsalis wrote in message <6svrm3$s40 at smc.vnet.net>...
>Dear Sirs ,
>
>while performing the following evaluation, i received an unexpected
>result:
>
>1.) W1[x_,t_]:=
>    q[2,1][t] (Sin[4.73 x] - Cos[4.73 x] + Exp[-4.73 x] + Exp[-4.73
>(1-x)]);
>
>2.) W2[x_,t_]:=Evaluate[(D[W1[x,t],{x,2} ])^2]
>
>3.) Integrate[W2[x,t],{x,0,1}]
>
>Answer:
>
>(509.399 -2.922295 X 10^-5 I) q[2,1][t]^2
>
>Could you please tell me, why does an imaginary part arise though the
>function
>that is being integrated is real ?
>


Georgios:
It comes from internal inexact computations thet work with complex
forms. You can get rid of the small complex part by using Chop. I also
tried to  integrate the exact form, with 4.73 replaced by 473/100, but
I had to turn off after quite a long time; however the answer came out
quite quickly when I expanded the integrand and integrated the summands
separately (this trick is often useful); also the inexact form treated
this way came out as real:

(1) Your example
W1[x_,t_]:=
q[2,1][t] (Sin[4.73 x] - Cos[4.73 x] + Exp[-4.73 x] + Exp[-4.73 (1-x)]);
W2[x_,t_]=D[W1[x,t],{x,2} ]^2;

Integrate[W2[x,t],{x,0,1}]

                     -15              2 (509.399 + 1.46147 10    I) q[2,
1][t]

Chop[%]
Out[4]=
                  2
509.399 q[2, 1][t]

(2) Expanded inexact form
Integrate[#,{x,0,1}]&/@Expand[W2[x,t]]

                  2
509.399 q[2, 1][t]

(3) Expanded exact form

Integrate[#,{x,0,1}]&/@Expand[Rationalize[W2[x,t]]]

                      2                          2
  105823817 q[2, 1][t]     39472283741 q[2, 1][t]
-(---------------------) + ----------------------- +
              473/50                    473/100
     1000000 E                50000000 E

                473 2           2
  105823817 Cos[---]  q[2, 1][t]
                100
  ------------------------------- +
              1000000

                 473        473             2
  105823817 (Cos[---] - Sin[---]) q[2, 1][t]
                 100        100
  ------------------------------------------- -
                    1000000

                 473        473             2
  105823817 (Cos[---] - Sin[---]) q[2, 1][t]
                 100        100
  ------------------------------------------- +
                        473/100
               1000000 E

                 473        473             2
  105823817 (Cos[---] + Sin[---]) q[2, 1][t]
                 100        100
  ------------------------------------------- +
                    1000000

                 473        473             2
  105823817 (Cos[---] + Sin[---]) q[2, 1][t]
                 100        100
  ------------------------------------------- +
                        473/100
               1000000 E

             473       473             2
  105823817 (--- - Sin[---]) q[2, 1][t]
             50        50
  -------------------------------------- +
                 4000000

             473       473             2
  105823817 (--- + Sin[---]) q[2, 1][t]
             50        50
  --------------------------------------
                 4000000


Simplify:

Simplify[%]
                        473/100        473/50 (105823817 (-100 + 746 E  
+ 523 E       +

           473/50     473        473/50     473
      200 E       Cos[---] + 50 E       Cos[---] +
                      100                   50

           473/100     473             2
      200 E        Sin[---]) q[2, 1][t] ) /
                       100

              473/50
  (100000000 E      )

Numerical value

N[%]

                    2
509.399 q[2., 1.][t]

------------------------------------------------------------- 
Allan Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay at haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642




  • Prev by Date: Re: Mathematica text-to-speech?
  • Next by Date: Re: Postscript Error
  • Previous by thread: Integration Problems
  • Next by thread: Re: Integration Problems