[Tex/LaTex] Missing $ Error in aligned equations

align

I think here's the problematic code

The series expansion of $e^z$ is given by

\[ e^z = \displaystyle \sum^{\infty}_{n=0} \dfrac{z^n}{n!}\]

Then we can write the given function as

\begin*{align}
\frac{e^z - 1}{z^2} &= \frac{e^z}{z^2} - \frac{1}{z^2} \\
                &= \frac{1}{z^2} \left( 1 + z + \frac{z^2}{2!} + \frac{z^3}{3!} +    \cdots \right) + \frac{1}{z^2} \\
                &= \frac{z}{z^2} + \frac{1}{2} + \frac{z}{3!} + \frac{z^2}{4!} + \cdots \\
                &= \frac{1}{z} + \frac{1}{2} \frac{z}{3!} + \displaystyle  
                   \sum^{\infty}_{k=2} \frac{z^k}{(k+2)!}
\end*{align}

The error messages include "! extra } or missing $" and "! Misplaced alignment tab character &". It's 3 AM here, so I apologize if I’ve missed a missing $ or {} but I really don't see what the error is here. I have tried changing the formatting so that I delete all the white space but it doesn't seem to help either.

Thank you

Best Answer

I think your problem is the placement of the *

\begin{align*}
\frac{e^z - 1}{z^2} &= \frac{e^z}{z^2} - \frac{1}{z^2} \\
                &= \frac{1}{z^2} \left( 1 + z + \frac{z^2}{2!} + \frac{z^3}{3!} +    \cdots \right) + \frac{1}{z^2} \\
                &= \frac{z}{z^2} + \frac{1}{2} + \frac{z}{3!} + \frac{z^2}{4!} + \cdots \\
                &= \frac{1}{z} + \frac{1}{2} \frac{z}{3!} + \displaystyle  
                   \sum^{\infty}_{k=2} \frac{z^k}{(k+2)!}
\end{align*}

Placing the star within the curly brackets and at the end of the environment will stop numbering if that was your intent.

Additionally, for this line of code, you don't need \displayatyle of \dfrac since \[\] is displaymath, so

\[ e^z = \displaystyle \sum^{\infty}_{n=0} \dfrac{z^n}{n!}\]

can be

\[ e^z = \sum^{\infty}_{n=0} \frac{z^n}{n!} \]

with the same output.