This site is supported by donations to The OEIS Foundation.

Template:Abs

From OeisWiki
Jump to: navigation, search

The {{abs}} mathematical formatting template and/or mathematical function template gives an HTML+CSS or a LaTeX formatted absolute value of an expression and/or the numerical result of the absolute value of an expression (in which case it must evaluate to an unformatted real number).

Usage

{{abs|expression}}

or

{{abs|expression|format}}

where the last argument, format, is from

  • htm: HTML+CSS [single line] markup (default);
  • HTM: HTML+CSS [multiline] markup;
  • tex: LaTeX [single line] markup;
  • TEX: LaTeX [multiline] markup;
  • #: numerical result, in which case expression must yield an unformatted real number (see unformatted numbers).

As an alternative to using LaTeX rendered PNG images (tex or TEX options), the htm or HTM options will produce an HTML+CSS formatted expression. (Do not use this option inside <math>...</math> tags.)

NOTE: To get rendered LaTeX, you must use the {{math}} template (or {{#tag:math|...}}, although you should use the {{math}} template for consistent formatting, e.g. font face and font size), since you cannot evaluate templates, parser functions or magic words inside <math>...</math> tags.

abs function

You may also use the abs operator in a mathematical expression for a numerical argument of a template, e.g.

{{expr| abs ( expression yielding an unformatted real number ) }}

or in a mathematical expression for a numerical argument of a parser function, e.g.

{{#expr: abs ( expression yielding an unformatted real number ) }}

Examples

Code Result
{{math| {{abs}} |&}}
| · |
{{math| {{abs|htm}} |&}}
| · |
{{math| {{abs|tex}} |$}}
{{math| {{abs|''x''|htm}} |&}}
| x |
{{math| {{abs|''x''|tex}} |$}}
{{math| {{abs|''x''|htm}} |&&}}
| x |
{{math| {{abs|''x''|tex}} |$$}}

Code Result
{{math| {{abs|0|#}} |&}}
0
{{math| {{abs|{{op|-}}6|htm}} {{=}} {{abs|{{op|-}}6|#}}|&}}
|  − 6 |
= 6
{{math| {{abs|{{op|-}}6|tex}} {{=}} {{abs|{{op|-}}6|#}}|$}}
{{math| {{abs|{{op|-}}6|htm}} {{=}} {{abs|{{op|-}}6|#}}|&&}}
| −6 |
= 6
{{math| {{abs|{{op|-}}6|tex}} {{=}} {{abs|{{op|-}}6|#}}|$$}}
{{math| {{abs|{{op|-}}6.5|#}} |&}}
6.5
{{math| {{abs|6.5|#}} |&}}
6.5
{{math| {{abs|{{op|+}}6.5|#}} |&}}
6.5
{{math| {{abs|{{op|-}}6.5e+45|#}} |&}}
6.5E+45
{{math| {{abs|{{op|-}}6.5e{{op|+}}45|#}} |&}}
6.5E+45
{{math| {{abs|{{op|-}}6.5E+45|#}} |&}}
6.5E+45
{{math| {{abs|{{op|-}}6.5E{{op|+}}45|#}} |&}}
6.5E+45
{{math| {{abs|{{op|-}}6e-12|#}} |&}}
6.0E−12
{{math| {{abs|{{op|-}}6e{{op|-}}12|#}} |&}}
6.0E−12
{{math| {{abs|{{op|-}}6E-12|#}} |&}}
6.0E−12
{{math| {{abs|{{op|-}}6E{{op|-}}12|#}} |&}}
6.0E−12
{{math| {{abs|6,500}} {{=}} {{abs|{{formatnum: 6,500|R}}|#}} |&}}
| 6,500 |
= 6500

More elaborate examples

The code

{{math| ''x''{{^|3}} {{op|-}} ''x''{{^|2}} {{op|+}} 1, |&&}} <!--
-->{{math| ''x''{{^|3|tex}} {{op|-}} ''x''{{^|2|tex}} {{op|+}} 1. |$$}}

yields the display style HTML+CSS, display style LaTeX

x 3x 2 + 1,

The code

{{math| ''x''{{^|3}} {{op|-}} ''x''{{^|2}} {{op|+}} 1, |&}} <!--
-->{{math| ''x''{{^|3|tex}} {{op|-}} ''x''{{^|2|tex}} {{op|+}} 1. |$}}
yields the text style HTML+CSS, text style LaTeX:
x 3  −  x 2  +  1,

The code

{{math| {{abs| ''x''{{^|3}} {{op|-}} ''x''{{^|2}} {{op|+}} 1 |htm}}, |&&}} <!--
-->{{math| {{abs| ''x''{{^|3|tex}} {{op|-}} ''x''{{^|2|tex}} {{op|+}} 1 |tex}}. |$$}}

yields the display style HTML+CSS, display style LaTeX

| x 3x 2 + 1 |
,

The code

{{math| {{abs| ''x''{{^|3}} {{op|-}} ''x''{{^|2}} {{op|+}} 1 |HTM}}, |&&}} <!--
-->{{math| {{abs| ''x''{{^|3|tex}} {{op|-}} ''x''{{^|2|tex}} {{op|+}} 1 |TEX}}. |$$}}

yields the display style HTML+CSS, display style LaTeX

x 3x 2 + 1
,

The code

{{math| {{abs| ''x''{{^|3}} {{op|-}} ''x''{{^|2}} {{op|+}} 1 |htm}}, |&}} <!--
-->{{math| {{abs| ''x''{{^|3|tex}} {{op|-}} ''x''{{^|2|tex}} {{op|+}} 1 |tex}}. |$}}
yields the text style HTML+CSS, text style LaTeX:
| x 3  −  x 2  +  1 |
,

The code

{{math| {{abs| ''x''{{^|3}} {{op|-}} ''x''{{^|2}} {{op|+}} 1 |HTM}}, |&}} <!--
-->{{math| {{abs| ''x''{{^|3|tex}} {{op|-}} ''x''{{^|2|tex}} {{op|+}} 1 |TEX}}. |$}}
yields the text style HTML+CSS, text style LaTeX:
x 3  −  x 2  +  1
,

The code

{{math| {{abs| {{frac| 1 | ''x''{{^|3}} {{op|-}} ''x''{{^|2}} {{op|+}} 1 |htm}} |HTM}}, |&&}} <!--
-->{{math| {{abs| {{frac| 1 | ''x''{{^|3|tex}} {{op|-}} ''x''{{^|2|tex}} {{op|+}} 1 |tex}} |TEX}}. |$$}}

yields the display style HTML+CSS, display style LaTeX

1
x 3x 2 + 1
,

The code

{{math| {{abs| {{frac| 1 | ''x''{{^|3}} {{op|-}} ''x''{{^|2}} {{op|+}} 1 |htm}} |HTM}}, |&}} <!--
-->pre{{math| {{abs| {{frac| 1 | ''x''{{^|3|tex}} {{op|-}} ''x''{{^|2|tex}} {{op|+}} 1 |tex}} |TEX}}. |$}}
yields the text style HTML+CSS, text style LaTeX:
1
x 3  −  x 2  +  1
,

Examples with invalid input

Code Result Comment
{{abs|6,500|#}} Abs error: First argument must be an unformatted real number. (formatted numbers are not allowed)
{{abs|i|#}} Abs error: First argument must be an unformatted real number.
{{abs|blob|#}} Abs error: First argument must be an unformatted real number.
{{abs|6 blobs|#}} Abs error: First argument must be an unformatted real number.

See also

  • {{norm}} to typeset and/or obtain the norm of an expression (which must yield a real number, a complex number, a quaternion or an
    n
    -vector,
    n ∈ {1, 2, 3, 4}
    )
  • {{sgn}} to typeset and/or obtain the sign of a real number (note that the sgn signum function is not supported by {{#expr: }})