I am currently working on a document in Overleaf, and I am having trouble formatting my equations and mathematical expressions. Specifically, I want to enumerate the steps of the solution with text describing the steps along the way, but I am having trouble aligning equations and getting them to display properly.
I keep getting several error messages such as "Missing $ inserted," "Command \item invalid in math mode," "Something's wrong--perhaps a missing \item," and "Command \end{enumerate} invalid in math mode."
I believe these errors are related to my use of mathematical symbols and expressions in the document. I understand that I need to enclose all mathematical expressions and symbols with special markers to create 'math mode'. I have tried using $...$
for inline math mode, and \[...\]
or one of the mathematical environments (e.g. equation) for display math mode, but I still seem to be making some mistakes.
Can someone please help me with aligning my equations and getting them to display properly? Any advice or suggestions would be greatly appreciated. Thank you in advance!
It's partly in Swedish, I had to translate the text to English (for context):
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{geometry}
\title{Krysstal 2}
\author{D}
\date{April 2023}
\begin{document}
\section*{Uppgift}
3. Calculate the determinant of the matrix below. Note that the number of multiplications and additions needed to calculate the determinant depends on how it is expanded!
$$
\left[\begin{array}{lllll}
1 & 0 & 0 & 0 & 4 \\
0 & 7 & 0 & 5 & 0 \\
0 & 2 & 1 & 3 & 0 \\
0 & 6 & 0 & 8 & 0 \\
0 & 0 & 0 & 0 & 1
\end{array}\right] .
$$
\subsection*{Lösning}
To calculate the determinant of a $5 \times 5$ matrix, we use cofactor expansion. First, we choose the row or column with the most zeros, which in this case is the last row, to reduce the problem by one step. Then, we write the determinant as a sum of products of terms. Each term corresponds to an element in the selected row or column and its minor, obtained by deleting the row and column that correspond to the element, multiplied by $(-1)^{i+j}$ where $i$ and $j$ are the row and column indices of the element. Then we expand along the selected row using cofactor expansion, which reduces the problem by one more step. Finally, we use Sarrus's rule to calculate the determinant of a $3 \times 3$ matrix.
\begin{enumerate}
\item We are to calculate the determinant of a $5 \times 5$ matrix. To solve the problem, we will use cofactor expansion, choosing the row or column with the most zeros. In this case, it is the last row that has the most zeros (4). We have a $5 \times 5$ matrix that looks like this:
$$
\left[\begin{array}{lllll}
1 & 0 & 0 & 0 & 4 \\
0 & 7 & 0 & 5 & 0 \\
0 & 2 & 1 & 3 & 0 \\
0 & 6 & 0 & 8 & 0 \\
0 & 0 & 0 & 0 & 1
\end{array}\right] .
$$
\item Then we write out the determinant by taking a sum of products. We use the last row as our expansion row, since it has the most zeros. We get:
$$
\left|\begin{array}{ccccc}
1 & 0 & 0 & 0 & 4 \\
0 & 7 & 0 & 5 & 0 \\
0 & 2 & 1 & 3 & 0 \\
0 & 6 & 0 & 8 & 0 \\
0 & 0 & 0 & 0 & 1
\end{array}\right| = (0)(-1)^{5+1}\left| \begin{array}{cccc}
0 & 0 & 0 & 4 \\
7 & 0 & 5 & 0 \\
2 & 1 & 3 & 0 \\
6 & 0 & 8 & 0
\end{array}\right|
+ (0)(-1)^{5+2}\left| \begin{array}{cccc}
1 & 0 & 0 & 4 \\
0 & 0 & 5 & 0 \\
0 & 1 & 3 & 0 \\
0 & 0 & 8 & 0 \\
\end{array}\right| \\
+ (0)(-1)^{5+3}\left| \begin{array}{cccc}
1 & 0 & 0 & 4 \\
0 & 7 & 5 & 0 \\
0 & 2 & 3 & 0 \\
0 & 6 & 8 & 0
\end{array}\right| \\
$$
$$
+ (0)(-1)^{5+4} \left|\begin{array}{cccc}
1 & 0 & 0 & 0 \\
0 & 7 & 0 & 5 \\
0 & 2 & 1 & 3 \\
0 & 6 & 0 & 8
\end{array}\right|
+ (1)(-1)^{5+5} \left|\begin{array}{cccc}
1 & 0 & 0 & 0 \\
0 & 7 & 0 & 5 \\
0 & 2 & 1 & 3 \\
0 & 6 & 0 & 8
\end{array}\right| \\
= \left|\begin{array}{llll}
1 & 0 & 0 & 0 \\
0 & 7 & 0 & 5 \\
0 & 2 & 1 & 3 \\
0 & 6 & 0 & 8
\end{array}\right| $$\\
\text{Utvecklar längs rad 1:}\\$$
$$
$$
\left|\begin{array}{cccc}
1 & 0 & 0 & 0 \\
0 & 7 & 0 & 5 \\
0 & 2 & 1 & 3 \\
0 & 6 & 0 & 8
\end{array}\right|=(1)(-1)^{1+1}\left|\begin{array}{ccc}
7 & 0 & 5 \\
2 & 1 & 3 \\
6 & 0 & 8
\end{array}\right| + (0)(-1)^{1+2} \left|\begin{array}{ccc}
0 & 0 & 5 \\
0 & 1 & 3 \\
0 & 0 & 8
\end{array}\right|+(0)(-1)^{1+3}\left|\begin{array}{ccc}
0 & 7 & 5 \\
0 & 2 & 3 \\
0 & 6 & 0
\end{array}\right| \\ $$+ (0)(-1)^{1+4} \left|\begin{array}{lll}
0 & 7 & 0 \\
0 & 2 & 1 \\
0 & 6 & 0
\end{array}\right| = \left|\begin{array}{lll}
0 & 7 & 5 \\
0 & 2 & 3 \\
0 & 6 & 8\end{array}\right|
$$
\\
$$
\item \text{Using Sarrus' rule to calculate the determinant:} \\
$$\begin{vmatrix}7&0&5\\ 2&1&3\\ 6&0&8\end{vmatrix} \begin{matrix}7&0\\ 2&1\\ 6&0\end{matrix} =\left( 7\cdot 1\cdot 8\right) -\left( 6\cdot 1\cdot 5\right) =26$$
\end{enumerate}
\end{document}
And with \[…\]
delimiter (no significant changes that I could notice. Note, it's in Swedish):
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{geometry}
\title{Krysstal 2}
\author{D}
\date{April 2023}
\begin{document}
\section*{Uppgift}
3. Beräkna determinanten till matrisen nedan. Notera att antalet multiplikationer och additioner man behöver göra beror på hur man utvecklar determinanten!
\[
\left[\begin{array}{lllll}
1 & 0 & 0 & 0 & 4 \\
0 & 7 & 0 & 5 & 0 \\
0 & 2 & 1 & 3 & 0 \\
0 & 6 & 0 & 8 & 0 \\
0 & 0 & 0 & 0 & 1
\end{array}\right] .
\]
\subsection*{Lösning}
För att beräkna determinanten för en $5 \times 5$ matris används kofaktorutveckling. Först väljs raden eller kolumnen som har flest nollor, i detta fall den sista raden, för att reducera problemet ett steg. Sedan skrivs determinanten som en summa av produkter av termer. Varje term svarar mot ett element i den valda raden eller kolumnen och dess minor, som fås genom att stryka bort raden och kolumnen som korresponderar med elementet, multiplicerat med $(-1)^{i+j}$ där $i$ och $j$ är rad- respektive kolumnindex för elementet. Därefter utvecklar vi längs raden med hjälp av kofaktorutveckling, vilket reducerar problemet ytterligare ett steg. Slutligen används Sarrus regel för att beräkna determinanten av en $3 \times 3$ matris.
\begin{enumerate}
\item Vi ska beräkna determinanten för en $5 \times 5$ matris. För att lösa problemet kommer vi använda cofaktor expansion, där vi väljer den rad eller kolumn som har flest nollor. I detta fall är det sista raden som har flest nollor (4). Vi har en $5 \times 5$ matris som ser ut som följer:
\[
\left[\begin{array}{lllll}
1 & 0 & 0 & 0 & 4 \\
0 & 7 & 0 & 5 & 0 \\
0 & 2 & 1 & 3 & 0 \\
0 & 6 & 0 & 8 & 0 \\
0 & 0 & 0 & 0 & 1
\end{array}\right] .
\]
\item Sedan skriver vi ut determinanten genom att göra en summa av produkter. Vi använder den sista raden som vår utvecklingsrad, eftersom den har flest nollor. Vi får:
\[
\left|\begin{array}{ccccc}
1 & 0 & 0 & 0 & 4 \\
0 & 7 & 0 & 5 & 0 \\
0 & 2 & 1 & 3 & 0 \\
0 & 6 & 0 & 8 & 0 \\
0 & 0 & 0 & 0 & 1
\end{array}\right| = (0)(-1)^{5+1}\left| \begin{array}{cccc}
0 & 0 & 0 & 4 \\
7 & 0 & 5 & 0 \\
2 & 1 & 3 & 0 \\
6 & 0 & 8 & 0
\end{array}\right|
+ (0)(-1)^{5+2}\left| \begin{array}{cccc}
1 & 0 & 0 & 4 \\
0 & 0 & 5 & 0 \\
0 & 1 & 3 & 0 \\
0 & 0 & 8 & 0 \\
\end{array}\right| \\
+ (0)(-1)^{5+3}\left| \begin{array}{cccc}
1 & 0 & 0 & 4 \\
0 & 7 & 5 & 0 \\
0 & 2 & 3 & 0 \\
0 & 6 & 8 & 0
\end{array}\right| \\
\]
\[
+ (0)(-1)^{5+4} \left|\begin{array}{cccc}
1 & 0 & 0 & 0 \\
0 & 7 & 0 & 5 \\
0 & 2 & 1 & 3 \\
0 & 6 & 0 & 8
\end{array}\right|
+ (1)(-1)^{5+5} \left|\begin{array}{cccc}
1 & 0 & 0 & 0 \\
0 & 7 & 0 & 5 \\
0 & 2 & 1 & 3 \\
0 & 6 & 0 & 8
\end{array}\right| \\
= \left|\begin{array}{llll}
1 & 0 & 0 & 0 \\
0 & 7 & 0 & 5 \\
0 & 2 & 1 & 3 \\
0 & 6 & 0 & 8
\end{array}\right| \]\\
\text{Utvecklar längs rad 1:}\\
\[
\left|\begin{array}{cccc}
1 & 0 & 0 & 0 \\
0 & 7 & 0 & 5 \\
0 & 2 & 1 & 3 \\
0 & 6 & 0 & 8
\end{array}\right|=(1)(-1)^{1+1}\left|\begin{array}{ccc}
7 & 0 & 5 \\
2 & 1 & 3 \\
6 & 0 & 8
\end{array}\right| + (0)(-1)^{1+2} \left|\begin{array}{ccc}
0 & 0 & 5 \\
0 & 1 & 3 \\
0 & 0 & 8
\end{array}\right|+(0)(-1)^{1+3}\left|\begin{array}{ccc}
0 & 7 & 5 \\
0 & 2 & 3 \\
0 & 6 & 0
\end{array}\right| \\ \]+ (0)(-1)^{1+4} \left|\begin{array}{lll}
0 & 7 & 0 \\
0 & 2 & 1 \\
0 & 6 & 0
\end{array}\right| = \left|\begin{array}{lll}
0 & 7 & 5 \\
0 & 2 & 3 \\
0 & 6 & 8\end{array}\right|
\[
\\
\]
\item \text{Använder Sarrus regel för att räkna ut determinanten:} \\
\[\begin{vmatrix}7&0&5\\ 2&1&3\\ 6&0&8\end{vmatrix} \begin{matrix}7&0\\ 2&1\\ 6&0\end{matrix} =\left( 7\cdot 1\cdot 8\right) -\left( 6\cdot 1\cdot 5\right) =26\]
\end{enumerate}
\end{document}
\[...\]
instead of$$...$$
.