Cornu spiral



On Dec. 10, Edwin Woollett wrote:
---------------------
I have looked at the smoothing switches in draw2d
-----------------------------

I was wrong about the smoothing of draw2d's
parametric plot. The most important parameter is
nticks (draw2d default = 30) which "is the
number of points that will be shown in
parametric and polar curves" according to
the manual.

This becomes evident when you plot the whole
Cornu spiral. The Fresnel integrals S(t) and C(t)
are odd functions of t. Despite calculating these
quantities with the use of assume ( t > 0 ), the 
resulting expressions can then be used for both
negative and positive t (technically because considered
as functions of complex z, both S(z) and C(z) are
entire functions ). 

Instead of using Maxima functions, here I use
expressions. For reasons of plotting efficiency,
it makes sense to use integrate(...) once to get
a symbolic expression, and to simply use that
expression to get the plot, rather than ask draw2d
or gnuplot to call integrate(..) again for each new
point to be calculated numerically for the plot.

In addition, we use those symbolic expressions to
confirm the oddness property and find the limiting
points of the Cornu Spiral.

    assume ( t > 0 )$
    fC : integrate ( cos (%pi*s^2/2), s, 0, t )$
    fS : integrate ( sin (%pi*s^2/2), s, 0, t )$

    expand ( float ( subst (t = 1.0, fC ) ) );    --->
            0.77989340037682 - 8.3266726846886741E-17*%i

    expand ( float ( subst (t = -1.0, fC ) ) );   --->
            8.3266726846886741E-17*%i  -  0.77989340037682

     limit ( fC, t, inf );  --->  1/2
     limit ( fS, t, inf );  --->  1/2
     limit ( fC, t, minf );  --->  -1/2
     limit ( fS, t, minf );  --->  -1/2

    ( load (draw), load (qdraw) )$

We now compare the use of qdraw, draw2d (directly), and
plot2d to draw the complete spiral (well, out to
t = +/- 3, at least) .

At the risk of seeming immodest, this is an opportunity
to emphasize that the primary utility of the qdraw.mac
interface to draw2d is the presence in qdraw of the
kinds of defaults most science and engineering
students and researchers expect to have (eg.,
x and y axes, etc ). 

You will get roughly the same plot with the following
three methods:

   qdraw ( xr ( -4/3, 4/3 ), yr ( -1, 1 ),
            para ( fC, fS, t, -3, 3, lc ( blue) ), nticks ( 200) )$

   plot2d ( [ parametric, fC, fS, [ t, -3, 3 ] ],
                 [ style, [ lines, 3, 1] ],
                [ x, -4/3, 4/3 ], [ y, -1, 1 ], [ axes, true ],
               [ nticks, 200], [ plot_realpart, true ],
                [ xlabel, "fC(t)" ], [ ylabel, "fS(t)" ] )$

    draw2d ( xrange = [-4/3, 4/3], yrange = [-1, 1],
                  nticks = 200,   line_width = 2,
                  points_joined = true,
                  points ( [ [-4/3, 0], [4/3, 0 ] ] ),
                  points( [ [0, -1], [0, 1] ] ), 
                  line_width = 3,  color = blue,
       parametric ( fC, fS, t, -3, 3 ), grid = true )$

Despite the plot_options list indicating that the default
plot2d setting is [axes,true], using windows xp
with Maxima 5.17.0 I get no plot2d axes unless
I use that explicitly as an option.

The only reason I have included xlabel and ylabel in
the plot2d version is that without those labels, the
default behavior tries to write the whole complex 
erf(...) expression of fC and fS as labels!

By using nticks = 200 we get smooth curves without having
to do our own listplot list preparations.

For what it's worth,

Ted Woollett
http://www.csulb.edu/~woollett/