A serious issue is that you use many numbers accurate to only 2 decimal digits. So even though you may think the answer is correct, it can easily be not a solutrion at all. dpb showed that to be a fact. As well, any time you have multiple trig functions in there, expect any solution to be non-unique.

Let me try your start points. I'll call x0 the value that you CLAIM to be a solution. x0 is the vector that you started fsolve at.

x0=[2.55707, 3.13087,0.68765,0,2.443221,2.557073];

>> xinit=[2.5570, 3.005,1,0,2.3685,2.0853];

>> [IK(xinit),IK(x0)]

ans =

0.86398 1

0.47215 -3e-06

-0.17497 -8.3398e-07

-0.40696 3e-06

0.85941 1

0.30952 5.518e-07

0.2965 8.3398e-07

-0.19621 -5.518e-07

0.93466 1

0.97211 0.81522

-0.77106 -0.66715

0.68671 1.0763

>> norm(IK(x0))

ans =

2.2952

>> norm(IK(xinit))

ans =

2.2385

As you can see, evaluating IK at each of those points gives very different results, yet the norm of the objective is quite close. That bodes very poorly for your claim that this is truly a valid solution.

What does fsolve give us?

[xf,fv,exitflag] = fsolve(@IK,x0)

Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm instead.

> In fsolve (line 310)

No solution found.

fsolve stopped because the last step was ineffective. However, the vector of function

values is not near zero, as measured by the value of the function tolerance.

<stopping criteria details>

xf =

4.1679 0.52101 -0.77606 0.49216 1.4093 4.2109

fv =

0.93396

0.12102

0.33626

-0.0022887

0.94293

-0.33299

-0.35737

0.31023

0.88093

5.0244e-06

-2.8169e-06

1.2031e-08

exitflag =

-2

In fact, fsolve is not terribly happy with the result. HOWEVER, it is considerably better than either your start point OR your claimed true "solution".

So fsolve did indeed improve the result. With 12 equations in 6 unknowns, expect there to be no true solution. Worse, when you use 2 digit numbers in such a complex problem, expect garbage out the end. The set in xf is indeed an improvement, by any measure we can apply.

[IK(xinit),IK(x0),IK(xf)]

ans =

0.86398 1 0.93396

0.47215 -3e-06 0.12102

-0.17497 -8.3398e-07 0.33626

-0.40696 3e-06 -0.0022887

0.85941 1 0.94293

0.30952 5.518e-07 -0.33299

0.2965 8.3398e-07 -0.35737

-0.19621 -5.518e-07 0.31023

0.93466 1 0.88093

0.97211 0.81522 5.0244e-06

-0.77106 -0.66715 -2.8169e-06

0.68671 1.0763 1.2031e-08

If you want a better solution, then I would start by using more accurate coefficients inside the objective. Then I would recognize that the solution will not be unique, and that with more equations than unknowns, the solution will generally not be exact either.

## Best Answer