abs - Maple Help

abs

The absolute value function

Calling Sequence

 abs(x) $\left|x\right|$ abs(n, x)

Parameters

 x - expression or rtable n - positive integer

Description

 • The abs function returns the absolute value of the expression x.
 • You can enter the command abs using either the 1-D or 2-D calling sequence. For example, abs(-11) is equivalent to $\left|-11\right|$.
 • If x is an rtable (Array, Matrix, or Vector), the abs function applies the abs function to each entry in the table, and returns the resulting rtable.
 • If x includes a function f, then abs will attempt to execute the procedure abs/f to determine the absolute value of the corresponding part of x.  The user can thus easily extend the functionality of abs.
 • The derivative of abs is denoted by abs(1, x). This is signum(x) for all non-0 real numbers, and is undefined otherwise. Neither first order nor higher order derivatives of abs can be determined if x is an rtable.
 • Higher order derivatives of abs are denoted by abs(n, x), where n is a positive integer.  When n is known, the expression is automatically simplified to the appropriate expression in a derivative of either signum or abs.

Examples

 > $\mathrm{abs}\left(-11\right)$
 ${11}$ (1)
 > $\mathrm{abs}\left(\mathrm{cos}\left(3\right)\right)$
 ${-}{\mathrm{cos}}{}\left({3}\right)$ (2)
 > $\mathrm{evalf}\left(\right)$
 ${0.9899924966}$ (3)
 > $\mathrm{abs}\left(-2\cdot 10\right)$
 ${20}$ (4)
 > $a≔\mathrm{abs}\left(2x-3\right)$
 ${a}{≔}\left|{2}{}{x}{-}{3}\right|$ (5)
 > $x≔1$
 ${x}{≔}{1}$ (6)
 > $a$
 ${1}$ (7)

The absolute value of a complex number is the modulus.

 > $\mathrm{abs}\left(3-4I\right)$
 ${5}$ (8)
 > $\mathrm{expr}≔\mathrm{abs}\left(\mathrm{sqrt}\left(2\right)I{u}^{2}v\right)$
 ${\mathrm{expr}}{≔}\sqrt{{2}}{}{\left|{u}\right|}^{{2}}{}\left|{v}\right|$ (9)
 > $\mathrm{expand}\left(\mathrm{expr}\right)$
 $\sqrt{{2}}{}{\left|{u}\right|}^{{2}}{}\left|{v}\right|$ (10)
 > $\mathrm{combine}\left(\mathrm{expr},\mathrm{abs}\right)$
 $\sqrt{{2}}{}{\left|{u}\right|}^{{2}}{}\left|{v}\right|$ (11)
 > $\mathrm{assume}\left(u,\mathrm{positive}\right):$$\mathrm{simplify}\left(\mathrm{expr}\right)$
 $\sqrt{{2}}{}{{\mathrm{u~}}}^{{2}}{}\left|{v}\right|$ (12)
 > $\mathrm{expr2}≔\mathrm{abs}\left({b}^{4}{c}^{2}{d}^{3}\right)$
 ${\mathrm{expr2}}{≔}{\left|{b}\right|}^{{4}}{}{\left|{c}\right|}^{{2}}{}{\left|{d}\right|}^{{3}}$ (13)
 > $\mathrm{assume}\left(0$\mathrm{simplify}\left(\mathrm{expr2}\right)$
 ${{\mathrm{b~}}}^{{4}}{}{{\mathrm{c~}}}^{{2}}{}{\left|{d}\right|}^{{3}}$ (14)
 > $\mathrm{int}\left(\mathrm{abs}\left(y\right),y\right)$
 $\left\{\begin{array}{cc}{-}\frac{{{y}}^{{2}}}{{2}}& {y}{\le }{0}\\ \frac{{{y}}^{{2}}}{{2}}& {0}{<}{y}\end{array}\right\$ (15)
 > $\mathrm{diff}\left(\mathrm{abs}\left(y\right),y\right)$
 ${\mathrm{abs}}{}\left({1}{,}{y}\right)$ (16)
 > $\mathrm{diff}\left(\mathrm{abs}\left(y\right),y,y\right)$
 ${\mathrm{signum}}{}\left({1}{,}{y}\right)$ (17)
 > $\mathrm{abs}\left(2,y\right)$
 ${\mathrm{signum}}{}\left({1}{,}{y}\right)$ (18)

To find the absolute value of a Matrix, use the absolute value function as written in 1-D Math, to avoid confusion between the function abs and the determinant of the Matrix.

 > $\mathrm{abs}\left(\mathrm{Array}\left(1..2,1..2,-2\right)\right)$
 $\left[\begin{array}{cc}{2}& {2}\\ {2}& {2}\end{array}\right]$ (19)
 > $\mathrm{abs}\left(⟨⟨-1,2,3⟩|⟨-4,5,-6⟩⟩\right)$
 $\left[\begin{array}{cc}{1}& {4}\\ {2}& {5}\\ {3}& {6}\end{array}\right]$ (20)
 > $\mathrm{abs}\left(\mathrm{Matrix}\left(3,\mathrm{fill}=-1\right)\right)$
 $\left[\begin{array}{ccc}{1}& {1}& {1}\\ {1}& {1}& {1}\\ {1}& {1}& {1}\end{array}\right]$ (21)

The derivative of the absolute value of an rtable cannot be determined, so an error results.

 > $\mathrm{abs}\left(1,\mathrm{rtable}\left(1..2,-1\right)\right)$