Best way to use a compiled function in findroot



On 27/08/2010 20:21, Robert Dodier wrote:
> On Fri, Aug 27, 2010 at 12:11 PM, Sergio Callegari
> <sergio.callegari at gmail.com>  wrote:
>
>    
>> f(x):=(mode_declare(x,float),sin(x));
>> compile(x);
>>      
> I guess you mean compile(f) here.
>
>    
>> find_root('f(x),x,-1,1);
>>      
> For the record, find_root(f, x, -1, 1) (i.e. just name the function)
> also works here. Also find_root(lambda([x], f(x)), x, -1, 1) works.
>
>    
>> g(y):=block([x:gensym()],findroot('f(x)-y,x,-1,1));
>>      
> I guess you mean find_root instead of findroot here.
>
> best,
>
> Robert Dodier
>    

Yes, of course... sorry for all the mistakes in writing in the code... 
but you got the idea.

Any idea at the correct way to code 'g' ?

Thanks,

Sergio