[Tex/LaTex] Error with using \frac in an equation

fractions

For some reason, when I try to run this code in LaTeX, it gives the error:
File ended while scanning use of \frac

I don't see my mistake. Also, my editor gives a warning considering the label: Reference 'eq6' on page 4 undefined. I assume it is, because I am using the reference before the label. But I want to name the formula in the text, before giving the formula.

\documentclass[11pt,a4paper, oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[free-standing-units]{siunitx}

\begin{equation} 
D_3 = -10 \log(\frac{P_2(2 f_{1,2} \pm f_{2,1}){P_2({f_1,f_2)})
\label{eq6}
\end{equation}

Best Answer

Solution

As Au101 already pointed out: There was a } missing and according to Ian Thompson a { too much. (Sorry Ian, for having missed your comment.)

Also, for this code to compile, you don't need any extra package in your MWE. Instead the \begin{document} ... \end{document} was missing.

To get nicer braces, you should use \left and \right before the (). Remember: you have to use \left and \right always in combination. You can't use the one without the other. The delimiters though don't have to match. You can combine \left( with \right\updownarrow, just to name an example. Hence, I also added those.

Example Code

\documentclass[11pt,a4paper, oneside]{article}

\begin{document}
\begin{equation} 
  D_3 = -10 \log \left(\frac{P_2(2 f_{1,2} \pm f_{2,1})}
     {P_2(f_1,f_2)}\right)
\label{eq6}
\end{equation}
\end{document}

Result

enter image description here

Related Question