[scilab-Users] How to find root of a function

Mathieu Dubois mathieu.dubois at limsi.fr
Thu Sep 11 11:19:15 CEST 2008


Hi Krzysztof,

Hum, I think that there are several problems in the definition your 
functions (maybe the errors are just cut-and-paste error but you should 
check your files).

In 'f', the variable 'r' is effectively unknown. In 'f', you use symbols 
'x', 'r', 's' and 'd'. 'x' is given as an argument.
Also, if 's' and 'd' are parameters you should use the 'global' keyword.

There are similar problems in 'g' ('r' is not defined).

It also seems that in f, you have unbalanced parenthesis (or you use a 
strange way of writing rational ;). In 'g', the constant for infinity is 
%inf...

I cannot help you more because I don't know precisely your problem. 
Maybe you could tell us more...

One way of clarifying the problem might be to pass values 's', 'd' and 
so on.. as function parameters (in  the definition) and use constant 
values when calling the function...

Mathieu

Krzysztof Dmytrów wrote:
> Hi
>
> Yes, I looked at the 'fsolve', but the problem is that my expression
> is not just a simple function. It is written as:
>
> function
>   y=f(x), y=(x-r)*1/(s*sqrt(0.1534)*sqrt(2*%pi))*exp(-(x-d)^2/(2*0.1534*49))
> endfunction
>
> Values of s, d are known. Now I create another function:
>
> function
>   z=g(x), z=B-intg(r,infinity,f)
> endfunction
>
> B is known.
>
> Now the problem is to find r such that z=0.
>
> I do not know if I can do that using the 'fsolve' function or maybe my
> syntax is wrong, but I receive a message that r2 is undefined
> variable.
>
> I would be grateful for any help
> Krzysiek
>   




More information about the users mailing list