# Formula problem

And added my latex as follows:

 $$SSIM(x,y)=\frac{{\left ( 2 \mu_x\mu_y+ C_1 \right )+ \left (2 \sigma _x_y+C_2\right)}} {\left(\mu_x^2+\mu_y^2+C_1)(\sigma_x^2+\sigma_y^2+C_2\right)} \label{eq:SSMI}$$


I expected the following formula but instead of I got the error:!Double subscript. ...y+C_1\right)+ ...

• \sigma _x_y -> \sigma_{xy}. – CroCo Dec 9 '17 at 21:42
• in addition to the subscript error, you should remove the \left and \right which are not wanted here – David Carlisle Dec 9 '17 at 21:45

Double subscripts are not allowed by TeX, you should replace \sigma_x_y by \sigma_{xy}.

Also, it is preferable to use a specific operator name for such a function.

Edit: And as David Carlisle pointed out, the \left and \right commands are of no use here. It can only add unwanted additional spacing.

You can try something like this:

\documentclass[12pt]{article}
%
\usepackage{mathtools}
\DeclareMathOperator{\SSIM}{SSIM}
\begin{document}
$$\SSIM(x,y) = \frac{(2\mu_x\mu_y + C_1) + (2 \sigma _{xy} + C_2)} {(\mu_x^2 + \mu_y^2+C_1) (\sigma_x^2 + \sigma_y^2+C_2)} \label{eq:SSMI}$$
\end{document}


To achieve the desired output, simply replace \sigma _x_y by \sigma _{xy}.

• Please make your answer self-contained, see minimal working example (MWE). – Henri Menke Dec 9 '17 at 21:40
• I am thankfull to all. I try to rewrite with \DeclareMathOperator it didnt work :( What is the purpose of using it? For example after declared the formula may I call it just writing SSMI etc? – user8151324 Dec 9 '17 at 22:01
• Errors: Can be used only in preamble.... undefined control sequence declaremath and SSIM – user8151324 Dec 9 '17 at 22:09
• @user8151324 You have to load the amsmath package or its extension mathtools, as I did, to use the DeclareMathOperator command. It is a typographical convention that math operators should be typesetted in roman type, like the main text, hence this command. See the amsmath documentation for more information. – Franck Pastor Dec 9 '17 at 22:12
• I have all: \usepackage{float} \usepackage{amsmath} \usepackage{mathtools} \usepackage{caption} \usepackage{subcaption} \usepackage{placeins} \usepackage{epstopdf} \usepackage{multirow} – user8151324 Dec 9 '17 at 22:13