# MATLAB: Fsolve result is not desirable even giving a close starting point

fsolvenonlinear equations

I have three nonlinear equations with three unknowns and I used fsolve function.
I know that x=[0.3173;0.3173;3.6590] is a good enough solution for the three equations. However, using fsolve, I could not get to this solution even for a very close starting point as shown below. Instead the result is (upon plugging these results into the 3 equations, the values are not close to 0):
x =   0.999999999999936   1.000000000000067   1.000000000000036
How can this be solved? Thanks!
CODE:
x0=[0.31; 0.31; 3.5];options=optimset('Display','iter'); [x,fval]=fsolve(@myfun1,x0,options)function F=myfun(x)F=[13*cos(x(3)) - 5*x(1)*x(3)^2 - 5*x(2)*x(3)^2 + 13*x(1)*x(3)*sin(x(3)) + 13*x(2)*x(3)*sin(x(3)) + 10*x(1)*x(2)*x(3)^2 - 13*x(1)*x(2)*x(3)^2*cos(x(3)) + 40;     5*x(3) - 13*sin(x(3)) + 30*x(1)*x(3) + 13*x(1)*x(3)*cos(x(3)) + 13*x(2)*x(3)*cos(x(3)) - 5*x(1)*x(2)*x(3)^3 + 13*x(1)*x(2)*x(3)^2*sin(x(3));     390*x(3)^2*sin(x(3)) + 300*x(1)*x(3)^3 - 25*x(1)*x(3)^5 + 25*x(2)*x(3)^5 - 150*x(3)^3 - 260*x(1)*x(3)^3*cos(x(3)) - 130*x(2)*x(3)^3*cos(x(3)) + 130*x(1)*x(3)^4*sin(x(3)) - 130*x(2)*x(3)^4*sin(x(3)) - 169*x(1)*x(3)^3*cos(x(3))^2 + 169*x(2)*x(3)^3*cos(x(3))^2 - 169*x(1)*x(3)^3*sin(x(3))^2 + 169*x(2)*x(3)^3*sin(x(3))^2     ];

#### Best Answer

• Possibly because you're passing @myfun1 to fsolve instead of @myfun? When I make this change and run your code, I get the solution you expect.