\chapter{Elementary approach to Diophantine equations}


\section{Linear Diophantine equations}

\begin{definition}
A \emph{Diophantine equation} is an algebraic equation where solutions are restricted to integers.
\end{definition}
Typically, $x,y,z,w$ are reserved as variables for Diophantine equations, while other symbols represent constants; this book follows this convention.


Perhaps the most famous Diophantine equation is the following.
\[x^n+y^n=z^n, x,y,z\in \mathbb{Z} , n \in \mathbb{N}\]
\begin{theorem}[Fermat's last theorem]
\[\forall n \in \mathbb{N} \setminus \{0,1,2\} [ \nexists a,b,c \in \mathbb{Z} [ a^n + b^n = c^n ] ]\]
\end{theorem}

Though it was stated by Fermat at around 1637, the first proof was only published in 1995 by Andrew Wiles, making this an open problem for 358 years! It was though the machinery of algebraic geometry (specifically Iwasawa theory) that this conjecture was proven.

Methods from algebraic geometry prove extremely potent in the study of Diophantine equations due to the fact that these are algebraic equations that define geometric curves.

\subsection{Linear Diophantine equation}



\begin{definition}
A \emph{linear Diophantine equation} is a Diophantine equation of the following form.
\[ ax+by=c , a,b,c \in \mathbb{Z} \]
\end{definition}

\begin{proposition}
Solutions $(x,y)$ exist iff $c$ is a multiple of $\mathrm{gcd}(a,b)$ 
\end{proposition}

One may note that linear Diophantine equations are strikingly similar to the equation featured in Bezout's identity.

One can generate an ordered pair by applying the extended Euclidean algorithm, however using this ordered pair one can generate an infinite amount of answers. The trick relies on adding and subtracting the LCM of $a,b$ (the smallest integer that both $ax'$ and $bx'$ can create).
\begin{proposition}
Let the ordered pair $(x,y)$ solve $ax+by=c$, then there exists solutions $(x',y')$ defined as such is a solution for any $n \in \mathbb{Z}$.
\[ x' = x + \frac{b}{\gcd(a,b)}n \]
\[ y' = y - \frac{a}{\gcd (a,b)}n \]
Furthermore, this class represents all solutions to the linear Diophantine equation
\end{proposition}


\subsection{Geometric analysis}

\[y=\frac{a}{b}x+\frac{c}{b}\]


One may ask how many solutions have only positive integers? A geometric argument can admit a useful approximation; since solutions have constant length apart, we consider the positive length of the Diophantine line and the length between adjacent solutions.
\[n= \lfloor \frac{c}{ab} \rfloor\]


\section{Homogeneous Diophantine equations}


\[ x^2+y^2=a , a \in \mathbb{Z} \]
\[ \nexists a : x^2 + y^2 = a \iff a \equiv 3 \mod 4 \]
All even numbers squared reduce to 0 modulo 4 since $ (2n)^2 = 4n^2 \equiv 0 \mod 4 $  and odd numbers 1 modulo 4 since $ (2n-1)^2 = 4n^2 -4n +1 = 4(n^2 -n) +1 \equiv 1 \mod 4 $. Therefore $ x^2 + y^2 $ can never reduce to 3 modulo 4 since the possible combinations are $ 0+0=0,0+1=1,1+0=1,1+1=2$, excluding 3 from the possibilities. Therefore $ a \equiv 3 \mod 4$ shows a disparity between the capabilities of the sum of two squares and $a$, proving the unsatisfiability of this diophantine equation.
\begin{definition}[Pell's equation]
	\[ x^2 -ny^2 = 1 \]
\end{definition}



\subsection{Pythagorean triples}

We will now study integer solutions to $x^2+y^2=z^2$.

$x$ and $y$ have the opposite sign

\begin{theorem}[Euclid's formula]
\[x=m^2 + n^2 \]
\[y=2nm \]
\[z=m^2 - n^2 \]
\end{theorem}




\subsection{Sum of two squares}

Let's study integer solutions to $a^2+b^2=n$. Our knwoledge of modular arithmetic, paired with the Brahmagupta-Fibonacci identity will prove essential here. Some geometric reasoning will also be beneficial to us.

By our study on squares modulo 4, we can deduce the following.

\begin{theorem}
\[n \nequiv 3 \mod 4\]
\end{theorem}

This is a good start, but can we find a necessary and sufficient condition for $n$ to be expressible as the sum of 2 squares?


\begin{theorem}
For an odd number $n$ expressible in two distinct ways as sums of 2 squares, then $n$ is composite and its factors are sums of 2 squares.
\end{theorem}
This can be proved by equating the distinct sum of 2 squares, constructing coprime factors, and then applying the Brahmagupta-Fibonacci identity.


\begin{theorem}[Sum of two squares theorem]
$n$ is a sum of 2 squares iff for each prime power factor $p^k$, $p^k \nequiv 3 \mod 4$ when $k$ is odd.
\end{theorem}




