Dear Madam/Sir,
I am trying to solve a system of nonlinear equations with fsolve.
For example, to solve f(x) = x.^3 - b*10 = 0, where b is a known vector, say 100 by 1.
I tried to solve the equation in vector form or in scalar form (with loops), the results are not always the same from the 2 approaches, depending on the starting values chosen. I am wondering why this is the case? Could you please give me some hints? Thanks a lot!
Problem: sz and sx are not always equal to each other, why?!
please see the codes below:
rand('state',2);
b = rand(100,1);
fun = @(x)(x.^3 + b*10);
options=optimset('Display','off');
start = -ones(100,1);
sx = fsolve(fun,start,options);
for i = 1:100
ifun = @(x)(x.^3 + 10*b(i));
sz(i,1) = fsolve(@(x)ifun(x), -2,options);
end