Re: Increased Precision in Plot?
- To: mathgroup at smc.vnet.net
- Subject: [mg34704] Re: Increased Precision in Plot?
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sat, 1 Jun 2002 04:29:17 -0400 (EDT)
- References: <ad7ev7$f4r$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Selwyn,
There are two problems with Plot[f[x], {x,0,1}]
- machine numbers are supplied as values for x;
- even if we correct the above, the default compilation reverts to using
machine numbers.
This corrects both problems:
Plot[f[SetPrecision[x, 17]], {x, 0, 1}, Compiled ->False]
But 17 may not be a high enough precision for some calculations, so it is
better to use the idea that you used in
N[f[1/2, 17], which leaves Mathematic to increase the internal working
precision to try and give the result to the precision 17 ( if it can't do it
we will get a warning message).
Plot[N[f[SetPrecision[x, Infinity]], 17], {x, 0, 1}, Compiled -> False]
// Timing
(SetPrecision[., 17] give a ratioanal approximation)
Another way is to use ListPlot
ListPlot[Table[{x, N[f[x], 17]}, {x, 0, 1, 1/50}],
AxesOrigin -> {0, 0}, PlotJoined -> True]
--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
"Selwyn Hollis" <shollis at armstrong.edu> wrote in message
news:ad7ev7$f4r$1 at smc.vnet.net...
> The command
>
> f[t_]=Nest[1 - Integrate[2s(#/.t->s),{s, 0, t}]&, Cos[t],
> 12]//Simplify
>
> returns a fairly innocent-looking result. However, evaluation (or
> plotting) of the result with default precision produces garbage; for
> example:
>
> In[1]:= f[.5]
> Out[1]:= 0.875
>
> In[2]:= N[f[1/2]]
> Out[2]:= 0.625
>
> In[3]:= N[f[1/2],17]
> Out[3]:= 0.77880078307140487
>
> My question is this: How can I get Plot to graph such a function with
> increased precision, so that the graph isn't overwhelmed by noise?
>
> Thanks in advance,
>
> Selwyn Hollis
>