This site is supported by donations to The OEIS Foundation.

Template:Max

From OeisWiki
Jump to: navigation, search

The {{max}} mathematical function template gives the maximum of one to three numbers or mathematical expressions. (For more than three arguments, use {{MAX}} instead.)

Usage

To use it, enter

{{max|input1}} (trivial case)

or

{{max|input1|input2}}

or

{{max|input1|input2|input3}}

Valid input

One to three numbers or mathematical expressions as arguments.

Examples

Examples with valid input

Code Result
{{max|7|2|15}} 15
{{max|2|-7|-15}} 2
{{max|-7|2|-15}} 2
{{max|2|-15|-7}} 2
{{max|-7|-15|2}} 2
{{max|-15|2|-7}} 2
{{max|-15|-7|2}} 2
{{max|34|-3}} 34
{{max|-34|-3}} -3
{{max|-34}} -34
{{max|3^3|31|5^2}} 31
{{max|5^2|3^3}} 27
{{max|3^3}} 27

Examples with invalid input

Code Result
{{max}} Max error: One to three unformatted numbers required as arguments
{{max|one}} Max error: One to three unformatted numbers required as arguments
{{max|34|-3 blobs}} Max error: One to three unformatted numbers required as arguments
{{max|34|blobs}} Max error: One to three unformatted numbers required as arguments
{{max|7|blob|15}} Max error: One to three unformatted numbers required as arguments
{{max|7|15|blob}} Max error: One to three unformatted numbers required as arguments
{{max|34|-3,000}} Max error: One to three unformatted numbers required as arguments
{{max|7|2|15|40}} Max error: Too many arguments, try {{MAX}} instead

Code


<noinclude>{{Documentation}}</noinclude><includeonly><!--
-->{{ifnum| {{{1}}}
| {{#if: {{{2|}}} 
  | {{ifnum| {{{2}}}  
    | {{#if: {{{3|}}} 
      | {{ifnum| {{{3}}}   
        | {{#ifexpr: ( {{{1}}} ) > ( {{{2}}} ) 
          | {{#ifexpr: ( {{{1}}} ) > ( {{{3}}} ) 
            | {{#if: {{{4|}}} | {{error| Max error: Too many arguments, try {{tlxb|MAX}} instead }} | {{#expr: {{{1}}} }} }} 
            | {{#if: {{{4|}}} | {{error| Max error: Too many arguments, try {{tlxb|MAX}} instead }} | {{#expr: {{{3}}} }} }}
            }} 
          | {{#ifexpr: ( {{{2}}} ) > ( {{{3}}} ) 
            | {{#if: {{{4|}}} | {{error| Max error: Too many arguments, try {{tlxb|MAX}} instead }} | {{#expr: {{{2}}} }} }} 
            | {{#if: {{{4|}}} | {{error| Max error: Too many arguments, try {{tlxb|MAX}} instead }} | {{#expr: {{{3}}} }} }}
            }}
          }} 
        | {{error| Max error: One to three [[unformatted numbers]] required as arguments }} 
        }}
      | {{#ifexpr: ( {{{1}}} ) > ( {{{2}}} ) 
        | {{#expr: {{{1}}} }} 
        | {{#expr: {{{2}}} }}
        }}
      }}  
    | {{error| Max error: One to three [[unformatted numbers]] required as arguments }} 
    }}  
  | {{#expr: {{{1}}} }}  
  }} 
| {{error| Max error: One to three [[unformatted numbers]] required as arguments }} 
}}</includeonly>

See also

  • {{min}} minimum of one to three expressions yielding numbers
  • {{max}} maximum of one to three expressions yielding numbers


  • {{MIN}} minimum of one to eighty-one expressions yielding numbers
  • {{MAX}} maximum of one to eighty-one expressions yielding numbers


  • Core function templates (used ONLY by {{MIN}}; do NOT use directly!)
    • {{~Min3}} (should be used for up to three numbers or mathematical expressions)
    • {{~Min9}} (should be used for four to nine numbers or mathematical expressions)
    • {{~Min27}} (should be used for ten to twenty-seven numbers or mathematical expressions)
    • {{~Min81}} (should be used for twenty-eight to eighty-one numbers or mathematical expressions)


  • Core function templates (used ONLY by {{MAX}}; do NOT use directly!)
    • {{~Max3}} (should be used for up to three numbers or mathematical expressions)
    • {{~Max9}} (should be used for four to nine numbers or mathematical expressions)
    • {{~Max27}} (should be used for ten to twenty-seven numbers or mathematical expressions)
    • {{~Max81}} (should be used for twenty-eight to eighty-one numbers or mathematical expressions)