\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsfonts,amsthm}
\usepackage{listings}
\usepackage{courier}
\usepackage{enumerate}
\usepackage{color}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{hyperref}
\hypersetup{colorlinks=true,urlcolor=MidnightBlue,citecolor=PineGreen,linkcolor=BrickRed}

\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\QQ}{\mathbb{Q}}

\lstset{
	basicstyle=\small\ttfamily,
	keywordstyle=\color{blue},
	language=python,
	xleftmargin=16pt,
}

% to include source code, uses the listings package as follows:
% \begin{lstlisting}
% Put your code here.
% \end{lstlisting}

\textwidth=6in
\textheight=9in
\topmargin=-0.5in
\headheight=0in
\headsep=.5in
\hoffset  -.4in
\pagestyle{empty}

% Feel free to add new macros here

\newcommand{\Q}{\mathbb{Q}}
\newcommand{\Z}{\mathbb{Z}}
\renewcommand{\char}{{\rm char}}

\begin{document}
\setlength{\unitlength}{1in}
\begin{center}
\large
\textbf{18.782 Introduction to Arithmetic Geometry\hspace{118pt}Fall~2020}\\\vspace{4pt}
\textbf{Problem Set \#1\hspace{237pt}Due: 09/11/2020}
\normalsize
\begin{picture}(6,.1) 
\put(0,0) {\line(1,0){6}}         
\end{picture}
\end{center}

\subsection*{Description}

These problems are related to the material covered in Lectures 1-2.
I have made every effort to proof-read these problems, but there are may be errors that I have missed.
The first person to spot each error will receive 1-5 points of extra credit on their problem set, depending on the severity of the error.
\medskip

\noindent
The problem set is due at 5pm Eastern time on 9/11/2020 and are to be submitted electronically as a pdf-file e-mailed to  \url{zzyzhang@mit.edu} and \url{roed@mit.edu}.
You can use the latex source for this problem set as a template for writing up your solutions;
be sure to include your name in your solutions (you can just replace the due date in the header with your name).
Don't forget to do the last problem, which is a survey whose results will help to shape future problem sets and lectures. 

\subsection*{Problem 1. Representing integers (10 points)}
Suppose that $k \in \ZZ$ and $x^2 + y^2 = k$ has a solution with $x, y \in  \QQ$.  Using the fact that $\ZZ[i]$ is a unique factorization domain, show that there is a solution to $x^2 + y^2 = k$ with $x, y \in \ZZ$.


\subsection*{Problem 2. Plane cubics that define elliptic curves (30 points)}
Show that over a field $k$ of characteristic not 2, 3 (and for part (b), not 7), each of the following irreducible cubic curves $C/k$ with a rational point $P$ defines an elliptic curve that can be put in the form $$y^2z=x^3+Axz^2+Bz^3$$ via a change of variables that takes the point $P$ to the point $(0:1:0)$.
\begin{enumerate}
\item[\textbf{(a)}] $C\colon X^3+Y^3+Z^3=0,\quad P=(1:-1:0)$.
\item[\textbf{(b)}] $C\colon X^3+Y^3+Z^3+XYZ=0,\quad P=(1:0:-1)$.
\end{enumerate}
\noindent
Be sure to verify that the curves are smooth (but you can take it is as given that they are irreducible and have genus 1).

\subsection*{Problem 3. Rational points on conics (60 points)}
In Lecture 2 we reduced the problem of finding a rational point on an irreducible conic over~$\Q$ to the problem of finding an integer solution
$(x_0,y_0,z_0)$ to the equation
\begin{equation}\label{eq:norm}
x^2-dy^2=nz^2,
\end{equation}
where $d$ and $n$ are positive square-free integers.  We solved \eqref{eq:norm} using Legendre's method of descent, which can be described as a recursive algorithm \textsc{Solve}$(d,n)$.
To facilitate the recursion, we let $d$ and $n$ also take negative square-free values.
\pagebreak

\noindent
\textsc{Solve}$(d,n)$
\begin{enumerate}
\item If $d,n<0$ then \textbf{\texttt{fail}}.
\item If $|d|>|n|$ then let $(x_0,y_0,z_0)=\textsc{Solve}(n,d)$ and return $(x_0,z_0,y_0)$.
\item If $d=1$ return $(1,1,0)$; if $n=1$ return $(1,0,1)$; if $d=-n$ return $(0,1,1)$.
\item If $d=n$ then let $(x_0,y_0,z_0)=\textsc{Solve}(-1,d)$ and return $(dz_0,x_0,y_0)$.
\item If $d$ is not a quadratic residue modulo $n$ then \textbf{\texttt{fail}}.
\item Let $w^2\equiv d\bmod n$, with $|w|\le|n|/2$, and set $x_0=w, y_0=1$ so that $x_0^2\equiv dy_0^2\bmod n$.
\item Let $t_1t_2^2=(x_0^2-dy_0^2)/n$ with $t_1$ square-free, let $(x_1,y_1,z_1)=\textsc{Solve}(d,t_1)$,\\ and return $(x_0x_1+dy_0y_1,x_0y_1+y_0x_1,t_1t_2z_1)$.
\end{enumerate}

\noindent
Your task is to implement \textsc{Solve} and use it to find rational points on a conic.

\begin{enumerate}
\item[\textbf{(a)}] Let $a$ and $b$ be the first two primes greater than your MIT ID, and let $-c$ be the least prime greater than $b$ for which $-bc$, $-ac$, and $-ab$ are squares modulo $a$, $b$, and $c$, respectively.
Use \textsc{Solve} to find an integer solution $(x_0,y_0,z_0)$ to
\begin{equation}\label{eq:diagonal}
ax^2+by^2 + cz^2 = 0.
\end{equation}
Have \textsc{Solve} print out the values $(d,n)$ just before step 1 so that you can see how the descent progresses.
Include a copy of this output, along with the values of $a$, $b$, and~$c$, as well as the final solution $(x_0,y_0,z_0)$ in your answer.
You do not need to include your code (but you are welcome to if you wish).
\end{enumerate}

\noindent
\textbf{Tip}:
In \texttt{sage} you can use \texttt{m=mod(d, n)} to obtain $d$ as an element $m$ of the ring $\Z/n\Z$, and then use \texttt{m.is\_square()} to check whether $m$ is a square.
If it is, you can then use \texttt{w=m.sqrt().lift()} to get a square-root of $m$ and lift it to an integer $w$ in the interval $[0,n-1]$ (you may then need to subtract $n$ from~$w$ in order to ensure that $|w|\le|n|/2$).
\bigskip

The solution returned by \textsc{Solve} is typically much larger than necessary.
As noted by Cremona and Rusin \cite{CR03}, the algorithm can be easily improved by modifying step 6 so that it chooses a solution $(x_0,y_0)$ to the congruence $x_0^2\equiv dy_0^2 \bmod n$  that minimizes $x_0^2+|d|y_0^2$.
This is achieved by finding a shortest integer vector $(u_0,v_0)$ that minimizes the $\Z^2$-norm
\[
\Vert(u,v)\Vert^2 = (wu+nv)^2+|d|u^2,
\]
where $w,d,$ and $n$ are as in step 6.
One can then use $x_0=u_0w+v_0n$ and $y_0=u_0$.
To find the vector $(u_0,v_0)$, apply the standard 2-dimensional lattice reduction algorithm to the basis $\mathcal{B}=\{(1,0),(0,1)\}$: iteratively shorten the longer of the two vectors in $\mathcal{B}$ (where length is measured by the norm $\Vert\cdot\Vert$), by adding or subtracting copies of the shorter vector until no further improvement is possible.

\begin{enumerate}
\item[\textbf{(b)}] Repeat part (a) using a modified version of \textsc{Solve} that minimizes $x_0^2+|d|y_0^2$ as above.
\item[\textbf{(c)}] Using your answer from (b), parameterize the solutions to \eqref{eq:diagonal} and find 2 more projectively inequivalent solutions that are also inequivalent under sign changes.
\end{enumerate}

\subsection*{Problem 4. Survey}
Complete the following survey by rating each of the previous problems on a scale of 1 to~10 according to how interesting you found the problem (1 = ``mind-numbing," 10 = ``mind-blowing"), and how difficult you found the problem (1 = ``trivial," 10 = ``brutal").  Also estimate the amount of time you spent on each problem.

\begin{center}
\begin{tabular}{l|r|r|r|}
& Interest & Difficulty & Time Spent\\\hline
Problem 1 & & & \\\hline
Problem 2 & & & \\\hline
Problem 3 & & & \\\hline
\end{tabular}
\end{center}

\noindent
Feel free to record any additional comments you have on the problem sets or classes; in particular, how you think they might be improved.

\begin{thebibliography}{9}
\bibitem{CR03}
J.E. Cremona and D. Rusin, \href{http://www.ams.org/journals/mcom/2003-72-243/S0025-5718-02-01480-1/home.html}{\emph{Efficient solution of rational conics}}, Mathematics of Computation \textbf{72} (2003), 1417--1441.
\end{thebibliography}

\end{document}