Appreciate the pointers.

Plot statement in prior posting could also be

  parametric_plot((g,h),(-pi,pi))

which has a nicer default aspect ratio.

BTW there is sage code for Cornu spiral in the wikipedia article, Euler 
spiral <http://en.wikipedia.org/wiki/Euler_spiral>.



On Wednesday, September 10, 2014 4:56:05 AM UTC-5, Volker Braun wrote:
>
> The "s = var('s')" is not necessary (the argument s inside the functions 
> shadows it).
>
> As for the original question, IMHO there is a learning opportunity here. 
> Numerical integration is powerful, but it doesn't give you symbolic 
> answers. Even if you make the integration bound a symbolic variable. 
>
>  
>
> On Wednesday, September 10, 2014 6:09:06 AM UTC+1, Hal Snyder wrote:
>>
>> This works on my sage-6.1.1:
>>
>> s = var('s')
>>
>> def g(s):
>>     return numerical_integral(cos(pi*x^2/2), 0, s, max_points=100)[0]
>>
>> def h(s):
>>     return numerical_integral(sin(pi*x^2/2), 0, s, max_points=100)[0]
>>
>> p = plot((g,h),(-pi,pi),parametric=True)
>> show(p)
>>
>> On Tuesday, September 9, 2014 5:17:14 PM UTC-5, Jotace wrote:
>>>
>>> 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