Huh...

cos(pi/u^2/2), first expression of your problem, has not, indeed, an 
explicit solution that sage is able to find.

but, on your following attempts, you reach for the integral of 
cos(pi*x^2/2), a horse of a different color (which is the one racing in 
Wikipedia pages on "Euler spiral") :
sage: var("t")
t
sage: foo(x)=integrate(cos(pi*t^2/2),t,0,x)
sage: foo
x |--> -1/2*sqrt(1/2)*((I - 1)*(1/4)^(1/4)*pi*erf((1/2*I + 
1/2)*sqrt(2)*(1/4)^(1/4)

Since

sage: bool(foo(x).imag()==0)
True

and, by the way

sage: bar(x)=integrate(sin(pi*t^2/2),t,0,x)
sage: bool(bar(x).imag()==0)
True

all hopes are open.

But the problem is elsewhere :
sage: parametric_plot([foo(x),bar(x)],[x,-5,5],figsize=4)
[ tons of error messages ... ]
TypeError: unable to coerce to a real number

Hmm. conversion problem ?

def Foo(x): return foo(x).N()
sage: def Bar(x): return bar(x).N()
sage: parametric_plot([Foo(x),Bar(x)],[x,-5,5],figsize=4)
Same problem... only different :
TypeError: Cannot evaluate symbolic expression to a numeric value.

Aha !

parametric_plot([lambda x:foo(x).N(), lambda 
x:bar(x).N()],[x,-5,5],figsize=4)
Yet anopther problem :
TypeError: Unable to convert -0.498688874572196 - 4.99775951821661e-17*I to 
float; use abs() or real_part() as desired

Hmmm. This time, it's a precison problem. The *numerical* computation of 
the values is problematic : the imaginary part, which should be zero, is 
not numerically null erf evaluation is suspect...). Let's try :

 parametric_plot([lambda x:foo(x).N().real(), lambda 
x:bar(x).N().real()],[x,-5,5],figsize=4)

and .. lo ! No error message, and Sage displays the enclosed figure.

However, this analysis is *NOT* satisfying : trying :
sage: def Foo(x): return foo(x).N().real()
sage: def Bar(x): return bar(x).N().real()
sage: parametric_plot([Foo(x),Bar(x)],[x,-5,5],figsize=4)

does *NOT* work (yet another ton of error messages ending with " Cannot 
evaluate symbolic expression to a numeric value"). I do not understand why. 
Better minds than mine are required.

My guess is that, since is forced to use erf on imaginary values (a kind of 
casuus irreductibilis ?), there is no expression of the *real* value f this 
integral of a *real* function in terms of "elementary" that does not 
involve imaginary quantities... There might well be some expression of 
"special functions" that avoid this, but those "special functions" have 
usually been created to avoid this kind of problems. Even trig functions 
can be seen as "special functions" curtaining e^i*x, but their geometric 
interpretation predates largely (by about two millenia) their analytic 
expression ; this is why they are thought of as "elementary".

HTH,
--
Emmanuel Charpentier


Le mercredi 10 septembre 2014 00:17:14 UTC+2, Jotace a écrit :
>
> Hi all,
>
> I want (my students) to plot Cornu's spiral, givent in parametric form by 
>
> x(t) = integral cos(pi/u^2/2), u going from 0 to t , and y(t) defined 
> analogously using the sine function. The integral connot be evaluated 
> symbolically, I guess.
>
> The first attempt would be
>
> parametric_plot([integrate(cos(pi*u^2/2),u,0,t),integrate(sin(pi*u^2/2),u,0,t)],(t,-pi,pi))
> which failw (coercion)
>
> The second attempt would be:
>
> parametric_plot([integral_numerical(cos(pi*u^2/2),0,t),integral_numerical(sin(pi*u^2/2),0,t)],(t,-pi,pi))
> which also fails.
>
> I finally did:
> def x(t):
>     return integral_numerical(cos(pi*u^2/2),0,t)[0]
>
> def y(t):
>     return integral_numerical(sin(pi*u^2/2),0,t)[0]
>
> Points = [(x(t),y(t)) for t in sxrange(-pi,pi,2*pi/200)]
> line(Points).show(figsize=[5, 5],aspect_ratio=1)
>
> This works, but it looks highly inelegant. Also, i cannot expect my 
> students to come up with something like this in a first year undergrad 
> course.
>
> Is there a way to fix one of the first two options?
>
> Regards,
> JC
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to