2

I'm not a mathematician be any mean, and I need to show a piece of pseudo code as an equation.

Here's the pseudo code:

if m >= t then
    s = m+d+r+s
else
    s = 5*m+d+r+s
end

How can I show this in standard mathematical terms? Preferably in latex.

Is something like this acceptable?

s = \left\{\begin{array}{lll}
              5*m+d+r+s & if & m<=t\\
              m+d+r+s & else
             \end{array}\right.

enter image description here

Lucien S.
  • 217

1 Answers1

3

Cases should be the environment you're looking for $$\begin{cases} a + b = c &\hbox{when } a > 0 \\ a + b = 2c & \hbox{when } a\leq 0 \end{cases}$$ begin{cases} a + b = c &\hbox{when } a > 0 \ a + b = 2c & \hbox{when } a\leq 0 \end{cases} with \ before the begin.

ajr
  • 1,627