MathGroup Archive 1998

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

Search the Archive

RE: Plot, Cursor and Spelling Errors questions

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

Ranko Bojanic wrote:
>
>I am having problems when trying to plot the graph of an error curve
>when the magnitude of the error curve is close to the $MachineEpsilon
>number. The following example is typical:
>
>n = 15;
>f[x_] := Exp[x];
>xLst = Table[Cos[((2*k - 1)*Pi)/(2*n)], {k, 1, n}]//Reverse; yLst =
>N[Map[f,xLst], 30];
>fLst = Transpose[{xLst, yLst}];
>p[x_] := InterpolatingPolynomial[fLst, x]; Plot[Evaluate[f[x]-P[x]], {x,
>-1, 1}, PlotPoints -> 50];
>
>Why the Plot function cannot draw the graph of the difference? I can
>still get a graph by computing 1000 points on the error curve and using
>ListPlot with PlotJoined->True, but the graph is not very smooth.
>
>The problem here is not in the accuracy of computations, as the ListPlot
>function shows, but in the way Plot processes data. 
>
>
That is true.  For efficiency Plot uses machine precision arithmetic.  In
the example you give you have to force the use of arbitrary precision
numbers and this isn't straight forward.

>
>Is there a way to force Plot to draw the error curve correctly?
>

I have sent Wolfram Research a suggestion indicating that Plot and
similar commands should have an option 'MachineArithmetic->True' (or
False).  Until they give use such an option the code below will solve
the problem.

In[1]:=
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]
    ]

In[2]:=
PrecisionPlot[Evaluate[f[x]-p[x]], {x,-1, 1}, PlotPoints -> 50];

(* Graphic not shown. *)


Actually I figured a way I can add such an Option to the Plot command in
version 3.0, but the necessary program is messy.

>
>An unrelated programming question:While  Mathematica is doing a lengthy
>computation, I would like to change the cursor into a watch cursor. I
>could not find any information on how to do it. Is there a simple
>command to change the current cursor into a watch cursor - something
>like SetCursor and InitCursor in Pascal.
>
>
I doubt this is possible if the feature is not built into the front end, and
I have not herd that it is.
>
>Last question: If you run the program listed here, you will probably get
>the messages :
>General::spell:Possible spelling error: new symbol "yLst" is similar
>to existing symbol {xLst} General::spell:Possible
>spelling error: new symbol "fLst" is similar
>to existing symbol {xLst,yLst}
>
>Is there a way to turn off these spelling errors messages?
>

There are two spelling messages.
They can be turned off using:

In[3]:=
Off[General::spell];
Off[General::spel1]; 

To turn them back on use:

On[3]:=
In[52]:=
On[General::spell];
On[General::spel1];


Cheers,
Ted Ersek


  • Prev by Date: Printing Problems under Windows98
  • Next by Date: RE: Plot, Cursor and Spelling Errors questions
  • Previous by thread: Plot, Cursor and Spelling Errors questions
  • Next by thread: RE: Plot, Cursor and Spelling Errors questions