MathGroup Archive 2012

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

Search the Archive

Re: For a variety of plotting experiences, maybe bugs?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124116] Re: [mg124074] For a variety of plotting experiences, maybe bugs?
  • From: Richard Fateman <fateman at eecs.berkeley.edu>
  • Date: Mon, 9 Jan 2012 03:20:58 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <je3vti$eeh$1@smc.vnet.net> <je6e5h$q7b$1@smc.vnet.net> <24475751.93762.1326015447306.JavaMail.root@m06> <006601ccce2f$c71c7ee0$55557ca0$@comcast.net>

David:
Thanks. Your suggestions would be useful if I were interested in exploring
the cosine function.  However, I was interested in exploring 
Cos[MachinePrecisionNumbers].
(actually, some other numerical functions. I just used cos to simplify 
the example).

  My interest was whether the numerical subroutine reflected the 
mathematical functions and
were appropriately monotonic in small ranges.  Looking "microscopically" 
one expects to see some kind of step function,
but if poorly implemented there may be some reversals-- i.e. local 
extrema-- that are not
mathematically justified, but are effects of the implemented algorithm, 
roundoff, etc.

I found that Mathematica refused to plot the most straightforward 
versions of these
investigations.


As far as why the powers of 2 instead of 10,  the fraction part of a 
machine float x has, as one
unit in the last place,  one part in  2^(52)  of x.    I find 2^-52 to 
be much nicer to look at than

2.220446049250313*^-16

as well as more accurate.




  On 1/8/2012 10:03 AM, David Park wrote:
> Small domains and small intervals are often treated masochistically. And why
> the powers of 2 instead of 10?
>
> This is the easy way to make the plots. Use a reasonable domain and range
> and enough WorkingPrecision.
>
> With[{n = 140},
>   Plot[(Cos[x 10^-n + 1] - Cos[1]) 10^n, {x, 0, 1},
>    WorkingPrecision ->  n + 3,
>    Frame ->  True,
>    FrameLabel ->  {(y - 1) 10.^n, 10.^n (Cos[y] - Cos[1])}]
>   ]
>
> Or use a series expansion:
>
> Series[10^n (Cos[1 + x 10^-n] - Cos[1]), {x, 0, 2}] // Normal
>
> -2^(-1 - n) 5^-n x^2 Cos[1] - x Sin[1]
>
> and then use MachinePrecision:
>
> With[{n = 145},
>   Plot[-2^(-1 - n) 5^-n x^2 Cos[1] - x Sin[1], {x, 0, 1},
>    WorkingPrecision ->  MachinePrecision,
>    Frame ->  True,
>    FrameLabel ->  {(y - 1) 10.^n, 10.^n (Cos[y] - Cos[1])}]
>   ]
>
> That is the way they do it in technical journals all the time.
>
>
> David Park
> djmpark at comcast.net
> http://home.comcast.net/~djmpark/index.html
>
>
>
>
>
>
> From: Richard Fateman [mailto:fateman at cs.berkeley.edu]
>
>
> try this (I did it on version 7...)
> Table[Plot[Cos[x], {x, 1 , 1 + 2.0^-i}], {i, 40, 45}]
>




  • Prev by Date: Re: Help! Mathematica 7 notebook is not working in Mathematica
  • Next by Date: Re: MatrixPower problem
  • Previous by thread: Re: how to get string in sci. notation to a number?
  • Next by thread: Re: For a variety of plotting experiences, maybe bugs?