This site is supported by donations to The OEIS Foundation.

Template:Cases

From OeisWiki
Jump to: navigation, search

The {{cases}} mathematical formatting template is used to typeset mathematical cases in either HTML+CSS or LaTeX. (In LaTeX, the cases environment is used for the definition of piecewise functions.)

Usage

{{cases|begin}} or {{cases|begin|format}} or {{cases|begin|left brace size}} or {{cases|begin|left brace size|format}}
...
{{cases|end}} or {{cases|end|format}}

where

  • first argument: begin or end;
  • [optional] second argument (left brace size) (ignored by LaTeX, size automatically adjusted): big, Big, bigg or Bigg (default bigg);
  • [optional] last argument (format): htm or tex (default htm).

If you want LaTeX style (using the {{begin}} and {{end}} templates):

{{begin|cases}} or {{begin|cases|format}} or {{begin|cases|left brace size}} or {{begin|cases|left brace size|format}}
...
{{end|cases}} or {{end|cases|format}}

Examples

Examples using {{cases}} template

The code

{{indent}}{{math|F{{sp|-2}}{{sub|''n''}}{{sp|1}}(''x'') {{sp}}{{sym|def}}{{sp}}
{{cases|begin}}
{{&}}0,{{&}}if ''n'' {{=}} 0, {{\\}}
{{&}}1,{{&}}if ''n'' {{=}} 1, {{\\}}
{{&}}F{{sp|-2}}{{sub|''n''{{sp|1}}{{op|-}}1}}{{sp|1}}(''x'') {{op|+}} ''x'' F{{sp|-2}}{{sub|''n''{{sp|1}}{{op|-}}2}}{{sp|1}}(''x''),{{sp|quad}}{{&}}if ''n'' {{rel|ge}} 2. 
{{cases|end}}
|tex = {\rm F}_{n}(x) := 
{{cases|begin|tex}}
0, & \text{if } n = 0, \\
1, & \text{if } n = 1, \\
{\rm F}_{n-1}(x) + x \, {\rm F}_{n-2}(x), & \text{if } n \geq 2.
{{cases|end|tex}}
|&&}}

yields the display style HTML+CSS (with the && option):

     
Fn (x)  := 
⎧  
⎨  
⎩  
0,if n = 0,
1,if n = 1,
Fn  − 1 (x) + x Fn  − 2 (x), if n ≥ 2.

or yields the display style LaTeX (with the $$ option):

     

The code

{{indent}}{{math|''c''{{sp|1}}(''n'') {{=|sp}} 
{{cases|begin|big}}
1 {{&}}if ''n'' {{=}} 0, {{\\}}
2{{^|{{sp|-1}}''n''{{sp|1}}{{op|-}}1}} {{sp|quad}}{{&}}if ''n'' {{rel|ge}} 1. 
{{cases|end}}
|tex = c(n) =
\begin{cases}
1 & \text{if } n = 0, \\
2^{n-1} & \text{if } n \ge 1. 
\end{cases}
|&&}}

yields the display style HTML+CSS (with the && option):

     
c (n)  = 
⎰  
⎱  
1 if n = 0,
2n  − 1if n ≥ 1.

or yields the display style LaTeX (with the $$ option):

     

Examples using {{begin}} and {{end}} templates

The code

{{indent}}{{math|F{{sp|-2}}{{sub|''n''}}{{sp|1}}(''x'') {{sp}}{{sym|def}}{{sp}} 
{{begin|cases}}
{{&}}0,{{&}}if ''n'' {{=}} 0, {{\\}}
{{&}}1,{{&}}if ''n'' {{=}} 1, {{\\}}
{{&}}F{{sp|-2}}{{sub|''n''{{sp|1}}{{op|-}}1}}{{sp|1}}(''x'') {{op|+}} ''x'' F{{sp|-2}}{{sub|''n''{{sp|1}}{{op|-}}2}}{{sp|1}}(''x''),{{sp|quad}}{{&}}if ''n'' {{rel|ge}} 2. 
{{end|cases}}
|tex = {\rm F}_{n}(x) :=
{{begin|cases|tex}}
0, & \text{if } n = 0, \\
1, & \text{if } n = 1, \\
{\rm F}_{n-1}(x) + x \, {\rm F}_{n-2}(x), & \text{if } n \geq 2.
{{end|cases|tex}}
|&&}}

yields the display style HTML+CSS (with the && option):

     
Fn (x)  := 
⎧  
⎨  
⎩  
0,if n = 0,
1,if n = 1,
Fn  − 1 (x) + x Fn  − 2 (x), if n ≥ 2.

or yields the display style LaTeX (with the $$ option):

     

The code

{{indent}}{{math|''c''{{sp|1}}(''n'') {{=|sp}} 
{{begin|cases|big}}
1{{&}} if ''n'' {{=}} 0, {{\\}}
2{{^|{{sp|-1}}''n''{{sp|1}}{{op|-}}1}} {{sp|quad}}{{&}}if ''n'' {{rel|ge}} 1. 
{{end|cases}}
|tex = c(n) =
\begin{cases}
1 & \text{if } n = 0, \\
2^{n-1} & \text{if } n \ge 1. 
\end{cases}
|&&}}

yields the display style HTML+CSS (with the && option):

     
c (n)  = 
⎰  
⎱  
1 if n = 0,
2n  − 1if n ≥ 1.

or yields the display style LaTeX (with the $$ option):

     

The code

{{indent}}{{math|sgn{{sp|1}}(''x'') {{sp}}{{rel|def}}{{sp}} 
{{begin|cases|Big}}
  0 {{&}}{{sp|quad}}{{text|if}} ''x'' {{=}} 0, {{\\}}
  {{frac|''x''|{{abs|''x''}}}} {{&}}{{sp|quad}}{{text|if}} ''x'' {{rel|ne}} 0. 
{{end|cases}}
|tex = \sgn(x) := 
\begin{cases}
  \, 0 & \text{if } x = 0, \\
  \frac{x}{ {{abs|x|tex}} } & \text{if } x \ne 0. 
\end{cases}
|&&}}

yields the display style HTML+CSS (with the && option):

     
sgn (x)  :=
⎰  
⎱  
0 if x = 0,
x
| x |
if x ≠ 0.

or yields the display style LaTeX (with the $$ option):