# Non solutions returned by NSolve. And why does it return both phi and Cos[phi]?

Similarly to this thread NSolve gives additional solutions that don't satisfy the equations!

NSolve returns "spurious" solutions, even increasing the working precision

fsys={1 - Cos[(11 π)/45] - (3 Cos[ψ1])/4 - 2/3 Sin[φ + π/6] == 0, h + 2/3 Cos[φ + π/6] + Sin[(11 π)/45] - (3 Sin[ψ1])/4 == 0, -0.0436952 - (3 Cos[ψ2])/4 - 2/3 Sin[φ - π/6] == 0,2/5 + h + 2/3 Cos[φ - π/6] + Sin[(17 π)/180] - (3 Sin[ψ2])/4 == 0}

NSolve[N[fsys], {φ, h, ψ1, ψ2}, WorkingPrecision -> 100]


The second solution returned is

    {h -> -1.99515, ψ2 -> -1.22627, ψ1 -> 1.68803, φ -> 0.0618559,
Sin[ψ1] -> -0.993136, Cos[ψ1] -> -0.116967,
Sin[ψ2] -> -0.941237, Cos[ψ2] -> 0.337748, Sin[φ] -> 0.0618165,
Cos[φ] -> 0.998088}, {h -> -1.99515, ψ2 -> 1.22627,
ψ1 -> -1.68803, φ -> 0.0618559, Sin[ψ1] -> -0.993136,
Cos[ψ1] -> -0.116967, Sin[ψ2] -> -0.941237,
Cos[ψ2] -> 0.337748, Sin[φ] -> 0.0618165, Cos[φ] -> 0.998088}


,

I do not understand why both ψ1 and Cos[ψ1] are returned, with Sin[1.68803] actually not equal to 0.993136 (the sign is different)

• I don't get the Sin[...], Cos[...] bits (on version 9). – b.gates.you.know.what Dec 17 '12 at 6:29
• Good to know (I am using version 7). And do you get the wrong solutions (which do not satisfy the original equations) or no? – Fabio Dalla Libera Dec 17 '12 at 6:32
• Yes I do and I think it's fair as NSolve is not the right tool as stated in the documentation and the warnings. Why not using FindRoot ? – b.gates.you.know.what Dec 17 '12 at 6:34
• Sorry, on v.7 I do not get the warning either. The reason is that I want all the real roots, and not just one – Fabio Dalla Libera Dec 17 '12 at 6:38

I would use FindRoot rather than NSolve for your problem (this is on version 7):

sol = NSolve[N[fsys], {phi, h, psi1, psi2}, WorkingPrecision -> 100];
fsys /. sol
(* {{False, True, False, False}, {False, True, True, False},
{False, False, False, False}, {False, False, False, False},
{True, True, False, False}, {True, False, False, False}} *)


but

sol2 = FindRoot[fsys, {{phi, 0.5}, {h, 0.21}, {psi1, 0.3}, {psi2, 0.4}},
WorkingPrecision -> 100];

fsys /. sol2
(* {True, True, True, True} *)