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 which contain 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
|
| | | | | | | | | | |
|
linabs(abs(1-2*abs(2-3*abs(x-3)))) |
|
−6 | ⎪
⎪ | x−3 | ⎪
⎪ | +3 | ⎪
⎪ | 2 x−5 | ⎪
⎪ | +3 | ⎪
⎪ | 2 x−7 | ⎪
⎪ | −2 | ⎪
⎪ | 3 x−7 | ⎪
⎪ | −2 | ⎪
⎪ | 3 x−11 | ⎪
⎪ | + | ⎪
⎪ | 6 x−13 | ⎪
⎪ | + | ⎪
⎪ | 6 x−23 | ⎪
⎪ | −5
|
| | | | | | | | | | |
|