# 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. – Zarko Apr 22 at 9:10
• After an error, "showing nicely" is a lucky outcome because TeX takes a guess at what you meant. – Teepeemm Apr 23 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! – Atelier Apr 22 at 9:14
• @Atelier You're welcome. If it fully answers your question and is the most suitable if multiple answers have been provided, feel free to click the check mark to the left of my answer. That will tell other readers that you found an answer that is "most useful" for answering your question. Once you get enough reputation (15 pt I think), you can click the up-arrow to the left of any question or answer (except your own), to indicate you found the question or answer "useful": – Steven B. Segletes Apr 22 at 9:18

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. – Atelier Apr 22 at 9:36