       Re: Simple question or how Mathematica getting on my nerves.

• To: mathgroup at smc.vnet.net
• Subject: [mg45796] Re: Simple question or how Mathematica getting on my nerves.
• From: Harold.Noffke at wpafb.af.mil (Harold Noffke)
• Date: Sun, 25 Jan 2004 03:04:50 -0500 (EST)
• References: <butdvt\$9se\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```George:

you some hair.  You are getting a non-trivial difference between your
two integrals because you are "comparing apples to oranges".  The
example I use below illustrates this point.  However, it will not
good number theorist can comment on the example's mathematical
background.  So, here goes.

When worried about accuracy in Mathematica calculations, it is better
to keep every number in "whole number fractional notation" -- that is,
as the ratio of two whole numbers.  You went from "apples" to
"oranges" when you changed 5242/10000 and 6214/10000 to 0.5242 and
0.6214, respectively.  If you read "The Mathematica Book > A Practical
Introduction to Mathematica > 1.1.4 Arbitrary Precision Calculations",
you will find some examples which explain the difference between
apple-fractions and orange-decimals.  This is the source material I
used here.

First, we define your "k-function" in TextForm ...

In:= k[f_] := 2687176093959399272413585923303421161600 * (1 -
f)^67 * f^61

Then, after reading Mathematica Book Section 1.1.4, we determine the
accurate fractional equivalent of 0.5242 and 0.6214.

In:= u = SetPrecision[ 0.5242, Infinity]

1180393462333807
Out= ----------------
2251799813685248

In:= l = SetPrecision[ 0.6214, Infinity]

1399268404224013
Out= ----------------
2251799813685248

Now, we calculate np (where "p" denotes "precise"), the value obtained
from using the precise fractional equivalents above.

In:= np = Integrate[ k[f], {f, l, u}]

Out= -(163 ... / ... 848) <-- Multiline whole-number fraction
abbreviated here.

Next, we let u and v be the fractions you specified.

In:= u = 5242/10000

2621
Out= ----
5000

In:= l = 6214/10000

3107
Out= ----
5000

Now, we calculate nf (where "f" denotes your original fractions).

In:= nf = Integrate[ k[f], {f, l, u}]

Out= -(321 ... / ... 000) <-- Multiline whole-number fraction
abbreviated here.

Now that we have derived two "apples" answers, we can determine how
close they are.

In:= Abs[ np - nf] // N

-18
Out= 1.87048 10

So, np and nf differ by about 2 parts in 10^18, which is probably good
enough for government work.

:>)
Harold

```

• Prev by Date: Re: typesetting fractions
• Next by Date: Help browser
• Previous by thread: Re: Simple question or how Mathematica getting on my nerves.
• Next by thread: Re: Simple question or how Mathematica getting on my nerves.