# Weird error in typing latex eqn

typing this:

$$\label{u_cart} \begin{array}{ll} u(x,y)_{N=5}= \begin{cases} \begin{array}{ll} \frac{(x+i y)^5 \text{BesselJ}\left[\text{{}1.5{''}} \sqrt{x^2+y^2},5\right]}{\left(x^2+y^2\right)^{5/2}} & 0<\sqrt{x^2+y^2}<\frac{1}{2} \\ \frac{(x+i y)^5 \left(\text{BesselJ}\left[3 \sqrt{x^2+y^2},5\right]+\text{BesselY}\left[3 \sqrt{x^2+y^2},5\right]\right)}{\left(x^2+y^2\right)^{5/2}} & \frac{1}{2}<\sqrt{x^2+y^2}<1 \\ \frac{(x+i y)^5 \text{HankelH1}\left[\sqrt{x^2+y^2},5\right]}{\left(x^2+y^2\right)^{5/2}} & \sqrt{x^2+y^2}>1 \endgroup \end{cases} \end{array} \end{array}$$


I get 37 weird errors, although it seems to show nicely. What is wrong?

Thanks!

• welcome to TeX.SE! You have mismatch in order of opening and closing environments. Also, all arrays are superfluous. Use only of cases is sufficient. Commented Apr 22, 2021 at 9:10
• After an error, "showing nicely" is a lucky outcome because TeX takes a guess at what you meant. Commented Apr 23, 2021 at 0:44

You did not need the arrays, because the first one operated on a single column, and the 2nd one was redundant to what cases provides (further, one of the arrays was mismatched with cases). You also had a stray \endgroup thrown in for no reason, which was excised. I also added extra vertical space with \\[8pt].

\documentclass{article}
\usepackage{amsmath}
\usepackage[margin=1in]{geometry}
\begin{document}
$$\label{u_cart} u(x,y)_{N=5}= \begin{cases} \frac{(x+i y)^5 \text{BesselJ}\left[\text{{}1.5{''}} \sqrt{x^2+y^2},5\right]}{\left(x^2+y^2\right)^{5/2}} & 0<\sqrt{x^2+y^2}<\frac{1}{2} \\[8pt] % \frac{(x+i y)^5 \left(\text{BesselJ}\left[3 \sqrt{x^2+y^2},5\right] +\text{BesselY}\left[3 \sqrt{x^2+y^2},5\right]\right)} {\left(x^2+y^2\right)^{5/2}} & \frac{1}{2}<\sqrt{x^2+y^2}<1 \\[8pt] % \frac{(x+i y)^5 \text{HankelH1}\left[\sqrt{x^2+y^2},5\right]}{\left(x^2+y^2\right)^{5/2}} & \sqrt{x^2+y^2}>1 \end{cases}$$
\end{document}


• Beautiful! Thank you for this! Commented Apr 22, 2021 at 9:14

Here's a variation on Steven Segletes's answer. First, use a dcases environment (provided by the mathtools package, which is a superset of the amsmath package) to show the fractions in display style. Second, get rid of the \left and \right directives, as their sizing operations are good for the material at hand. Third, define BesselJ, BesselY, and HankelH1 as math operators, to get the spacing right.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{mathtools} % for 'dcases' environment
\DeclareMathOperator{\BesselJ}{BesselJ}
\DeclareMathOperator{\BesselY}{BesselY}
\DeclareMathOperator{\HankelH}{HankelH1}
\begin{document}

$$\label{u_cart} u(x,y)^{}_{N=5}= \begin{dcases} \frac{(x+i y)^5 \BesselJ[\textnormal{1.5''} \sqrt{x^2+y^2},5]}{(x^2+y^2)^{5/2}} & 0<\sqrt{x^2+y^2}<\frac{1}{2} \\[8pt] % \frac{(x+i y)^5 \bigl(\BesselJ[3 \sqrt{x^2+y^2},5] +\BesselY[3 \sqrt{x^2+y^2},5]\bigr)} {(x^2+y^2)^{5/2}} & \frac{1}{2}<\sqrt{x^2+y^2}<1 \\[8pt] % \frac{(x+i y)^5 \HankelH[\sqrt{x^2+y^2},5]}{(x^2+y^2)^{5/2}} & \hphantom{\frac{1}{2}<{}}\sqrt{x^2+y^2}>1 \end{dcases}$$

\end{document}

• Many thanks, very nice. Commented Apr 22, 2021 at 9:36