Hi Jason,
That's awesome, thanks a lot! I had a bit of trouble understanding the
documentation of partial, but your example helped tremendously. This
should definitely be included in any upcoming documentation on
fast_float. As far as I understand, partial(F,1) just replaces the first
variable in F by 1. If I define something like F = fast_float(a*x^3 +
b*x^2 + c*x + d, 'a', 'b', 'c', 'd', 'x'), could I then use partial to
replace a, b, d and x and leave c as a variable, or would I have to
re-define F to take c as the last argument?
Cheers,
Stan
Jason Grout wrote:
> Stan Schymanski wrote:
>
>> Hi William,
>>
>> I just stumbled over this message and found that the following is even
>> faster:
>>
>> var('t')
>> W(t)=95*sqrt(t)*sin(t/6)^2
>> R(t)=275*sin(t/3)^2
>> F = (W-R)._fast_float_('t')
>> def A(t):
>> return 1200 + numerical_integral(F,0,t)[0]
>>
>> plot(A, (t,0,18))
>>
>> For reasons I have still not understood, fast_float works faster if the
>> variables are set in quotation marks. I still can't find anything about
>> fast_float in the Sage Reference Manual. For example, I would like to
>> know how something like this is handled:
>>
>> var('a t')
>> F = fast_float(a*t^2 + a*t + a, 'a', 't')
>>
>> How would I plot F or find its root for a fixed a? plot(F(1,t),(t,-1,1))
>> does not work, nor does find_root(F(1,t), -1, 1).
>>
>>
>
>
> I do this in http://sagenb.org/home/pub/69/ by using the standard python
> functools.partial:
>
> http://docs.python.org/library/functools.html
>
>
> Something like:
>
> from functools import partial
>
> plot(partial(F,1), (t, -1, 1))
>
> Jason
>
>
>
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---