plotting problem with trigonometric functions



El mi?, 14-03-2012 a las 12:22 -0600, Robert Dodier escribi?:
> Looks like a Gnuplot bug to me.
> This is enough to trigger it:
> 
> $ cat /tmp/baz.data
> 
> -1. 1.
> 0.7068965517241379 0.99999999999999989
> 1. 1.
> 
> then in gunplot, issue: plot "/tmp/baz.data"
> 
> $ gnuplot --version
> gnuplot 4.4 patchlevel 2
> 
> I suppose Gnuplot is trying to find the range and getting
> mixed up somehow. Incidentally if all y-values are exactly the
> same it doesn't seem to have the same problem.
> 
> I guess somebody should forward this to the Gnuplot team
> but I'm too lazy.
> 
> best


When I plot this function with draw (and Gnuplot 4.4 patchlevel 3) I
get:

(%i1) load(draw)$
(%i2) draw2d(explicit(sec(x)*cos(x),x,-1,1))$
(%i3) line 27: warning: tick interval too small for machine precision

The problem is that the y-range is too narrow for this function and
Gnuplot complains.

If I type

(%i4) draw2d(explicit(sec(x)*cos(x),x,-1,1), yrange=[0.9, 1.1])$

I get a perfect horizontal line without any warning in only 0.176011
sec. 

A similar workaround for plot2d:

(%i16) plot2d(
     sec(x)*cos(x),[x,-1,1],
     [gnuplot_preamble, "set yrange [0.9:1.1]"]);


I think it wouldn't be too hard to fix this in package draw.

--
Mario