"Specifically, we're looking for the first solution with $t > 10^{12}$. This is a [Diophantine problem](https://en.wikipedia.org/wiki/Diophantine_equation). "
"Inspecting these parameterizations, the first two will always generate negative solutions for integer $t$, so we'll only consider the last two. We'll evaluate them at $t=0,1,2,\\ldots$ to find the first instance where the total number of discs is greater than $10^{12}$."
"This tells us that $b=756872327473, t=1070379110497$ is the arrangement we're after.\n",
"\n",
"## Alternate method\n",
"However, we don't need SageMath's `solve_diophantine` for this problem. In fact, we can solve it using the same techniques as [problem 45](https://projecteuler.net/problem=45).\n",
"\n",
"First, rearrange:\n",
"$$2b^2 - 2b - t^2 + t = 0$$\n",
"Then complete the square:\n",
"$$(2t-1)^2 - 2(2b-1)^2 = -1$$\n",
"Then substitute $X=2t-1$ and $Y=2b-1$ to get a Pell equation:\n",
"$$X^2 - 2Y^2 = -1$$\n",
"The problem gives $b=85, t=120$ as a solution to the original equation; this corresponds to $X=239, Y=169$ for our Pell equation. To generate more solutions, we'll need a fundamental solution to this Pell equation, which we can find with SageMath, or with continued fractions, as in [problem 66](https://projecteuler.net/problem=66)."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "0349d6a5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"sqrt2 + 1"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"K.<sqrt2> = QQ[sqrt(2)]\n",
"u, *_ = K.units()\n",
"u"
]
},
{
"cell_type": "markdown",
"id": "2e30da3f",
"metadata": {},
"source": [
"With both of these values in hand, we can easily generate more solutions to $X^2 - 2Y^2 = -1$ by computing $\\left(239+169\\sqrt{2}\\right)\\left(1+\\sqrt{2}\\right)^k$ for successive values of $k$. Then we'll check to see if they correspond to solutions to our original equation."
"This work is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International license](https://creativecommons.org/licenses/by-sa/4.0/) and the [BSD Zero Clause license](https://spdx.org/licenses/0BSD.html)."