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

CRETE Denis denis.crete at thalesgroup.com
Tue Nov 28 12:30:36 CET 2017


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). 
In any case, it is quite strange to give 0.5 as initial value for this search of root, as at this particular point f=1 and its slope is zero !!! It explains why very strange values are returned for the roots.
HTH
Denis

-----Message d'origine-----
De : users [mailto:users-bounces at lists.scilab.org] De la part de Hermes
Envoyé : mardi 28 novembre 2017 11:59
À : users at lists.scilab.org
Objet : Re: [Scilab-users] find a zero of a system of nonlinear functions


I have tried to reproduce what can be read in this document, https://ljk.imag.fr/membres/Bernard.Ycart/mel/ds/ds.pdf
<https://ljk.imag.fr/membres/Bernard.Ycart/mel/ds/ds.pdf>  , on page 36.
 I find it interesting to introduce a range as an initial value.
I use  otras funciones y obtuve los resultados esperados.
function y=f(x)
    y=exp(-x.^2)*cos(4*x);
endfunction
function y = B(x)
 y = besselj(40,x+cos(x));
endfunction
I would have liked to replace this script with the fsolve function:

function root=brute_force_root_finder(F, a, b, n)
    x = linspace(a, b, n);
    n=size(x,"*")-1;
    y = feval(x,F);
    root = [];
    for i=1:n-1
        if y(i)*y(i+1) < 0 then
            root($+i) = x(i) - (x(i+1) - x(i))/(y(i+1) - y(i))*y(i);//root = x[i] - (x[i+1] - x[i])/(y[i+1] - y[i])*y[i]
        end
    end
endfunction
Gracias




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



More information about the users mailing list