A friend asked me if I have a certain algorithm to solve $x^2+y = 31$ and $y^2+x=41$ simultanously. We found the solutions but we didn't find a way to solve both equations.
Any ideas?
A friend asked me if I have a certain algorithm to solve $x^2+y = 31$ and $y^2+x=41$ simultanously. We found the solutions but we didn't find a way to solve both equations.
Any ideas?
As a concrete, graphical elaboration in Sage on @Srivatsan's comment (which already answers how to solve it) and @Américo Tavares's solution,
x,y = var('x,y')
eqns = [x^2+y==31, y^2+x==41]
S = solve(eqns, [x,y], solution_dict=True)
V = [(s[x].n(digits=5), s[y].n(digits=5)) for s in S]
G = Graphics(); G.set_aspect_ratio(1)
G += implicit_plot(x^2+y==31, (x,-10,10), (y,-10,10), color="blue")
G += implicit_plot(y^2+x==41, (x,-10,10), (y,-10,10), color="green")
G += point((p for p in V), color="red", pointsize=30)
G.show()
V
[(5.0000, 6.0000), (6.0753, -5.9097), (-4.9217, 6.7766), (-6.1536, -6.8668)]
S
[{y: 6, x: 5}, {y: -5.90970873786, x: 6.07533632287}, {y: 6.77655750799, x: -4.92173189009}, {y: -6.86684782609, x: -6.15360501567}]
f = x + (31-x^2)^2 - 41; f.factor() # or: latex(f.factor())
${\left(x - 5\right)} {\left(x^{3} + 5 \, x^{2} - 37 \, x - 184\right)}$
This cubic polynomial is irreducible over the rationals or integers, which has three real solutions:
plot(x^3 + 5*x^2 - 37*x - 184,(x,-10,10))
For what it's worth, looking at the exact solutions, we can see that two are "variations" on the third, where the first term of each is multiplied by (the two nontrivial) third roots of unity, $e^{\frac{2{\pi}ik}{3}} = -\frac{1}{2}\pm\frac{i\sqrt{3}}{2},\;(k=1,2)$:
f.roots()[0] # latex(f.roots()[0])
# gives the first root with its multiplicity
$\left(-\frac{1}{2} \, {\left(i \, \sqrt{3} + 1\right)} {\left(\frac{1}{18} i \, \sqrt{3} \sqrt{27445} + \frac{3053}{54}\right)}^{\left(\frac{1}{3}\right)} + \frac{68 i \, \sqrt{3} - 68}{9 \, {\left(\frac{1}{18} i \, \sqrt{3} \sqrt{27445} + \frac{3053}{54}\right)}^{\left(\frac{1}{3}\right)}} - \frac{5}{3}, 1\right)$
f.roots()[1] # latex(f.roots()[1])
$\left(-\frac{1}{2} \, {\left(-i \, \sqrt{3} + 1\right)} {\left(\frac{1}{18} i \, \sqrt{3} \sqrt{27445} + \frac{3053}{54}\right)}^{\left(\frac{1}{3}\right)} + \frac{-68 i \, \sqrt{3} - 68}{9 \, {\left(\frac{1}{18} i \, \sqrt{3} \sqrt{27445} + \frac{3053}{54}\right)}^{\left(\frac{1}{3}\right)}} - \frac{5}{3}, 1\right)$
f.roots()[2] # latex(f.roots()[2])
$\left({\left(\frac{1}{18} i \, \sqrt{3} \sqrt{27445} + \frac{3053}{54}\right)}^{\left(\frac{1}{3}\right)} + \frac{136}{9 \, {\left(\frac{1}{18} i \, \sqrt{3} \sqrt{27445} + \frac{3053}{54}\right)}^{\left(\frac{1}{3}\right)}} - \frac{5}{3}, 1\right) $
As Srivatsan commented we can eliminate one of the variables from the system
$$\left\{ \begin{array}{c} x^{2}+y=31 \\ y^{2}+x=41. \end{array} \right. $$
It is equivalent to
$$\left\{ \begin{array}{c} y=31-x^{2} \\ x^{4}-62x^{2}+x+920=0. \end{array} \right. $$
A rational solution of the quartic equation has to be a divisor of $ 920=2^{3}\times 5\times 23$. If we check $x=5$, we conclude that it is a root, which we call $x_{0}$. Now we can easily factor the quartic $$ x^{4}-62x^{2}+x+920=\left( x-5\right) \left( x^{3}+5x^{2}-37x-184\right) $$ remaining to solve the cubic equation $$ x^{3}+bx^{2}+cx+d=0 $$ with coefficients $b=5,c=-37,d=-184$. To get the correspondent depressed cubic equation $$ t^{3}+pt+q=0 $$ we need to make the change of variables $x=t-b/3$ thus finding the coefficients $p=-136/3$ and $q=-3053/27$. Now we can apply the Cardano's method. Since the discriminant $q^{2}+4p^{3}/27<0$ all roots are real. One of the roots is $$ \begin{eqnarray*} t_{1} &=&\left( -\frac{q}{2}+\frac{1}{2}\sqrt{q^{2}+\frac{4p^{3}}{27}} \right) ^{1/3} +\left( -\frac{q}{2}-\frac{1}{2}\sqrt{q^{2}+\frac{4p^{3}}{27}}\right) ^{1/3} \\ &\approx &7.742\qquad\text{(numerical evaluation in SWP)}, \end{eqnarray*}$$ which corresponds to $x_{1}=t_{1}-5/3\approx 6.075$. The radicals are chosen in such a way that their product is
$$\left( -\frac{q}{2}+\frac{1}{2}\sqrt{q^{2}+\frac{4p^{3}}{27}}\right) ^{1/3}\left( -\frac{q}{2}-\frac{1}{2}\sqrt{q^{2}+\frac{4p^{3}}{27}}\right) ^{1/3}=-\frac{p}{3}.$$
The remaining roots could also be found by factoring the cubic. Numerically we have got $t_{2}\approx -4.487,t_{3}\approx -3.255$ and $x_{2}\approx -6.154,x_{3}\approx -4.922$. The equation $y=31-x^{2}$ yields the values $y_{0}=6, y_{1}\approx -5.910$, $y_{2}\approx -6.867$, $y_{3}\approx 6.776$ (Note: rounding error of $0.001$ in comparison with bgins's evaluation).
Rearranging gives $y^2 - x^2 = 10 + y-x,$ so that $(y-x) (y+x-1) = 10.$ You don't say you are looking for integer solutions, but if you are, then you are left with finitely many possibilities for the pair $(y-x,y+x-1),$ which can be individually solved by Gaussian elimination: for example, one possibility is $y-x = 2, y+x-1 =5,$ leading to $y = 4, x = 2.$ But this pair does not satisy the original equations. However, another possibility is $y-x = 1$ and $y+x-1 = 10,$ which leads to $y=6$ and $x=5,$ which does satisfy the original system. The other cases can be handled similarly.
Another approach (Graphical approach) is to sketch the two graphs (must be drawn to scale) as found here http://www.wolframalpha.com/input/?i=Graph+x%5E2%2By%3D31+and+y%5E2%2Bx%3D41. Then determine the points of intersections of the two graphs which will give you the same set of solutions in the other approaches.
Another way, is the combination of Srivatsan's comment and Smanoos' answer:
$\begin{cases} y=31-x^2 \\ y^2+x=41 \end{cases}$
As a general algorithm for this kind of problem, you can compute a Gröbner basis of the ideal generated by your polynomials, using lexicographic ordering of monomials.
The result will be a "triangular system": first a polynomial in x, then a polynomial in xy... you can solve in x, then plug the values in the second polynomial and solve in y. (cf this paragraph in the WP article).
Solving Systems of Polynomial Equations (pdf) by Bernd Sturmfels gives an introduction to the topic. If you have access to the collective book Some Tapas of Computer Algebra (Springer), the two first chapters will give you a very complete and clear overview of the topic.