[Scilab-users] find a zero of a system of nonlinear functions

Samuel Gougeon sgougeon at free.fr
Tue Nov 28 15:12:13 CET 2017


Le 28/11/2017 à 12:30, CRETE Denis a écrit :
> Hello,
> I am not convinced that in the quoted document the first argument is a range:
> the values returned by the function fsolve are generally not lying in the intended "range";
> if you try:
> fsolve([0.4,0.45,0.5],f)
>   ans  =
>     - 1.    6.    228.
> If I understand correctly, the first argument is considered as a vector, i.e. that the function f takes a vector as argument and returns a vector of the same dimension, with elements sin(2*%pi*xi).
You are all right, Denis.
But this feature could actually be used to parallelize computations of 
several roots, provided that the function is well vectorized. But it's 
not the case: there is a mistake:
Le 28/11/2017 à 11:58, Hermes a écrit :
> .../...
> function y=f(x)
>      y=exp(-x.^2)*cos(4*x);
> endfunction
.* cos() should be used instead of *cos()

Le 28/11/2017 à 11:12, Hermes a écrit :
> .../...
> function y = poly_cubic(x)
>   y = 3 - 10*x + 2*x^2 + 3*x^3;
> endfunction

This one is definitely not vectorized. .^should be used instead of ^.

HTH
Samuel




More information about the users mailing list