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) returns the absolute value of the
For many constant expressions,
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
abs extracts constant factors. Properties
of identifiers are taken into account. See Example 2 and Example 3.
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
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,
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)
produces products of
abs(x*(y + 1)), expand(abs(x*(y + 1)))
The absolute value of the symbolic constants
etc. are known:
abs(PI), abs(EULER + CATALAN^2)
abs can be differentiated:
diff(abs(x), x), diff(abs(x), x, x)
a function environment
f defines the absolute value
of symbolic calls of
f := funcenv(f): f::abs := x -> f(x)/sign(f(x)): abs(f(x))
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:
arithmetical expression or a container object containing such expressions