\documentclass[10pt, twoside, openany]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{kpfonts}
\usepackage{float}
\raggedbottom

% Control spacing of list environments
\usepackage{enumitem}

% Refer to sections by title
\usepackage{nameref}

% Where are our images?
\graphicspath{{images/}}

% Let's set this as a half-letter sized sheet
% https://tex.stackexchange.com/questions/338789/how-to-set-paper-size-to-half-letter-5-5-x-8-5-in-in-amsbook
\usepackage{geometry}
\geometry{
	paperheight=8.5in,
	paperwidth=5.5in,
%	heightrounded,
	margin=0.5in
}

% Add an \hrule with space above and below
\newcommand\krule[2]{\vspace{#1}\hrule\vspace{#2}}

% Adjust the top and bottom margins
% http://kb.mit.edu/confluence/pages/viewpage.action?pageId=3907057
\addtolength{\topmargin}{0.4in}
\addtolength{\textheight}{-0.75in}

% Set the header style
% https://www.overleaf.com/learn/latex/Headers_and_footers
\usepackage{fancyhdr}
\pagestyle{fancy}
 \fancyhf{}
 \fancyhead[RE]{Completing}
 \fancyhead[LO]{the Square}
 \cfoot{\thepage}
\renewcommand{\footrulewidth}{0.5pt}

% Remove the heading from the last page, if necessary
\fancypagestyle{lastpage}{ %
 \fancyhf{} % remove everything
 \cfoot{\thepage}
}

% We will probably want some two- or three-column sections
\usepackage{multicol}

\title{Completing the Square}
\author{Kenneth John Odle}
\date{17 July 2023}

\begin{document}

\maketitle

\begin{abstract}
The purpose of this document is to describe how to complete the square---a common method for factoring quadratic equations. It also described how the quadratic formula is derived from the standard form for quadratic equations by completing the square.

It also provides several worked equations to serve as examples.
\end{abstract}

\section{Quadratic Equations}

\textbf{Quadratic equations} are equations of the form $ax^2+bx+c=0$, or that can be written in that form. 

When we say ``of the form'' what we mean is that:

\begin{itemize}[noitemsep]
	\item The letters $a, ~b,$ and $c$ represent constants, and that both $b$ and $c$ can be zero. (The constants are the \textbf{coefficients} of the equation.)
	\item There is at least one term that contains the variable $x^2$.
\end{itemize} 

For example, the equation $3x^2+2x-5=0$ is a quadratic equation because it is written in the form $ax^2+bx+c=0$. 

However, the equation $5=2-3x^2$ is also a quadratic equation because it can be rewritten as $3x^2+3=0$. In this case, the value for $b$ is zero. (This could also be written as $3x^2+0x+3=0$.)

\paragraph{Perfect Square Quadratic Equations} The simplest quadratic equation to solve is the type where both sides are a perfect square. A \textbf{perfect square} is an integer whose square root is also an integer, such as 9 or 25, because $\sqrt{9}=3$ and $\sqrt{25}=5$. This description can also apply to a term whose coefficient is a perfect square, such as $16x^2$ and $9x^2$ because $\sqrt{16x^2}=4x$ and $\sqrt{9x^2}=3x$.

These are easy to solve because you can simply take the square root of both sides:

\begin{align}\label{eq1}
\begin{split}
4x^2 &= 36 \\
\sqrt{4x^2} &= \sqrt{36} \\
\sqrt{4}\times\sqrt{x^2} &= \sqrt{36} \\
2x &= \pm6 \\
x &= \pm\frac{6}{2} \\
x &= \pm3
\end{split}
\end{align}

\paragraph{Note:} Because we are taking the square root of a constant, we must include both the positive and negative values of the square root as the solution, hence $\pm3$. Substituting either $3$ or $-3$ into $x$ in the original equation results in a value of 36. (In story problems, the situation may mean that we can safely ignore one of these values.)

\paragraph{Factorable Quadratic Equations} The other type of quadratic equation is one that can easily be solved by factoring. For example,

\begin{align}\label{eq2}
\begin{split}
x^2-x-6 &= 0 \\
(x-3)(x+2) &= 0 
\end{split}
\end{align}

Because any number times zero is equal to zero, we can conclude that either $x-3$ or $x+2$ (or both) are equal to zero. In the first case:

\begin{align}\label{eq3}
\begin{split}
x-3 & =0 \\
x &= 3
\end{split}
\end{align}

and in the second case:

\begin{align}\label{eq4}
\begin{split}
x+2 &= 0 \\
x &= -2
\end{split}
\end{align}

Using either of these values for $x$ in equation \ref{eq2} will result in one of the factors being equal to zero, meaning both sides of the equation will be zero.

\section*{The Quadratic Formula}

For equations that are not easily factored, a general solution called ``the 	quadratic formula'' can be used to solve any quadratic.

For any equation of the form $ax^2+bx+c=0$, the solution (that is, the value for $x$) can be found by using:

\begin{equation}\label{eq5}
x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
\end{equation}

In reality, the quadratic formula is the result of solving the general form quadratic equation $ax^2+bx+c=0$ by completing the square. Using the quadratic formula is generally much easier (it can be programmed into some calculators and spreadsheets, for instance), but completing the square is used in certain calculus problems and for graphing some functions.

We will demonstrate how to obtain the quadratic formula in section ``\nameref{expqe}'' on page~\pageref{expqe}.

\section*{Completing the Square}

The general procedure for completing the square is to first make the left side of the equation into a perfect square (the right side will just be a number), and then solving it as we did in \ref{eq1}. This is not a difficult process, but most students tend to get stuck on the first step---making the left side into a perfect square. 

Here is the general procedure:

\begin{enumerate}
\item If the value for $a$ is \textit{not} 1, divide both sides of the equation by $a$. (We want the $x^2$ term to be by itself.) 
\item Move the constant term to the right side of the equation.
\item Divide $b$ by 2, square it, and add it to both sides of equation. 

\textbf{Note:} If dividing by 2 results in a fraction, leave it as a square \textit{on the left side}. That is, leave it as $(\frac{5}{2})^2$ rather than doing the math and arriving at $\frac{25}{4}$. This will make step four easier. (However, you will need to do the math on the right side.)
\item Write the left side as a perfect square.
\item Take the square root of both sides.
\item Solve for $x$.
\end{enumerate}

\paragraph{Note:} Our goal is to make the \textit{left} side of the equation into a square. However, the right side will often not be a perfect square, as in equation set~(\ref{eq1}) where the right side was $36$, which is simply $6^2$. In such cases, we will have a $\sqrt{~~}$ sign in our solution, which is perfectly acceptable.

\subsection*{Example \#1}\label{ex01}

For our first example, we'll use an equation in which $a$ is already 1, so we can skip the first step. Our equation is \[x^2+4x+1=0\]

The second step is to move the constant term to the right side of the equation by subtracting 1 from both sides: \[x^2+4x+1-1=0-1\] \[x^2+4x=-1\]

Our value for $b$ is 4. $4\div2 = 2$ and $2^2=4$, so we will add 4 to both sides of the equation (step three): \[x^2+4x+4=-1+4\] \[x^2+4x+4=3\]

The left side is now a perfect square, even though it doesn't look like it. Because $x^2+4x+4=(x+2)^2$ we can rewrite it as a perfect square (step four): \[(x+2)^2=3\]

All that is left to do is to take the square root of both sides (step five): \[\sqrt{(x+2)^2}=\pm\sqrt{3}\]

which gives us \[x+2=\pm\sqrt{3}\]

and then solve for $x$ (step six): \[x=\pm\sqrt{3} -2\]

Conventionally, we would write this as $x=-2+\sqrt{3}, -2-\sqrt{3}$.

\newpage

\noindent{}Here is the entire sequence all together:

\begin{equation}\label{eq6}
\begin{aligned}
x^2+4x+1 &= 0 && && &&\text{Original equation}\\
 & && && &&a=1\text{ so Step 1 is not needed} \\
x^2+4x &= -1 && && &&\text{Step 2}\\
x^2+4x+4 &= 3  && && &&\text{Step 3}\\
(x+2)^2 &= 3 && && && \text{Step 4}\\
\sqrt{(x+2)^2} &= \pm\sqrt{3} && && && \text{Step 5}\\
x+2 &= \pm\sqrt{3} && && && \text{Step 5}\\
x &= -2\pm\sqrt{3} && && &&\text{Step 6}
\end{aligned}
\end{equation}

\hrule

\subsection*{Example \#2}\label{ex02}

For our second example, we will look at an equation where $a$ is \textit{not} equal to 1. Our equation is: \[2x^2+5x-3=0\]

Step 1: The value for $a$ is 2, so we begin by dividing each term by 2: \[\frac{2}{2}x^2+\frac{5}{2}x-\frac{3}{2}=\frac{0}{2}\] \[x^2+\frac{5}{2}x-\frac{3}{2}=0\]

Step 2: We now need to move the constant term ($-\frac{3}{2}$) to the right side: \[x^2+\frac{5}{2}x-\frac{3}{2}+\frac{3}{2}=0+\frac{3}{2}\] \[x^2+\frac{5}{2}x=\frac{3}{2}\]

Step 3: Our value for $b$ is $\frac{5}{2}$ so we will divide that by 2, square it, and add it both sides of the equation: \[x^2+\frac{5}{2}x+\biggl(\frac{5}{4}\biggl)^2=\frac{3}{2}+\biggl(\frac{5}{4}\biggl)^2\]

We will leave it as a square term on the left, but let's do the math on the right side of the equation: 
\[x^2+\frac{5}{2}x+\biggl(\frac{5}{4}\biggl)^2=\frac{3}{2}+\frac{25}{16}\]
\[x^2+\frac{5}{2}x+\biggl(\frac{5}{4}\biggl)^2=\frac{3}{2}\biggl(\frac{8}{8}\biggl)+\frac{25}{16}\]
\[x^2+\frac{5}{2}x+\biggl(\frac{5}{4}\biggl)^2=\frac{24}{16}+\frac{25}{16}\]
\[x^2+\frac{5}{2}x+\biggl(\frac{5}{4}\biggl)^2=\frac{49}{16}\]

Step 4: We can now rewrite the left side as a perfect square:
\[\biggl(x+\frac{5}{4}\biggl)^2=\frac{49}{16}\]

Step 5: Take the square root of both sides, remembering that because the value on the right is a constant, we need to take into account both negative and positive values:
\[\sqrt{\biggl(x+\frac{5}{4}\biggl)^2}=\pm\sqrt{\frac{49}{16}}\]
\[x+\frac{5}{4}=\pm\frac{7}{4}\]

Step 6: All that is left is to solve for $x$:
\[x+\frac{5}{4}-\frac{5}{4}=-\frac{5}{4}\pm\frac{7}{4}\]
\[x=-\frac{5}{4}\pm\frac{7}{4}\]
\[x=\frac{-5\pm7}{4}\]
\[x=\frac{-5-7}{4}= ~\frac{-12}{4}, ~x=\frac{-2+4}{4}=\frac{2}{4}\]
\[x=-3, ~x=\frac{1}{2}\]



\subsection*{Example \#3}\label{ex03}

For our third example, we will look at an equation where the right side is not a perfect square.

\subsection*{Example \#4}\label{ex04}

For our fourth example, we will look at an equation where neither $a$ is equal to 1 nor the right side is a perfect square.

\section*{More Worked Examples}

\subsection*{Example \#5}\label{ex05}

\subsection*{Example \#6}\label{ex06}

\section*{An Explanation of the Quadratic Formula}\label{expqe}

Figuring out the quadratic formula by completing the square from the standard form (i.e., $ax^2+bx+c=0$) is not difficult once you are familiar with this problem solving technique. Most people get hung up doing the math on the coefficients. 

\begin{equation}\label{quadsolv}
\setlength{\jot}{10pt} % Add space between each equation
\begin{aligned}
ax^2+bx+c &= 0 && && &&\text{General Form}\\
x^2+\frac{b}{a}+\frac{c}{a} &= 0 && && &&\text{Step 1} \\
x^2+\frac{b}{a} &= -\frac{c}{a} && && &&\text{Step 2}\\
x^2+\frac{b}{a}+\left(\frac{b}{2a}\right)^2 &= -\frac{c}{a}+\left(\frac{b}{2a}\right)^2 && && &&\text{Step 3a}\\
x^2+\frac{b}{a}+\left(\frac{b}{2a}\right)^2  &= -\frac{c}{a}+\frac{b^2}{4a^2} && && && \text{Step 3b}\\
x^2+\frac{b}{a}+\left(\frac{b}{2a}\right)^2  &= -\biggl(\frac{c}{a}\biggl)\left(\frac{4a}{4a}\right)+\frac{b^2}{4a^2} && && && \text{Step 3c}\\
x^2+\frac{b}{a}+\left(\frac{b}{2a}\right)^2  &= -\frac{4ac}{4a^2}+\frac{b^2}{4a^2} && && && \text{Step 3d} \\
x^2+\frac{b}{a}+\left(\frac{b}{2a}\right)^2  &= \frac{b^2-4ac}{4a^2} && && && \text{Step 3e} \\
\left(x+\frac{b}{2a}\right)^2  &= \frac{b^2-4ac}{4a^2} && && && \text{Step 4} \\
\sqrt{\left(x+\frac{b}{2a}\right)^2}  &= \pm\sqrt{\frac{b^2-4ac}{4a^2}} && && && \text{Step 5a} \\
x+\frac{b}{2a}  &= \frac{\pm\sqrt{b^2-4ac}}{2a} && && && \text{Step 5b} \\
x+\frac{b}{2a}-\frac{b}{2a}  &= \frac{\pm\sqrt{b^2-4ac}}{2a}-\frac{b}{2a} && && && \text{Step 6a} \\
x &= \frac{-b\pm\sqrt{b^2-4ac}}{2a} && && && \text{Step 6b}
\end{aligned}
\end{equation}

Remember we said that most people get hung up doing the math on the coefficients? This is why we divided Step 3 into six substeps, and Steps 5 and 6 were both divided into two substeps. This suggests one trouble-shooting method if you are having difficulty solving a problem: work out each step on paper and do every single bit of arithmetic on paper, not in your head. Often, you'll find that you can complete the square without any problems, but have made a mistake in the arithmetic when working on the right side of the equation.

Also note that in Step 3, we basically left the left side of the equation alone after Step 3a. This suggests yet another trouble-shooting method if you can't work out a problem: only work one side of the equation at a time. Make sure you have that portion of the problem worked out correctly before attempting the rest of it.

%\pagestyle{lastpage}
% Remove the header from the last page; comment this out if the document ends on an odd-numbered page

\end{document}