10.1.9 Rewriting with absolute values
The linabs command attempts rewriting
piecewise defined expressions, as well as expressions involving step functions (signum
and Heaviside) and/or absolute values, as a linear combination of absolute values of
linear arguments (see Section 8.3.2).
- linabs takes one mandatory argument and one optional argument:
- expr, an expression.
- Optionally, x, a variable (by default, x=x).
- linabs(expr ⟨,x ⟩) returns expr
written as an expression depending on parameters of form |x−a| instead on
step/piecewise expressions.
- linabs tries to find a simplest representation by nesting the parameters |x−a|.
Examples
linabs(sin(x)*Heaviside(x)-sin(x)*Heaviside(-x)) |
f:=piecewise(x<-1,x+5/2,x<2,2-x^2/2,x-2):;
linabs(f,x) |
linabs is useful for expanding expressions with nested absolute values. For example:
linabs(abs(abs(x-2)+x*abs(x+1)+1)) |
|
x2+x | ⎪
⎪ | x+1 | ⎪
⎪ | + | ⎛
⎝ | −x+1 | ⎞
⎠ | ⎪
⎪ | x+3 | ⎪
⎪ | + | ⎪
⎪ | x−2 | ⎪
⎪ | +2 x−2
|
| | | | | | | | | | |
|