rewrite -- rewrite an
expression
Introductionrewrite(f, target) transforms an
expression f to a mathematically equivalent form, trying
to express f in terms of the specified target
function.
Call(s)rewrite(f, target)
Parametersf |
- | an arithmetical expression |
target |
- | the target function to be used in the representation:
one of cot, coth, diff, exp, fact, gamma, heaviside, ln, piecewise, sign, sincos, sinhcosh, tan, or tanh |
Returnsan arithmetical expression.
f
Further
DocumentationChapter ``Manipulating Expressions'' of the Tutorial.
Related
Functionscollect, combine, expand, factor, normal, partfrac, rationalize, rectform, simplify
Detailsf are
replaced by the target function if this is mathematically valid.exp, all trigonometric and hyperbolic
functions are rewritten in terms of exp. Further, the
inverse functions as well as arg are rewritten in terms of
ln.tan, cot, exp,
sinh, cosh, tanh, and
coth are rewritten in terms of sin and
cos.exp, tanh, coth,
sin, cos, tan, and
cot are rewritten in terms of sinh and
cosh.
Example
1This examples demonstrates the use of
rewrite:
>> rewrite(D(D(y))(x), diff)
diff(y(x), x, x)
>> rewrite(fact(n), gamma), rewrite(gamma(n), fact);
gamma(n + 1), fact(n - 1)
>> rewrite(sign(x), heaviside), rewrite(heaviside(x), sign);
sign(x)
2 heaviside(x) - 1, ------- + 1/2
2
>> rewrite(heaviside(x), piecewise)
piecewise(1 if 0 < x, heaviside(0) if x = 0, -1 if x < 0)
Example
2Trigonometric functions can be rewritten in terms of
exp, sin, cos etc.:
>> rewrite(tan(x), exp), rewrite(cot(x), sincos), rewrite(sin(x), tan)
/ x \
2 2 tan| - |
I exp(I x) - I cos(x) \ 2 /
- ---------------, ------, -------------
2 sin(x) / x \2
exp(I x) + 1 tan| - | + 1
\ 2 /
>> rewrite(arcsinh(x), ln)
2 1/2
ln(x + (x + 1) )
cot, coth, tanh,
and piecewise were
added.