# how can i solve a system with inexact coefficients

I try to solve this system:

e1 = H1[0, y] - H1[0, Y]
e2 = H2[0, y] - H2[0, Y]


with

H1[x_, y_] = 8 (-0.1 x - 1.2 y) + (4 x - 0.8 y)^2 + 4 y^2;
H2[x_, y_] = (
1 - 2 (1.5 - 0.5 x - 4.553076848028063*^-15 y)^2 +
4 (-1.0344827586206884 - x + y)^2)/(1.5 - 0.5 x -
4.553076848028063*^-15 y)^4;


I use Solve like this:

Solve[{e1, e2} == 0, {y, Y}]


but I found this message

Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>

• You need a semicolon between your lines. Aug 5 at 16:17
• To form the exact system use Rationalize. To force rationalization of all numeric values use Rationalize[#, 0]& Aug 5 at 16:46
• It says it solved the system and gave an answer....It gave me another warning, in effect that Y == y is solution in which y is a free variable. In short, it worked! :) -- That said, coefficients that vary in magnitude by a factor of 10^15 is asking for numerical trouble. That's an issue with how the problem is posed. Ratioinalize won't fix it, but it will show the uncertainty in a couple of the solutions, if you compare their numerical values. (I don't know how to fix it. How was H2 derived?) Aug 5 at 19:15
• This will let you compare solutions side-by-side: Sort /@ {{y, Y} /. Solve[{e1, e2} == 0, {y, Y}], {y, Y} /. Solve[Rationalize[{e1, e2}, 0] == 0, {y, Y}] // N} // Transpose // Grid Aug 5 at 19:18

There is an extremely small number $$a=4.553076848028063\times10^{-15}$$ involved, which I'd treat with a lot of caution. Rationalizing all numbers except $$a$$, we have

H1[x_, y_] = 8 (-1/10 x - 12/10 y) + (4 x - 8/10 y)^2 + 4 y^2;
H2[x_, y_] = (1 - 2 (3/2 - 1/2 x - a y)^2 + 4 (-30/29 - x + y)^2)/(3/2 - 1/2 x - a y)^4;


and then

sol = Solve[{H1[0, y] - H1[0, Y] == 0, H2[0, y] - H2[0, Y] == 0}, {y, Y}];


The first solution is $$y=Y$$,

sol[]
(*    {Y -> y}    *)


The remaining four solutions can be series-expanded for small $$a$$ to see their behavior:

Assuming[a > 0, Series[{y, Y} /. sol[], {a, 0, 1}]] // FullSimplify
(*    {(30/29 + Sqrt/4) - (9 Sqrt a)/29 + O[a]^2,
(30/29 - Sqrt/4) + (9 Sqrt a)/29 + O[a]^2}    *)


from which you can see that inserting an extremely small value of $$a$$ will give stable results $$y\approx\frac{30}{29}+\frac{\sqrt{5}}{4}$$ and $$Y\approx\frac{30}{29}-\frac{\sqrt{5}}{4}$$.

The third solution sol[] is the same with $$y$$ and $$Y$$ interchanged.

The fourth solution diverges as $$a\to0$$,

Assuming[a > 0, Series[{y, Y} /. sol[], {a, 0, 1}]] // FullSimplify
(*    (3 I)/(2 a) + (30/29 - (30 I)/29) + (3 I a)/4 + O[a]^2,
-((3 I)/(2 a)) + (30/29 + (30 I)/29) - (3 I a)/4 + O[a]^2}    *)


and the fifth as well (with $$y$$ and $$Y$$ interchanged).

• @MichaelE2 I don't think your three-argument form of Solve gives an actual solution of the equations: back-substituting the suggested {{Y -> 1/29 (60 - 29 y)}, {Y -> y}} into the equations gives no match. Aug 6 at 5:13
• That may be; but notice that the solutions for $a=0$ are not the same as the solutions for $\lim_{a\to0^+}$. This is one of those cases where perturbing the equations is not the same as perturbing the solutions. Aug 6 at 6:46