MathGroup Archive 2011

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

Search the Archive

Re: Mathematica Weirdness

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116700] Re: Mathematica Weirdness
  • From: Gary Wardall <gwardall at gmail.com>
  • Date: Thu, 24 Feb 2011 06:23:35 -0500 (EST)
  • References: <ik2nab$9kk$1@smc.vnet.net>

On Feb 23, 4:25=C2 am, 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


Steve,

There is a problem, a very interesting problem.

Define the function:

f[x_] := 1000000*Exp[x^2 - 12*x]*x^14

Then the first and second derivatives are:

f1[x_] := =E2=80=A8 14000000 E^(-12 x + x^2) x^13 + 1000000 E^(-12 x + x^2)
x^14 (-12 + 2 x)

f2[x_] := =E2=80=A8 182000000 E^(-12 x + x^2) x^12 + 28000000 E^(-12 x + x^2)
x^13 (-12 + 2 x) + =E2=80=A8  1000000 x^14 (2 E^(-12 x + x^2) + E^(-12 x +
x^2) (-12 + 2 x)^2)

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

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               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]))

(Check these results in Mathematica.)

Since the first derivative is positive and continuous on [0,1] then
f[x] is a rising function on [0,1]. (The first derivative has zeros at
x=0, 3 - Sqrt[2], and 3 + Sqrt[2].
At x=0 the zero has a multiplicity 13. The other roots are not on
[0,1].)

Since f[x] is rising on [0,1] and f[0]=0 then the integral function
F[x] must be positive on [0,1].

Make plots of the functions:

Plot[f[x], {x, 0, 1}]

Plot[f1[x], {x, 0, 1}]

Plot[f2[x], {x, 0, 1}]

These functions and their graphs are not that "weird".

Plot also F[x].

Plot[F[x], {x, 0, 1}]

This graph is "weird" and not a correct representation of the
function.

Note also by the Fundamental Theorem of Calculus that the first
derivative of the F[x] must be the function f[x]. Use the D operation
on F[x].  You should get the the function f[x]. But it's not quite
right.  (This can be seen graphically and numerically quite easily.)
So either Mathematica 8 is not symbolically integrating or not
symbolically differentiating correctly or both.

If Mathematica is not symbolically integrating correctly it would
explain why

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

are not giving good approximations.

The result obtained from:

NIntegrate[1000000*Exp[x^2 - 12*x]*x^14, {x, 0, 1}]

is a good approximation. This I verified independently using the
Trapezoid and Simpson's 1/3 rules.


Another interesting item:

Suppose you define the function g[x] as the function you get from
doing:

D[F[x],x]

This should be the same as f[x] the original function.

Make a plot of g[x]/f[x] on say, [-3,3]. If g[x] and f[x] were the
same them
the plot:

Plot[g[x]/f[x], {x, -3, 3}]

should be the line y=1, except at zero of course. The plot is not the
line y=1, but you will see the line in it.

Make the plot:

Plot[g[x]/f[x], {x, 10, 20}, PlotRange -> {-2, 2}]

The line y=1 appears in this plot too. This would give credence to the
conclusion that Mathematica 8 did correctly do D[F[x],x] after all,
well correctly away from the origin. Perhaps, just perhaps, the first
derivative having a multiple zero at zero with a multiplicity of 13
has something to do with it, perhaps not.

Well, a most interesting problem. More could be said, I'm sure.

Gary Wardall
Retired Instructor
University of Wis.-Green Bay


  • Prev by Date: Re: Rational[a,b] vs Rational[1,2]
  • Next by Date: Re: how packages work
  • Previous by thread: Re: Mathematica Weirdness
  • Next by thread: Re: Mathematica Weirdness