0

I want to make an addition of two square root functions, not one inside another. here is my code:

\begin{equation}
    L=\sqrt{\frac{1}{n} \sum_{i=1}^{n}\left\left\|y_{pred} -y_{true}\right\|_{2}}  +
    \sqrt{\frac{1}{n} \sum_{i=1}^{n}\left\left\|y_{pred1} -y_{pred2}\right\|_{2}}
\end{equation}

And the output is:enter image description here Can anyone tell me what's the right way to do this?

SebGlav
  • 19,186
kegemo
  • 3
  • 1
    Unrelated, might be am idea to use y_{\mathrm{pred}}. Additionally all the \left...\right in this example does nothing. – daleif Apr 19 '21 at 10:22
  • 1
    Off-topic: Should it be ^2 instead of _2 in all instances of \right\|_{2}? – Mico Apr 19 '21 at 10:35
  • @Mico it might be a 2 norm, like the \lVert_p norm? – daleif Apr 19 '21 at 10:37
  • 1
    Another unrelated, generally \| is a bad symbol to use for norm, use \lVert ... \rVert instead. Why? Try \| -1 \| and \lVert -1 \rVert. – daleif Apr 19 '21 at 10:38
  • 1
    Please, read terminal or log output. Three must be TeX error messages. If there is an error then the PDF output is irrelevant. Don't waste time with astonishment at PDF output if there is an error message. – wipet Apr 19 '21 at 13:57
  • 1
    @daleif - Given that L is defined as the square root of the average of a bunch of terms, these terms better be the squared norms rather than just the norms themselves. Actually, there's another fairly serious deficiency in the OP's notation: the summation is taken over a bunch of terms indexed by i, yet none of terms being summed has an i component. – Mico Apr 19 '21 at 15:22

1 Answers1

2

You put too much \left delimiters. sum of sqrts

\documentclass{article}
\begin{document}
   \begin{equation}
        L=\sqrt{\frac{1}{n} \sum_{i=1}^{n}\left\|y_{pred} -y_{true}\right\|_{2}}  + \sqrt{\frac{1}{n} \sum_{i=1}^{n}\left\|y_{pred1} -y_{pred2}\right\|_{2}}    
   \end{equation}
\end{document}
SebGlav
  • 19,186
  • 1
    Nice bro! Because I just know how to use norm yesterday, and I am confused with that. Thank you so much! – kegemo Apr 19 '21 at 13:02
  • 1
    Obviously, I didn't correct the mathematical visible errors, but you may follow the comments on your OP. – SebGlav Apr 19 '21 at 13:39