# Typesetting a function defined by case analysis

Can any one suggess me the code to write this equation in LaTeX.

• Welcome to TeX.SE. Have you tried anything before asking for some help? If it's the case, you should shows us what you've done ;-) – Romain Picot Aug 19 '15 at 6:38
• @FarhanRaza If one of the below answers solved your problem, please accept one answer, so the question is marked solved. – sodd Aug 28 '15 at 11:37

You can make use of mathtools and its cases* environment.

The environments cases* and dcases* handles the second column as text, so you wont have to manually "escape" mathmode to typeset the text correctly. The dcases* variant use displaystyle math in the first column, which will make no difference in your situation. See section 3.4.3 in the package documentation for more details.

If you want to remove the equation number (1), you can use \begin{equation*} ... \end{equation*} instead of $$...$$.

\documentclass{article}
\usepackage{mathtools}

\begin{document}
$$L = \begin{cases*} (0 + 1)^{*} & if P = \mathit{NP} \\ \phi & otherwise \end{cases*}$$
\end{document}


• I would suggest to use equation* instead of replacing equation by . It is easier and much easier if you want to put numbers back. – Sigur Aug 19 '15 at 9:50
• There are quite a few differences between this output and the question image: 1) The left part was originally centered and not left-aligned and 2) the otherwise wasn't aligned with if P = NP. It would be informative to provide a way to match the example output more closely. – Bakuriu Aug 19 '15 at 11:58
• @Bakuriu The question is how to write the given equation in LaTeX, not how to achieve an identical output. Both equations are the same, which I consider to be the answer to the question. Also, the left part isn't centered; the last line is centered, with the space evenly distributed before, between and after the text. – sodd Aug 19 '15 at 12:30

For example:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$L = \begin{cases} (0 + 1)* & \text{if P = \mathit{NP}} \\ \emptyset & \text{otherwise} \end{cases}$
\end{document}