Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*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 2004

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

Search the Archive

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:

I downloaded your Notebook entries, and have examples which may save
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
answer all your questions; nor will it answer all my own.  Perhaps a
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[1]:= 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[2]:= u = SetPrecision[ 0.5242, Infinity]

            1180393462333807
    Out[2]= ----------------
            2251799813685248

    In[3]:= l = SetPrecision[ 0.6214, Infinity]

            1399268404224013
    Out[3]= ----------------
            2251799813685248
			
Now, we calculate np (where "p" denotes "precise"), the value obtained
from using the precise fractional equivalents above.

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

    Out[4]= -(163 ... / ... 848) <-- Multiline whole-number fraction
abbreviated here.
	
Next, we let u and v be the fractions you specified.
 
    In[5]:= u = 5242/10000

            2621
    Out[5]= ----
            5000

    In[6]:= l = 6214/10000

            3107
    Out[6]= ----
            5000
			
Now, we calculate nf (where "f" denotes your original fractions).

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

    Out[7]= -(321 ... / ... 000) <-- Multiline whole-number fraction
abbreviated here.
	
Now that we have derived two "apples" answers, we can determine how
close they are.
 
    In[8]:= Abs[ np - nf] // N

                      -18
    Out[8]= 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.