[Maxima] Cornu spiral

Edwin Woollett woollett at charter.net
Tue Dec 9 19:17:01 CST 2008

```On Dec. 8 Robert Dodier wrote:
------------------------------------
It turns out Maxima can compute the integrals symbolically.
Although %i appears in the result, the result evaluates to a
real number for real t. Maxima needs a little encouragement to
get a number instead of an expression containing %i.

One way:

assume (t > 0);
x (t) := ''(integrate (cos (s^2 * %pi/2), s, 0, t));
y (t) := ''(integrate (sin (s^2 * %pi/2), s, 0, t));
plot2d ([parametric, x, y, [t, 0, 4]], [nticks, 100], [plot_realpart,
true]);
-----------------------------------------------
Thank you for reminding me of this construct, which also works
with draw2d. However things fall apart if you go past about
t = 4.8, due to a current bug in the evaluation of erf(z).

(%i1) (display2d:false,assume(t>0))\$
(%i2) x (t) := ''(integrate (cos (s^2 * %pi/2), s, 0, t))\$
(%i3) y (t) := ''(integrate (sin (s^2 * %pi/2), s, 0, t))\$
(%i4) showtime:true\$

note that draw2d doesn't need any special switches to get
this plot

(%i6) draw2d( explicit(x(t),t,0,3) )\$
Evaluation took 3.0500 seconds (3.0500 elapsed)
(%i7) draw2d( explicit(y(t),t,0,3) )\$
Evaluation took 2.5800 seconds (2.5800 elapsed)

(%i8) draw2d( parametric(x(t),y(t),t,0,3),nticks=100)\$
Evaluation took 2.2200 seconds (2.2200 elapsed)

the draw2d parametric plot looks much cruder than your
plot2d( parametric(..) ) plot. Maybe someone knows how
to smooth this out.

Here we show the blow up by looking at the
real and imaginary parts of what should be
a real function (to within floating point errors).

(%i9) xfr(t) := realpart(float(x(t)))\$
Evaluation took 0.0000 seconds (0.0000 elapsed)

(%i10) map('xfr,[1,2,3,4,5,6,7]);

(%o10) [0.77989340037682,0.48825340607534,0.60572078930926,0.49842588395517,
0.92294250203326,5394606.134146459,1.1458348613507996E+16]

(%i11) xfi(t) := imagpart(float(x(t)))\$
(%i12) map('xfi,[1,2,3,4,5,6,7]);
(%o12) [-8.3266726846886741E-17,5.6898930012039273E-15,
-8.6821105860224179E-12,3.772560090431476E-7,0.53728316249859,

Ted Woollett

2.1605661208583072E+7,-3.4913409426819615E+15]

```