The basic piecewise function in Markdown / LaTeX is using ‘cases’ environment:

1
2
3
4
5
$$ Function = \begin{cases}
Formula1 & Condition1 \\
Formula2 & Condition2 \\
Formula3 & Condition3
\end{cases}$$

For example:

1
2
3
4
5
6
7
$$ 
(T_m,T_n) = \int_{-1}^{1}\frac{T_m(x)T_n(x)}{\sqrt {1-x^{2}}}dx = \begin{cases}
0 & if m ≠ n \\
\pi & if m = n =0 \\
\frac{\pi}{2} & if m = n ≠ 0
\end{cases}
$$

Plus: we can use multiple ‘cases’ environment to get multiple piecewise functions in one interline formula. For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$$ 
D_{ij} = \begin{cases}
\frac{1}{h_1} & i = j = 1 \\
\frac{1}{h_{i-1}} + \frac{1}{h_{i}} & i = j ≠ 1,N_E+1 \\
\frac{1}{h_{N_E}} & i = j = N_E+1 \\
-\frac{1}{h_i} & j = i + 1 \\
-\frac{1}{h_{i-1}} & j = i - 1 \\
0 & others
\end{cases} % The first piecewise function
\quad\quad
M_{ij} = \begin{cases}
\frac{h_1}{3} & i = j = 1 \\
\frac{h_{i-1}}{3} + \frac{h_{i}}{3} & i = j ≠ 1,N_E+1 \\
\frac{h_{N_E}}{3} & i = j = N_E+1 \\
\frac{h_i}{6} & j = i + 1 \\
\frac{h_{i-1}}{6} & j = i - 1 \\
0 & others
\end{cases} % The second piecewise function
$$