RE: High precision numbers and Plot[] ?

• To: mathgroup at smc.vnet.net
• Subject: [mg13671] RE: [mg13661] High precision numbers and Plot[] ?
• From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
• Date: Sat, 15 Aug 1998 04:39:05 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Axel Kowald wrote:
_________________________

I try to plot a function where I have to use high precision numbers.
That means to get the correct answer I have to use N[f,50]. I set the
Compiled option of plot to false and tried:

Plot[N[f,50], {i, start, end}, Compiled -> False]

However, this doesn't work. The result is the same as:
Plot[f,{i,start,end}]

Any idea what I'm doing wrong ?

_________________________

Plot insists on using machine precision numbers even when you use
Compile->False.  The lines below will use SetPrecision to give the
desired result.

In[1]:=
f[x_]:=Log[1-Erf[x]]+x^2;
g[x_]:=f[SetPrecision[x,17]]

In[2]:=
Plot[g[x],{x,2,8}];

(*  graphics not shown  *)

Note:
Plot[Log[1-Erf[x]]+x^2, {x,2,8}]
doesn't work.

About a month ago I wrote a new plot command to use SetPrecision behind
the scenes.  See the code below.

In[3]:=
PrecisionPlot[lst_List,{x_,xmin_,xmax_},
opts___?OptionQ]:=Module[{plots1,disp},
disp=DisplayFunction/.{opts}/.Options[PrecisionPlot];
plots1=((PrecisionPlot[#,{x,xmin,xmax},
DisplayFunction->Identity,opts]&)/@lst);
Show[plots1, DisplayFunction->disp]
]

In[4]:=
PrecisionPlot[f_,{x_,xmin_,xmax_},
Module[{g,h},
g=Evaluate[f/.x->#]&;
h=g[SetPrecision[#,17]]&;
Plot[h[x],{x,xmin,xmax}, opts]
]

(*  I give PrecisionPlot the same default options as Plot.  *)

In[5]:=
Options[PrecisionPlot]={
AspectRatio -> GoldenRatio^(-1),
Axes -> Automatic,
AxesLabel -> None,
AxesOrigin -> Automatic,
AxesStyle -> Automatic,
Background -> Automatic,
ColorOutput -> Automatic,
Compiled -> True,
DefaultColor -> Automatic,
Epilog -> {},
Frame -> False,
FrameLabel -> None,
FrameStyle -> Automatic,
FrameTicks -> Automatic,
GridLines -> None,
ImageSize -> Automatic,
MaxBend -> 10.`,
PlotDivision -> 30.`,
PlotLabel -> None,
PlotPoints -> 25,
PlotRange -> Automatic,
PlotRegion -> Automatic,
PlotStyle -> Automatic,
Prolog -> {},
RotateLabel -> True,
Ticks -> Automatic,
DefaultFont :> \$DefaultFont,
DisplayFunction :> \$DisplayFunction, FormatType :> \$FormatType,
TextStyle :> \$TextStyle};

(*  Now both of the lines below produce a satisfactory graphics.  *)

In[6]:=
PrecisionPlot[Log[1-Erf[x]]+x^2,{x,2,8}];

(* graphic not shown *)

In[7]:=
PrecisionPlot[{Log[1-Erf[x]]+x^2,Sin[x]-2},{x,2,8}];

(* graphic not shown  *)

Ted Ersek

```

• Prev by Date: Label Display in 2-D Plots?
• Next by Date: Re: Request for help: working with multi-level lists
• Previous by thread: High precision numbers and Plot[] ?
• Next by thread: Re: High precision numbers and Plot[] ?