abs
Absolute value of a real or complex number
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
abs(z
) abs(L
)
abs(z)
returns the absolute value of the
number z
.
For many constant expressions, abs
returns
the absolute value as an explicit number or expression. Cf. Example 1.
A symbolic call of abs
is returned if the
absolute value cannot be determined (e.g., because the argument involves
identifiers). The result is subject to certain simplifications. In
particular, abs
extracts constant factors. Properties
of identifiers are taken into account. See Example 2 and Example 3.
The expand
function
rewrites the absolute value of a product to a product of absolute
values. E.g., expand(abs(x*y))
yields abs(x)*abs(y)
.
Cf. Example 4.
The symbolic constants CATALAN
, E
, EULER
,
and PI
are processed by abs
.
Cf. Example 5.
The absolute value of symbolic function calls can be defined
via the slot "abs"
of function environments. Cf. Example 7.
In the same way, the absolute value of domain elements can be defined via overloading. Cf. Example 8.
This function is automatically mapped to all entries of container objects such as arrays, lists, matrices, polynomials, sets, and tables.
abs
respects properties of
identifiers.
For many constant expressions, the absolute value can be computed explicitly:
abs(1.2), abs(8/3), abs(3 + I), abs(sqrt(3))
abs(sin(42)), abs(PI^2  10), abs(exp(3)  tan(157/100))
abs(exp(3 + I)  sqrt(2))
Symbolic calls are returned if the argument contains identifiers without properties:
abs(x), abs(x + 1), abs(sin(x + y))
The result is subject to some simplifications. In particular, abs
splits
off constant factors in products:
abs(PI*x*y), abs((1 + I)*x), abs(sin(4)*(x + sqrt(3)))
abs
is sensitive to properties of identifiers:
assume(x < 0): abs(3*x), abs(PI  x), abs(I*x)
unassume(x):
The expand
function
produces products of abs
calls:
abs(x*(y + 1)), expand(abs(x*(y + 1)))
The absolute value of the symbolic constants PI
, EULER
,
etc. are known:
abs(PI), abs(EULER + CATALAN^2)
Expressions containing abs
can be differentiated:
diff(abs(x), x), diff(abs(x), x, x)
The slot "abs"
of
a function environment f
defines the absolute value
of symbolic calls of f
:
abs(f(x))
f := funcenv(f): f::abs := x > f(x)/sign(f(x)): abs(f(x))
delete f:
The slot "abs"
of
a domain d
defines the absolute value of its elements:
d := newDomain("d"): e1 := new(d, 2): e2 := new(d, x): d::abs := x > abs(extop(x, 1)): abs(e1), abs(e2)
delete d, e1, e2:
 

A container object: an array, an hfarray, a list, a matrix, a polynomial, a set, or a table. 
arithmetical expression or a container object containing such expressions
z