RE: Plot, Cursor and Spelling Errors questions

• To: mathgroup at smc.vnet.net
• Subject: [mg14453] RE: [mg14393] Plot, Cursor and Spelling Errors questions
• From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
• Date: Wed, 21 Oct 1998 03:32:50 -0400
• Sender: owner-wri-mathgroup at wolfram.com

``` Ranko Bojanic wrote:
>
>
>I still do not understand why and how your module works.
>
The program below is along the lines of:
Plot[f[SetPrecision[x,17]],{x,xmin,xmax},opts]
but this doesn't work.  I needed some assistance from Dave Withoff to come
up with the program below.

PrecisionPlot[f_,{x_,xmin_,xmax_},opts___?OptionQ]/;
Head[f]=!=List:=
Module[{g,h},
g=Evaluate[f/.x->#]&;
h=g[SetPrecision[#,17]]&;
Plot[h[x],{x,xmin,xmax}, opts]
]

>
>If you write a simpler module along these lines just to evaluate
>a function f at a point a with  p decimal digits, you may write
>
> eval[f_,a_,p_]:=   Module[{g,h,x},
>    g=Evaluate[f[x]/.x->#]&;
>    h=g[SetPrecision[#,p]]&;
>    Return[h[a]]]
>This gives
>In[1]    := eval[Exp,2.3, 30]
>Out [1]  = 9.9741824548147189681868930533
>
>It looks like we can evaluate Exp[2.3] with arbitrary
>precision. But
>
>In[2]    := N[Exp[23/10],30]
>Out[1]  = 9.9741824548147207399576151569
>
>gives a different result.
>
>
In the line below SetPrecision takes (2.3) and makes a number with lots of
precision, but the result isn't much closer to (23/10) than the floating
point (2.3) was.  All those extra digits are garbage.  If you want a number
within 10^-30 of (23/10) SetPrecision[23/10, 30] will do the job.

In[3]:=
a=SetPrecision[2.3, 30];
InputForm[a]
Out[3]//InputForm=
2.29999999999999982236431605997

In[4]:=
InputForm[23/10-a]
Out[4]//InputForm=
1.7763568394003*^-16

Exp[23/10] may be (probably is) an irrational number, right? When
Mathematica computes  N[Exp[23/10],30] it tries very hard to correctly
determine the first thirty digits of this number.

In the next line Mathematica computes Exp[a]. Here 'a' is a number with
thirty digits of precision and is about  1.8*10^-16 away from (23/10)

```

• Prev by Date: RE: Plot, Cursor and Spelling Errors questions
• Next by Date: Inserting/Removing Forced Page Breaks?
• Previous by thread: RE: Plot, Cursor and Spelling Errors questions
• Next by thread: Re: Plot, Cursor and Spelling Errors questions