Re: Mathematica Graphics

• To: mathgroup at smc.vnet.net
• Subject: [mg8862] Re: [mg8846] Mathematica Graphics
• From: David Withoff <withoff>
• Date: Tue, 30 Sep 1997 20:16:25 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```> Could anyone tell me how to make Mathematica plot the following function
> smoothly?
>
> Wbar[q_,w_]:=w/(4 Sin[q/2]);
>
> Chi[q_,w_]:=
>   EllipticF[Pi/2 - ArcSin[Wbar[q,w]], 1/(1-Wbar[q,w]^2)]  /
> Sqrt[1-Wbar[q,w]^2];
>
> ChiPlot[q_,w_]:=
>   If[(w>2 Sin[q])&&(w < 4 Sin[q/2]), Chi[q,w]/(2 Pi Sin[q/2]),0];
>
> Plot[{ChiPlot[0.025,w]},{w,0.04999,0.050},PlotPoints->200,
>   PlotRange->{19.998,20.003}]
>
> If I run the last Plot command, Mathematica always complains about
> ChiPlot[w] not being a machine-size real number at some points, and then
> it only plots several disconnected lines. I realize the function is
> rather `dangerous' but analytically  I expect it  to behave normally
> inside the region that I use above, except perhaps at the
> boundaries. Anyway, if Mathematica can get the separate lines, why can't
> it obtain
> the values for points between the lines also?
>
>
> David Djajaputra

Try using high-precision, as in

Plot[{ChiPlot[1/40, SetPrecision[w, 100]]},{w,0.04999,0.050},PlotPoints->200,
PlotRange->{19.998,20.003}, Compiled -> False]

In this example, numerical error in machine arithmetic leads to a
non-zero imaginary parts in values for ChiPlot[0.025,w]:

In[5]:= ChiPlot[0.025, .049995]

-6
Out[5]= 20.0013 - 7.19537 10   I

Using the high-precision arithmetic provided by Mathematica, rather
than the machine arithmetic provided by the host computer, this
problem goes away.

Dave Withoff
Wolfram Research

```

• Prev by Date: Piecewise functions
• Next by Date: FW: make 1. x 10^-10 read simpl
• Previous by thread: Mathematica Graphics
• Next by thread: Mathematica 3.0.0 on WinNT 4: Bug in Show[]