Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
One way is to eliminate one of the variables (say, $y$) from the system, giving a quartic equation in $x$: namely, $$(31-x^2)^2 + x = 41 .$$ So solving the problem amounts to finding the roots of the quartic. [If you could guess one solution to the system, that of course helps in factoring the polynomial.] – Srivatsan Dec 29 '11 at 16:23
As is already known to Lagrange, or even Euler, a system of two quadratic homogeneous equations define an elliptic curve on the plane. But your equation is not homogeneous. Therefore I might ask why did your friend ask this question? Thanks. – awllower Dec 29 '11 at 17:52
Then per chance you could try to solve the equations? $x^2+2y^2=1$ and $2x^2+y^2=1$ simultaneously. It is of course interesting. – awllower Dec 29 '11 at 17:56
@awllower It's a very simple equation system, since you can just subtract them, and get that $x^2 = y^2$. From there I'm sure you can solve it yourself. It was never really a question about $x$ and $y$ actually, but about $x^2$ and $y^2$ – user3329719 Aug 27 '15 at 22:08

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)

implicit plot of x^2+y==31, y^2+x==41 in the square (-10,10)^2


[(5.0000, 6.0000), (6.0753, -5.9097), (-4.9217, 6.7766), (-6.1536, -6.8668)]


[{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))

cubic univariate polynomial plot

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) $

share|cite|improve this answer
+1 for using open source (plus I learned some new SAGE commands) – Fredrik Meyer Dec 29 '11 at 20:53

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).

share|cite|improve this answer

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.

share|cite|improve this answer
I want the whole real solutions. – tomerg Dec 29 '11 at 16:53
Then this method is not sufficient, although the fact that $x=5$ is a solution of the quartic in Srivatsan's comment should be helpful. – Geoff Robinson Dec 29 '11 at 17:03
Notice that Srivatsan's quartic factors as $(x-5)(x^3 + 5x^2 -37x -184),$ so the remaining possibilities for $x$ that need to be checked (apart from $x=5$ which has already been dealt with) are the roots of the cubic factor. – Geoff Robinson Dec 29 '11 at 19:43

Another approach (Graphical approach) is to sketch the two graphs (must be drawn to scale) as found here Then determine the points of intersections of the two graphs which will give you the same set of solutions in the other approaches.

share|cite|improve this answer

Another way, is the combination of Srivatsan's comment and Smanoos' answer:

$\begin{cases} y=31-x^2 \\ y^2+x=41 \end{cases}$

And for $(31-x^2)^2 + x = 41 $:

enter image description here

share|cite|improve this answer
Note, if you graph $(31-x^2)^2$ again $41-x$ and $41$, you'll see that the constant line and the $41-x$ line are dominated by the large swing in the $(31-x^2)$, so the solutions to $(31-x^2)^2=41$ give you a good "guide" of where to look for the solutions of $(31-x^2)^2=41-x$. The solutions to the simpler equation are $\pm\sqrt{31\pm \sqrt {41}}$ – Thomas Andrews Dec 29 '11 at 17:38

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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.