abs - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

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

 > $\left|-11\right|$
 ${11}$ (1)
 > $\left|\mathrm{cos}\left(3\right)\right|$
 ${-}{\mathrm{cos}}{}\left({3}\right)$ (2)
 > $\mathrm{evalf}\left(\right)$
 ${0.9899924966}$ (3)
 > $\left|-2\cdot 10\right|$
 ${20}$ (4)
 > $a≔\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.

 > $\left|3-4I\right|$
 ${5}$ (8)
 > $\mathrm{expr}≔\left|\sqrt{2}I{u}^{2}v\right|$
 ${\mathrm{expr}}{≔}\sqrt{{2}}{}\left|{{u}}^{{2}}{}{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}}^{{2}}{}{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}≔\left|{b}^{4}{c}^{2}{d}^{3}\right|$
 ${\mathrm{expr2}}{≔}\left|{{b}}^{{4}}{}{{c}}^{{2}}{}{{d}}^{{3}}\right|$ (13)
 > $\mathrm{assume}\left(0$\mathrm{simplify}\left(\mathrm{expr2}\right)$
 ${{\mathrm{b~}}}^{{4}}{}{{\mathrm{c~}}}^{{2}}{}{\left|{d}\right|}^{{3}}$ (14)
 > $∫\left|y\right|\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}ⅆy$
 ${{}\begin{array}{cc}{-}\frac{{1}}{{2}}{}{{y}}^{{2}}& {y}{\le }{0}\\ \frac{{1}}{{2}}{}{{y}}^{{2}}& {0}{<}{y}\end{array}$ (15)
 > $\frac{ⅆ}{ⅆy}\left|y\right|$
 ${\mathrm{abs}}{}\left({1}{,}{y}\right)$ (16)
 > $\frac{{ⅆ}^{2}}{ⅆ{y}^{2}}\left|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.

 > $\left|\mathrm{Array}\left(1..2,1..2,-2\right)\right|$
 $\left[\begin{array}{rr}{2}& {2}\\ {2}& {2}\end{array}\right]$ (19)
 > $\left|⟨⟨-1,2,3⟩|⟨-4,5,-6⟩⟩\right|$
 $\left[\begin{array}{rr}{1}& {4}\\ {2}& {5}\\ {3}& {6}\end{array}\right]$ (20)
 > $\left|\mathrm{Matrix}\left(3,\mathrm{fill}=-1\right)\right|$
 $\left[\begin{array}{rrr}{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)$

 See Also