MathGroup Archive 2011

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

Search the Archive

Re: Mathematica Weirdness

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116730] Re: Mathematica Weirdness
  • From: Gary Wardall <gwardall at gmail.com>
  • Date: Fri, 25 Feb 2011 06:36:10 -0500 (EST)
  • References: <ik5feh$sm2$1@smc.vnet.net>

On Feb 24, 5:29=C2 am, Bob Hanlon <hanl... at cox.net> wrote:
> You need to use more precision
>
> N[Integrate[1000000*Exp[x^2 - 12*x]*x^14, {x, 0, 1}], 20]
>
> 2.7482124237345664276
>
> NIntegrate[1000000*Exp[x^2 - 12*x]*x^14, {x, 0, 1}]
>
> 2.74821
>
> Bob Hanlon
>
> ---- Steve Heston <shes... at rhsmith.umd.edu> wrote:
>
> =============
> My question is why I get a negative integral of a positive
> function?
>
> Integrate[1000000*Exp[x^2-12*x]*x^14,{x,0,1}]//N
> Integrate[1000000*Exp[x^2-12*x]*x^14,{x,0.,1}]//N
> NIntegrate[1000000*Exp[x^2-12*x]*x^14,{x,0,1}]
>
> The first line gives a negative answer, while the second two lines give
> identical positive answers. =C2 Something is strange here.
>
> Steve
>
> Steven L. Heston
> Associate Professor
> Finance Department
> Robert H. Smith School of Business
> 4447 Van Munching Hall Van Munching Hall
> University of Maryland
> College Park, MD 20742-1815
> 301-405-9686 TEL
> 301-405-0359 FAX
> shes... at rhsmith.umd.eduhttp://www.rhsmith.umd.edu


I made a slight error yesterday. I checked the derivative of the
antiderivative of

1000000*Exp[x^2 - 12*x]*x^14

Mathematica 8 yields:


1000000 E^((-12 + x) x) x^14

Which the same as:

1000000*Exp[x^2 - 12*x]*x^14

In other words Mathematica 8 did the symbolic calculations correctly.
The problem must be in the numerical evaluations. Both the
antiderivative and the derivative of the antiderivative do not render
accurate results near x=0.

Gary Wardall
***************************
See below the steps below

Define:

F[x_] := Integrate[1000000*Exp[t^2 - 12*t]*t^14, {t, 0, x}]

F[x]=15625/2 (-174657787110 + 2065912371945 DawsonF[6] + =E2=80=A8   E^((-12 +
x) x) (174657787110 + =E2=80=A8      x (29981073375 + =E2=80=A8         2 x
(2614326570 + =E2=80=A8            x (463615155 + =E2=80=A8               2x
(41841090 + =E2=80=A8                  x (7695585 + =E2=80=A8              2 x
(722070 + =E2=80=A8                    x (138465 + =E2=80=A8               =
     2 x
(13590 + =E2=80=A8                    x (2735 + 2 x (282 + x (59 + 2 x (6 +
x)))))))))))) - =E2=80=A8      2065912371945 DawsonF[6 - x]))

Compute:

D[15625/2 (-174657787110 + 2065912371945 DawsonF[6] + =E2=80=A8   E^((-12 +=
 x)
x) (174657787110 + =E2=80=A8      x (29981073375 + =E2=80=A8         2 x (2=
614326570
+ =E2=80=A8            x (463615155 + =E2=80=A8               2 x (41841090=
 +
                  x (7695585 + =E2=80=A8                    2 x (722070 +
                    x (138465 + =E2=80=A8                    2 x (13590 +
                    x (2735 + 2 x (282 + x (59 + 2 x (6 +
x)))))))))))) - =E2=80=A8      2065912371945 DawsonF[6 - x])),x]


We get:

15625/2 (E^((-12 + x) x) (-12 + 2 x) (174657787110 + =E2=80=A8      x
(29981073375 + =E2=80=A8         2 x (2614326570 + =E2=80=A8            x (=
463615155
+ =E2=80=A8               2 x (41841090 + =E2=80=A8                  x (769=
5585 +
                    2 x (722070 + =E2=80=A8                    x (138465 +
                    2 x (13590 + =E2=80=A8                    x (2735 + 2 x
(282 + x (59 + 2 x (6 + x)))))))))))) - =E2=80=A8      2065912371945 Dawson=
F[6
- x]) + =E2=80=A8   E^((-12 + x) x) (29981073375 + =E2=80=A8      2 x (2614=
326570 +
         x (463615155 + =E2=80=A8            2 x (41841090 + =E2=80=A8     =
          x
(7695585 + =E2=80=A8                  2 x (722070 + =E2=80=A8              =
      x
(138465 + =E2=80=A8                    2 x (13590 + =E2=80=A8              =
      x
(2735 + 2 x (282 + x (59 + 2 x (6 + x))))))))))) + =E2=80=A8      x (2 x
(463615155 + =E2=80=A8            2 x (41841090 + =E2=80=A8               x=
 (7695585
+ =E2=80=A8                  2 x (722070 + =E2=80=A8                    x (=
138465 +
                    2 x (13590 + =E2=80=A8                    x (2735 + 2 x
(282 + x (59 + 2 x (6 + x))))))))) + =E2=80=A8            x (2 x (7695585 +
                  2 x (722070 + =E2=80=A8                    x (138465 +
                    2 x (13590 + =E2=80=A8                    x (2735 + 2 x
(282 + x (59 + 2 x (6 + x))))))) + =E2=80=A8                  x (2 x (13846=
5
+ =E2=80=A8                    2 x (13590 + =E2=80=A8                    x =
(2735 + 2 x
(282 + x (59 + 2 x (6 + x))))) + =E2=80=A8                    x (2 x (2735 =
+ 2
x (282 + x (59 + 2 x (6 + x))) + =E2=80=A8                    x (2 x (59 + =
2 x
(6 + x) + x (2 x + 2 (6 + x))) + =E2=80=A8                    2 (282 + x (5=
9 +
2 x (6 + x))))) + =E2=80=A8                    2 (13590 +
x (2735 + 2 x (282 + x (59 + 2 x (6 + x))))))) +
2 (722070 + =E2=80=A8                    x (138465 + =E2=80=A8             =
       2 x
(13590 + =E2=80=A8                    x (2735 + 2 x (282 + x (59 + 2 x (6 +
x))))))))) + =E2=80=A8               2 (41841090 + =E2=80=A8               =
   x
(7695585 + =E2=80=A8                    2 x (722070 + =E2=80=A8            =
        x
(138465 + =E2=80=A8                    2 x (13590 + =E2=80=A8              =
      x
(2735 + 2 x (282 + x (59 + 2 x (6 + x))))))))))) + =E2=80=A8         2
(2614326570 + =E2=80=A8            x (463615155 + =E2=80=A8               2=
 x
(41841090 + =E2=80=A8                  x (7695585 + =E2=80=A8              =
      2 x
(722070 + =E2=80=A8                    x (138465 + =E2=80=A8               =
     2 x
(13590 + =E2=80=A8                    x (2735 + 2 x (282 + x (59 + 2 x (6 +
x)))))))))))) + =E2=80=A8      2065912371945 (1 - 2 (6 - x) DawsonF[6 - x])=
))

Simplify[%]

The result is:

1000000 E^((-12 + x) x) x^14


Which is the same as:

1000000*Exp[x^2 - 12*x]*x^14


  • Prev by Date: Re: outputting C code
  • Next by Date: Re: FinancialData Function Not Working for Property "Members"
  • Previous by thread: Re: Mathematica Weirdness
  • Next by thread: Re: Mathematica Weirdness