I've read a few posts here about center math equations and all of them make use of
\begin{align} *Math symbols* \end{align}
Now I've included the \usepackage{amsmath}
before the begin document line. But I keep getting this error:
Any ideas guys? I'm a latex noob
Here is some code:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\section{Situation 1}
\begin{align}
$J_{(j)} = \sum\limits_{i:r(i,j)=1} ((\theta\textsuperscript{(j)})\textsuperscript{T}x\textsuperscript{(i)} - Y_{i,j})^2 + \frac{\lambda}{2}\sum\limits_{k=1}^n(\theta_k\textsuperscript{(j)})^2$
\end{align}
\end{document}
Best Answer
TeX is great for math typesetting; so it's unlikely that a formula like that is so complicated to input:
There should never be
\textsuperscript
inside a formula.Using
\bigl
and\bigr
in the first formula makes the parentheses slightly bigger, which is good for reading in this case. Since they are almost necessary in the furst summation, I used them also in the second one, for symmetry.The
align
environment is for multiline displays; if you want the equation numbered, then useequation
instead ofequation*
.But in any case, the contents of
equation
,align
and similar environments is already assumed to be math, so adding$
will give errors.