# Formula not being rendered

The following latex code :

J(\theta) = -1/m \left[ \sum\limits_{i=1}^m \sum\limits_{k=1}^K y_k ^(^i^) log (\:h\theta(x ^i))k  + (1 - y_k^(^i^)) \: log (1 - (h\theta(x ^i))k) \right]

+

\newline
\newline

\lambda / 2m \sum\limits_{l=1}^{L-1}  \sum\limits_{i=1}^{sl} \sum\limits_{j=1}^{sl+1} (\theta_{ji}^{(l)})^2


produces:

But on math stackexchange this formula is not rendered ? Should I escape some symbols?

Update :

$$J(\theta) = -1/m \left[ \sum\limits_{i=1}^m \sum\limits_{k=1}^K y_k^{(i)} log (\:h\theta(x ^i))k + (1 - y_k^{(i)}) \: log (1 - (h\theta(x ^i))k) \right] \\ + \\ \lambda / 2m \sum\limits_{l=1}^{L-1} \sum\limits_{i=1}^{sl} \sum\limits_{j=1}^{sl+1} (\theta_{ji}^{(l)})^2$$

• 1. No empty lines in math environment. 2. \newline should be replaced with \\ . 3. y_k ^(^i^) is invalid, did you mean y_k^{(i)}? – Daniel Fischer Nov 17 '15 at 14:30
• @Daniel Fischer thank you, that worked except I used \\ for new lines as your latex for new line did not render – blue-sky Nov 17 '15 at 14:40
• That was a markdown failure. I typed backtick-backslash-backslash-backtick and didn't notice that Markdown interpreted one of the backslashes as an escape for the closing backtick. – Daniel Fischer Nov 17 '15 at 14:42