# close a square root function

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

$$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}}$$


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

• Unrelated, might be am idea to use y_{\mathrm{pred}}. Additionally all the \left...\right in this example does nothing. Apr 19, 2021 at 10:22
• Off-topic: Should it be ^2 instead of _2 in all instances of \right\|_{2}?
– Mico
Apr 19, 2021 at 10:35
• Another unrelated, generally \| is a bad symbol to use for norm, use \lVert ... \rVert instead. Why? Try \| -1 \| and \lVert -1 \rVert. Apr 19, 2021 at 10:38
• 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. Apr 19, 2021 at 13:57
• @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, 2021 at 15:22

You put too much \left delimiters.
\documentclass{article}
$$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}}$$