On Apr 23, 2009, at 12:09 AM, Stan Schymanski wrote:

> Hi Jason,
>
> It think that find_root does use fast_float, but it compiles the
> fast_float function every time it is called. This makes it very  
> slow if
> I want to find the roots of f for all values of b between say -3  
> and -1.
> Therefore, I would like to be able to compile a fast_float function of
> e.g. 'b' and 'x', then pluck in different values for b and call
> find_root repeatedly to find the roots.
> The partial trick did it, but it would be great if this could be made
> more intuitively and part of fast_float, as you suggested.

Creating fast_float (or, now, fast_callable) objects should be much  
faster with the new symbolics.

> Since fast_float can be defined for an arbitrary number of  
> variables, I
> think that it should be possible to generate a fast_float  
> expression for
> any symbolic equation, and if this was a callable function or even
> worked with .subs() it would be a huge enhancement.

A partial function application would be a great thing to add to this  
class, though I'm not sure how much effort should be put into  
simplification (probably just change inputs to constants).

>
> Thanks again,
>
> Stan
>
> Jason Grout wrote:
>> Unfortunately, I don't that will ever work, as Python does not do
>> automatic currying (did I use the right term?).  The list  
>> comprehension
>> in python is a special case, where the function is not evaluated  
>> until
>> you have a value for x.  However, in the case of plot, the  
>> function ff
>> is evaluated first, and since x is missing, there is an error.
>>
>> However, in your case, it would probably make a lot more sense to  
>> do this:
>>
>> f = a*x^3+b*x^2+c*x+d
>> plot(f.subs(a=1,b=2,c=3,d=4), (x, 0, 6))
>>
>> This uses the fact that f is a symbolic expression, then the subs
>> command substitutes in variables and returns another expression.
>> fast_float is called by plot automatically.
>>
>> If find_root doesn't automatically use fast_float (it should!),  
>> then you
>> could do something like:
>>
>> f = a*x^3+b*x^2+c*x+d
>> find_root(fast_float(f.subs(a=1,b=2,c=3,d=4), 'x'), (x, 0, 6))
>>
>> (or whatever the syntax is).
>>
>> Again, this only works for Sage symbolic expressions...
>>
>> Sorry I didn't think of this earlier.  For general python  
>> functions, you
>> could use the partial trick we talked about.
>>
>> It might make sense to have some sort of partial evaluation available
>> for fast_float functions, so if a few arguments were given, it  
>> behaved
>> like the partial trick above.
>>
>> Thanks,
>>
>> Jason
>>
>>
>>
>>>
>>
>>
>
> -- 
> ________________________________________
>
> Stan Schymanski
> Scientist
> Max Planck Institute for Biogeochemistry
> Postfach 10 01 64
> D-07701 Jena
>
> Phone: +49.3641.576264
> Fax: +49.3641.577274
> WWW: http://www.bgc-jena.mpg.de/~sschym
>
> Biospheric Theory and Modelling Group
> http://www.bgc-jena.mpg.de/bgc-theory/
> _________________________________________
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to