Hi,
I was trying to use fsolve to solve a system of equations, and couldn't get it to work. So I decided to try entering the example from the Octave documentation, Chapter 20 page 505. I figured once I got that to run I could work my way through to figure out what I was doing wrong. But I couldn't get fsolve to give the same result the documentation example said I should get!
I entered into the editor and saved as f.m the following:
function y=f(x)
y=zeros(2,1);
y(1)=-2*x(1)^2+3*x(1)*x(2)+4*sin(x(2))-6;
y(2)=3*x(1)^2-2*x(1)*x(2)^2+3*cos(x(1))+4;
endfunction
I then entered into the command window:
[x,fval,info]=fsolve(@f,[1;2])
According to the documentation I should get:
x =
0.57983
2.54621
fval =
-5.7184e-10
5.5460e-10
info = 1
Instead I got:
[x,fval,info]=fsolve(@f,[1;2])
y =
0
0
y =
0
0
y =
0
0
y =
0
0
y =
0
0
warning: matrix singular to machine precision
warning: called from
fsolve>__dogleg__ at line 587 column 5
fsolve at line 303 column 11
y =
0
0
x =
1
2
fval =
0
0
info = -3
>> f
y =
0
0
ans =
I don't know where to start resolving this, I could use some help.
Thanks in advance,
Steven