Why is the solution I obtained from Solve not verified in the original equation?
Solve
yields a generic result, while Reduce provides complete description of the solution space. With the MaxExtraConditions -> All
option in Solve
one can get in various cases as much as Reduce
can provide however this isn't always possible.
The fact that Solve
provides a generic result sometimes apears to be convenient as is the case here, however that generic solution need not always to be an actual solution.
More extensive discussion one can find in What is the difference between Reduce and Solve?
For an insight what kind of solution one might expect here we can sketch them with
ContourPlot[ (Sqrt[1 - y^2] Sin[x] - Sin[4 x]) x^2 + 2 x y == 0,
{x, -10, 10}, {y, -2, 2},
ContourStyle -> Thick, AspectRatio -> Automatic, ImageSize -> 600,
PlotPoints -> 90, MaxRecursion -> 3]
It is obvious thet there are solutions with -1 <= y <= 1
only. We can see that for certain real ranges of x
thare is no solution, for others on can find one or two solutions. As we mentioned above Reduce
is more powerful, nonetheless we can find solutions with Solve
as well:
Solve[ (Sqrt[1 - y^2] Sin[x] - Sin[4x]) x^2 + 2 x y == 0 && -5 < x < 5, y, Reals]
Let's demonstrate that the "generic sollution" need not be an actual solution.
sol = Solve[ (Sqrt[1 - y^2] Sin[x] - Sin[4 x]) x^2 + 2 x y == 0, y];
ex1 = (((Sqrt[1 - y^2] Sin[x] - Sin[4 x]) x^2 + 2 x y)/. sol[[1]] // Simplify);
Plot[ ex1, {x, -5, 5}, PlotStyle -> Thick, WorkingPrecision -> 30]
y
is a solution only when ex1
vanishes. Since it is hard demonstraiting with symbolic functionality we can reach satisfactory insight with plotting of the graph of ex1
. One can easily observe that ex1
is not a solution e.g. for 3.5 < x < 4
. Similar analysis for another "generic solution" ensures that we can get a specific solution only for appropriate ranges and simplifying the equation with a generic solution cannot yield zero in general. One can see how many different cases can be found with Reduce
e.g.
Reduce[ (Sqrt[1 - y^2] Sin[x] - Sin[4 x]) x^2 + 2 x y == 0 && -10 < x < 10, y, Reals]
This output is very large and one realizes why there the system suppresses the output when no reasonable restriction for x
is provided.
I cannot find an error in what you write but the issue lies with Solve
which does not quite "solve" equations. Mathematica indeed finds two solutions:
e[x_, y_] := x^2 (Sqrt[1 - y^2]*Sin[x] - Sin[4*x]) + 2 x y;
sol = Solve[e[x, y] == 0, y];
TableForm[%]
f[x_] := e[x, y] /. First[sol];
g[x_] := e[x, y] /. Last[sol];
Neither solution can be reduced to 0 by Simplify
or FullSimplify
. Plotting may help; each solution may be OK in part of the domain for $x$ but not everywhere as shown here:
Plot[{f[x], g[x]}, {x, 0, 10}, PlotRange -> All]
However the documentation for Solve
mentions that
Solve does not eliminate solutions that are neither generically correct nor generically incorrect
Have a look at @Artes ' comment for a link to a discussion.
I don't think you are doing anything wrong, but the result is interesting. When you plug in numbers, you get the equation satisfied only sometimes.
eq[x_, y_] = (Sqrt[1 - y^2]*Sin[x] - Sin[4*x])*x^2 + 2*x*y
let Mathematica solve it.
sol = Solve[eq[x, y] == 0, y] // Flatten // Simplify
and look at some values. A few x,y values for the first solution:
tab1 = Table[{x, y /. sol[[1]]}, {x, 0, 5, .2}] // N
plug the values into the original equation:
result1 = Table[{tab1[[i, 1]], eq[tab1[[i, 1]], tab1[[i, 2]]]}, {i, 1, Length[tab1]}];
Looking at the result the equation is satisfied to machine precision up to about $x=2.4$ and for higher values, only occasionally. If you look at the second solution the same way, the lower values are wrong, while the higher values are right about half the time.
So I understand why Mathematica does not verify the solutions, but I do not understand why we are getting these answers in the first place.
As a check, M12 and M8 produce the same results, except for minor simplification differences.