# Quadratic Diophantine Equations - Solve by Completing the Square

We will tackle some Diophantine equations using the method of completing the square.

Consider the function \(f(x) = ax^{2} + bx +c\). We are interested in knowing what values of \(x\) make \(f(x)\) a perfect square. We know that \(f(x) = ax^{2} + bx +c\) can be written as \( a\left(x+\frac{b}{2a}\right)^{2} + \frac{4ac-b^{2}}{4a}\).

For more information on how to transform \(f(x)\) into this form, go here.

What values of \(x\) make \(f(x) = x^{2} + 6x + 8\) a perfect square?

Solution 1:Let \(f(x) = x^{2} + 6x + 8 = (x+3)^{2} - 1 = k^{2},\) where \(x\) is an integer and \(k\) is a non-negative integer. Observe that this can be rewritten as\[\begin{align} (x+3)^{2} - k^{2} &= 1 \\ (x+3+k)(x+3-k) &= 1. \qquad (1) \end{align}\]

Then since both \(x\) and \(k\) are integers, there are only the following two possibilities for the left side of \((1)\) to be \(1\) which is the right side:

\[\begin{align} x+3+k = 1, x+3-k &= 1 \\ \Rightarrow x &= -2, k = 0\\\\ x+3+k = -1, x+3-k &= -1 \\ \Rightarrow x &= -4, k = 0. \end{align}\]

That implies that the only integers \(x\) such that \(f(x)\) is a perfect square are \(x = -2\) and \(x = -4\). \(_\square\)

Solution 2:In this particular case, we see that: \((x+3)^{2} - k^{2} = 1\). The only squares that differ by \(1\) are \(1\) and \(0\). So we look for those values of \(x\) satisfying \((x + 3)^{2} = 1\), which gives \( x = -2, x = -4.\) \(_\square\)

**Cite as:**Quadratic Diophantine Equations - Solve by Completing the Square.

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/quadratic-diophantine-equations-solve-by/