This site is supported by donations to The OEIS Foundation.

Template:~Min3

From OeisWiki
Jump to: navigation, search

The {{~Min3}} core function template (used by the {{MIN}} mathematical function template) gives the minimum of one to three numbers or mathematical expressions. This template

  • considers only the first three arguments (ignores extra arguments);
  • considers only arguments (among the first three) which are not undefined, empty string or white space characters (spaces, tabs, newlines) only;
  • returns empty string if all three arguments are undefined, empty string or white space characters (spaces, tabs, newlines) only;
  • returns an error message when a considered argument does not evaluate to a number (arguments require prior validation).

Usage

{{~Min3|expression}}

or

{{~Min3|expression 1|expression 2}}

or

{{~Min3|expression 1|expression 2|expression 3}}

Valid input

One to three expressions yielding numbers (requires prior validation) as arguments. Extra arguments are ignored! Arguments (among the first three) which are undefined, empty string or white space characters (spaces, tabs, newlines) only are ignored.

Examples

Examples with valid input

Code Result Comment
{{~Min3}} (empty string)
{{~Min3|-34}} -34
{{~Min3|3^3}} 27
{{~Min3|-34|-3}} -34
{{~Min3|34|-3}} -3
{{~Min3|5^2|3^3}} 25
{{~Min3||5^2|3^3}} 25 (first argument is empty)
{{~Min3||3^3|5^2}} 25 (first argument is empty)
{{~Min3|5^2||3^3}} 25 (second argument is empty)
{{~Min3|3^3||5^2}} 25 (second argument is empty)
{{~Min3|5^2|3^3|}} 25 (third argument is empty)
{{~Min3|3^3|5^2|}} 25 (third argument is empty)
{{~Min3|||5^2}} 25 (first and second arguments are empty)
{{~Min3||5^2|}} 25 (first and third arguments are empty)
{{~Min3|5^2||}} 25 (second and third arguments are empty)
{{~Min3|7|2|15}} 2
{{~Min3|2|-7|-15}} -15
{{~Min3|-7|2|-15}} -15
{{~Min3|2|-15|-7}} -15
{{~Min3|-7|-15|2}} -15
{{~Min3|-15|2|-7}} -15
{{~Min3|-15|-7|2}} -15
{{~Min3|3^3|31|5^2}} 25
{{~Min3|97|{{Fibonacci|11}}|10^2}} 89
{{~Min3|34| {{formatnum: -3,000 |R}} }} -3000 (remove format from formatted numbers)

Examples with invalid input

Code Result Comment
{{~Min3|one}} Expression error: Unrecognized word "one".
{{~Min3|34|-3 blobs}} Expression error: Unexpected < operator.
{{~Min3|34|blobs}} Expression error: Unexpected < operator.
{{~Min3|7|blob|15}} Expression error: Unexpected < operator.
{{~Min3|7|15|blob}} Expression error: Unexpected < operator.
{{~Min3|34|-3,000}} Expression error: Unexpected < operator. (formatted numbers are not allowed!)
{{~Min3|7|2|15|-40}} 2 (fourth argument ignored!)

Code

<noinclude>{{Documentation}}</noinclude><includeonly><!-- 

* considers only the first three arguments (ignores extra arguments);
* considers only arguments (among the first three) which are not undefined, empty string or white space characters (spaces, tabs, newlines) only;   
* returns empty string if all three arguments are undefined, empty string or white space characters (spaces, tabs, newlines) only;
* returns an error message when a considered argument does not evaluate to a number (arguments require prior validation).

-->{{#expr:
  {{#if: {{{1|}}}  
  | {{#if: {{{2|}}}
    | {{#if: {{{3|}}} 
      | {{#ifexpr: ( {{{1}}} ) < ( {{{2}}} )
        | {{#ifexpr: ( {{{1}}} ) < ( {{{3}}} )
          | {{{1}}} 
          | {{{3}}}
          }}
        | {{#ifexpr: ( {{{2}}} ) < ( {{{3}}} )
          | {{{2}}} 
          | {{{3}}}
          }}
        }}
      | {{#ifexpr: ( {{{1}}} ) < ( {{{2}}} ) <!-- {{{3|}}} is empty or white space -->
        | {{{1}}} 
        | {{{2}}}
        }}
      }}
    | {{#if: {{{3|}}} <!-- {{{2|}}} is empty or white space -->
      | {{#ifexpr: ( {{{1}}} ) < ( {{{3}}} )
        | {{{1}}} 
        | {{{3}}}
        }}
      | {{{1|}}} <!-- {{{2|}}} and {{{3|}}} are empty or white space --><!-- {{{1|}}} could be empty or white space --> 
      }}
    }} 
  | {{#if: {{{2|}}} <!-- {{{1|}}} is empty or white space -->
    | {{#if: {{{3|}}}
      | {{#ifexpr: ( {{{2}}} ) < ( {{{3}}} )
        | {{{2}}} 
        | {{{3}}}
        }}
      | {{{2}}} <!-- {{{1|}}} and {{{3|}}} are empty or white space --> 
      }}
    | {{{3|}}} <!-- {{{1|}}} and {{{2|}}} are empty or white space --><!-- {{{3|}}} could be empty or white space -->
    }} 
  }} 
}}</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)