[Tex/LaTex] Multiple Compilation errors: Missing $ inserted

compilingerrors

I'm a beginner when it comes to Latex so excuse my formatting if it is poor. Whenever I compile, I receive multiple Compilation errors:

Missing $ inserted ans Extra } or forgotten endgroup. 

I've poured over the code removing and replacing $ and } everywhere and I still get the same errors. However, it still compiles and turns into a correctly formatted PDF. Can anyone shed some light on this?

\documentclass[11pt]{article}

\usepackage{fullpage} 
\usepackage{amsmath}  
\usepackage{amssymb}  
\usepackage{amsthm}   
\usepackage{comment}  
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{lipsum}

\usepackage[colorlinks=true,citecolor=blue,linkcolor=blue]{hyperref} 

\usepackage{lipsum}

\makeatletter
\renewcommand{\maketitle}{\bgroup\setlength{\parindent}{0pt}
\begin{flushleft}
  \@title

  \@author
\end{flushleft}\egroup
}
\makeatother

\title{}
\date{}
\author{%
Name \\
Due \\
ID\\
}

\pagestyle{empty} % disables page numbers

\begin{document}

\maketitle

\centerline{\sc \large Homework 1 in \LaTeX\ }

\vspace{2pc}

\thispagestyle{empty}

\begin{flushleft}
\textbf{Exercise 1} 

\vspace{1pc}

\par \textit{A ball and a bat cost \$1.10 (total). The bat costs \$1.0 more than the ball. How much does the ball cost?}\par
    \setlength{\parindent}{10ex} 
    Let the price of the bat = $x$ \hfill $x$ + $y$ = 1.10

    Let the price of the ball = $y$ \hfill $x$ = $y$ + 1.0

                                    \hfill ($y$ + 1) + $y$ = 1.10

                                    \hfill 2$y$ = .10

                                    \hfill $y$ = .05

                                    \hfill $x$ + .05 = 1.10

                                    \hfill $x$ = \$1.05

    Therefore the ball cost \$0.05 and the the bat cost \$1.0 

\vspace{1pc}    

\noindent\textbf{Exercise 2} 

\vspace{1pc}

\noindent\textit{Prove the following statements:}\par
    \indent\textit{a)   The sum of any three consecutive even numbers is always a multiple of 6}\par

    \noindent Let $N1$ be the first even integer where $N2$ and $N3$ are consecutive even integers.\par
    $N1$ = $2q$ 

    $N2$ = $2q$ + 2 

    $N3$ = $2q$ + 4

    $S$ = $N1$+$N2$+$N3$

    By hypothesis $S$ = $2q+(2q+2)+(2q+4$) = $6q+6$

    $S$ = $N1$+$N2$+$N3$ = $6(q+1)$

    \indent\textit{b)   The product of any three consecutive even numbers is always a multiple of 8}\par

    \noindent Let $N1$ be the first even integer where $N2$ and $N3$ are consecutive even integers.\par
    $N1$ = $2q$ 

    $N2$ = $2q$ + 2 

    $N3$ = $2q$ + 4

    $S$ = $N1$\times$N2$\times$N3$
                    = $2q(4q^{2}+16q+8)$

                    = $8q^{3}+32q^{2}+16q$

                    = $8q(q^{2}+4q+2)$ 

\indent\textit{c)   Prove that if you add the squares of three consecutive integer numbers and then subtract two, you always get a multiple of 3.}\par

    \vspace{4pc}

    \noindent Let $N1$ be the first even integer where $N2$ and $N3$ are consecutive even integers.\par
    $N1$ = ($2q$)^{2} 

    $N2$ = ($2q + 2$)^{2} 

    $N3$ = ($2q + 4$)^{2} 

    $S = N1 + N2 + N3$

By hypothesis $S = ((2q)^{2} + (2q+2)^{2} + (2q+4)^{2})-2 

                    = (4q^{2}+(4q^{2}+8q+4)+(4q^{2}+16q+16))-2

                    = (12q^{2}+24q+20)-2

                    = 12q^{2}+24q+18

                    = 3(4q^{2}+8q+6)$

    \noindent If N1= 2, N2=4, N3=6

    $S$ = ((2)^{2}+(4)^{2}+(6)^2)-2 = (56)-2 = 54 = 3\times 18\par
    \noindent If N1 = 4, N2 = 6, N3 = 8

    $S$ = ((4)^{2}+(6)^{2}+(8)^2)-2 = (116)-2 = 114 = 3\times 38

\vspace{1pc}    

\noindent\textbf{Exercise 3} 

\vspace{1pc}

\noindent\textit{Based on the final number obtained, Roger can then “guess” the initial number. Show that there is no magic in this. Justify your answer.} \par
    \setlength{\parindent}{10ex} 
    Let $x$ be the random integer: \hfill $2x$

                                   \hfill $2x$ + 5

                                   \hfill (2$x$ + 5)^{2}

                                   \hfill (4$x$^{2}+20$x$+25)-25

                                   \hfill (4$x$^{2}+20$x$) \div 4

    Roger can simply asubtract 5 from the final number and\hfill ($x^{2}$+5$x$) \div x

    he will be able to guess the integer.  \hfill $x$ + 5

\vspace{1pc}    

\noindent\textbf{Exercise 4} 

\vspace{1pc}

\noindent\textit{Prove the following identities, where $p, q, x, m,$ and $n$ are real numbers:} \par
    \noindent\textit{a) $8(p-q)+3(p+q)=2(p+2q)+9(p-q)$}\par
    \noindent Let the LHS = $8(p-q)+3(p+q)$

    \setlength{\parindent}{13ex}  = $8p-8q+3p+3q = 11p - 5q$ 

    \noindent Let the RHS = $2(p+2q)+9(p-q)$

    \setlength{\parindent}{13ex}  = $2p+4q+9p-9q = 11p - 5q$ \hfill Therefore $LHS = RHS$ 

    \noindent\textit{b) $ x(m+n)+y(n-m)=m(x-y)+n(x+y)$}\par

    \noindent Let the LHS = $x(m+n)+y(n-m)$

    \setlength{\parindent}{13ex}  = $ xm + xn +yn -ym $ 

    \noindent Let the RHS = $m(x-y)+n(x+y)$

    \setlength{\parindent}{13ex}  = $xm - ym + xn + yn = xm +xn + yn - ym $ \hfill Therefore $LHS = RHS$ 

    \noindent\textit{c) $(x+2)(x+10)-(x-5)(x-4)=21x$}\par

    \noindent Let the LHS = $(x+2)(x+10) - (x-5)(x-4)$

    \setlength{\parindent}{13ex}  = $ (x^{2}+12x+20) - (x^{2}-9x+20)$ 

                                  = $21x $ 

    \noindent Let the RHS = $21x$ \hfill Therefore $LHS = RHS$ 

    \noindent\textit{d) $m^{4}-1=(m^{2+}1)(m^{2}-1)$}\par

    \noindent Let the LHS = $m^{4}-1$

    \noindent Let the RHS = $(m^{2}+1)(m^{2}-1)$ 
                          = $m^{4} -1 $\hfill Therefore $LHS = RHS$

\vspace{2pc}    

\noindent\textbf{Extra Credit} 

\vspace{1pc}

\par If the 1 minute person goes across with the two minute person that would be 2 min gone. The one minute person then goes back to the ten \& five minute persons while the two minute person is already on the other side, 3 minutes will have elapsed.Once back on the starting side, the one minute person gives the ten minute person and the five minute person the flashlight, they cross to the other side with 13 minutes goneby. If the ten \& five minute person give the two minute person the flashlight, the two minute person can go back across the bridge to retrieve the one minute person and this will cost another 2 minutes so 15 minutes will have elapsed. The two minute person then crosses to the other side with the one minute person, they will both take another 2 minutes and all will have crossed in 17 minutes.


\end{flushleft}     

\end{document}

Best Answer

I've compiled your document, and the main problem comes from the fact you seem to consider that in a maths formula, only the variables have to be enclosed between a pair of $$ … $. Example: (2$x$ + 5)^{2} instead of $(2x+5)^2$.

While some symbols can be understood in text mode, such as + (with a bad spacing), most of them are understood by the compiler only in math mode.

Furthermore, most of your formatting is done manually throughout the document, which is very bad practice: LaTeX is markup language, and all the formatting should be done through the preamble, packages and class files. You should read some document for beginners.

The exsheets package might be of interest to you.

Here is your code made compilable:

\documentclass[11pt]{article}

\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{comment}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{lipsum}

\usepackage[colorlinks=true,citecolor=blue,linkcolor=blue]{hyperref}

\usepackage{lipsum}

\makeatletter
\renewcommand{\maketitle}{\bgroup\setlength{\parindent}{0pt}
\begin{flushleft}
  \@title

  \@author
\end{flushleft}\egroup
}
\makeatother

\title{}
\date{}
\author{%
Name \\
Due \\
ID\\
}

\pagestyle{empty} % disables page numbers

\begin{document}

\maketitle

\centerline{\sc \large Homework 1 in \LaTeX\ }

\vspace{2pc}

\thispagestyle{empty}

\begin{flushleft}
\textbf{Exercise 1}

\vspace{1pc}

\par \textit{A ball and a bat cost \$\,1.10 (total). The bat costs \$\,1.0 more than the ball. How much does the ball cost?}\par
    \setlength{\parindent}{10ex}
    Let the price of the bat = $x$ \hfill $x$ + $y$ = 1.10

    Let the price of the ball = $y$ \hfill $x$ = $y$ + 1.0

                                    \hfill ($y$ + 1) + $y$ = 1.10

                                    \hfill 2$y$ = .10

                                    \hfill $y = .05$

                                    \hfill $x$ + .05 = 1.10

                                    \hfill $x$ = \$\,1.05

    Therefore the ball cost \$\,0.05 and the the bat cost \$\,1.0

\vspace{1pc}

\noindent\textbf{Exercise 2}

\vspace{1pc}

\noindent\textit{Prove the following statements:}\par
    \indent\textit{a) The sum of any three consecutive even numbers is always a multiple of 6}\par

 \noindent Let $N1$ be the first even integer where $N2$ and $N3$ are consecutive even integers.\par
 $N1$ = $2q$

 $N2$ = $2q$ + 2

 $N3$ = $2q$ + 4

 $S$ = $N1$+$N2$+$N3$

 By hypothesis $S$ = $2q+(2q+2)+(2q+4$) = $6q+6$

 $S$ = $N1$+$N2$+$N3$ = $6(q+1)$

 \indent\textit{b) The product of any three consecutive even numbers is always a multiple of 8}\par

 \noindent Let $N1$ be the first even integer where $N2$ and $N3$ are consecutive even integers.\par
 $N1$ = $2q$

 $N2$ = $2q$ + 2

 $N3$ = $2q$ + 4

 $S$ = $N1\times N2\times N3$
 = $2q(4q^{2}+16q+8)$

 = $8q^{3}+32q^{2}+16q$

 = $8q(q^{2}+4q+2)$

\indent\textit{c) Prove that if you add the squares of three consecutive integer numbers and then subtract two, you always get a multiple of 3.}\par

 \vspace{4pc}

 \noindent Let $N1$ be the first even integer where $N2$ and $N3$ are consecutive even integers.\par
 $N1 = (2q)^{2}$

 $N2 = (2q + 2)^{2}$

 $N3 = (2q + 4)^{2}$

 $S = N1 + N2 + N3$

By hypothesis $S = ((2q)^{2} + (2q+2)^{2} + (2q+4)^{2})-2 $
$ = (4q^{2}+(4q^{2}+8q+4)+(4q^{2}+16q+16))-2 $

$ = (12q^{2}+24q+20)-2 $

$ = 12q^{2}+24q+18 $

 $ = 3(4q^{2}+8q+6)$

 \noindent If $ N1= 2, N2=4, N3=6 $

 $S = ((2)^{2}+(4)^{2}+(6)^2)-2 = (56)-2 = 54 = 3\times 18$\par
 \noindent If $ N1 = 4, N2 = 6, N3 = 8 $

 $S = ((4)^{2}+(6)^{2}+(8)^2)-2 = (116)-2 = 114 = 3\times 38$

\vspace{1pc}

\noindent\textbf{Exercise 3}

\vspace{1pc}

\noindent\textit{Based on the final number obtained, Roger can then “guess” the initial number. Show that there is no magic in this. Justify your answer.} \par
 \setlength{\parindent}{10ex}
 Let $x$ be the random integer: \hfill $2x$

 \hfill $2x + 5$

 \hfill $ (2x + 5)^{2} $

 \hfill $(4x^{2}+20x+25)-25 $

 \hfill $ (4x^{2}+20x) \div 4 $

%% Roger can simply asubtract 5 from the final number and\hfill $ ( x^{2} +5x) \div x $
%%
%% he will be able to guess the integer. \hfill $x + 5$

\vspace{1pc}

\noindent\textbf{Exercise 4}

\vspace{1pc}

\noindent\textit{Prove the following identities, where $p, q, x, m,$ and $n$ are real numbers:} \par
 \noindent\textit{a) $8(p-q)+3(p+q)=2(p+2q)+9(p-q)$}\par
 \noindent Let the LHS = $8(p-q)+3(p+q)$

 \setlength{\parindent}{13ex} = $8p-8q+3p+3q = 11p - 5q$

 \noindent Let the RHS = $2(p+2q)+9(p-q)$

 \setlength{\parindent}{13ex} = $2p+4q+9p-9q = 11p - 5q$ \hfill Therefore $LHS = RHS$

 \noindent\textit{b) $ x(m+n)+y(n-m)=m(x-y)+n(x+y)$}\par

 \noindent Let the LHS = $x(m+n)+y(n-m)$

 \setlength{\parindent}{13ex} = $ xm + xn +yn -ym $

 \noindent Let the RHS = $m(x-y)+n(x+y)$

 \setlength{\parindent}{13ex} = $xm - ym + xn + yn = xm +xn + yn - ym $ \hfill Therefore $LHS = RHS$

 \noindent\textit{c) $(x+2)(x+10)-(x-5)(x-4)=21x$}\par

 \noindent Let the LHS = $(x+2)(x+10) - (x-5)(x-4)$

 \setlength{\parindent}{13ex} = $ (x^{2}+12x+20) - (x^{2}-9x+20)$

 = $21x $

 \noindent Let the RHS = $21x$ \hfill Therefore $LHS = RHS$

 \noindent\textit{d) $m^{4}-1=(m^{2+}1)(m^{2}-1)$}\par

 \noindent Let the LHS = $m^{4}-1$

 \noindent Let the RHS = $(m^{2}+1)(m^{2}-1)$
 = $m^{4} -1 $\hfill Therefore $LHS = RHS$

\vspace{2pc}

\noindent\textbf{Extra Credit}

\vspace{1pc}

\par If the 1 minute person goes across with the two minute person that would be 2 min gone. The one minute person then goes back to the ten \& five minute persons while the two minute person is already on the other side, 3 minutes will have elapsed.Once back on the starting side, the one minute person gives the ten minute person and the five minute person the flashlight, they cross to the other side with 13 minutes goneby. If the ten \& five minute person give the two minute person the flashlight, the two minute person can go back across the bridge to retrieve the one minute person and this will cost another 2 minutes so 15 minutes will have elapsed. The two minute person then crosses to the other side with the one minute person, they will both take another 2 minutes and all will have crossed in 17 minutes.

\end{flushleft}

\end{document} 

and the first page of the result:

enter image description here