Documentation

rewrite

Rewrite an expression

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

rewrite(f, target)

Description

rewrite(f, target) transforms an expression f to a mathematically equivalent form, trying to express f in terms of the specified target function.

The target indicates the function that is to be used in the desired representation. Symbolic function calls in f are replaced by the target function if this is mathematically valid.

With the target arg, the function ln(sign(x)) is rewritten as i arg(x).

With the target 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.

With the target sincos, the functions tan, cot, exp, sinh, cosh, tanh, and coth are rewritten in terms of sin and cos.

With the target sin, the same is done as in the case of sincos. Additionally, cos(x)2 is rewritten as 1 - sin(x)2. This holds for the target cos analogously.

With the target sinhcosh, the functions exp, tanh, coth, sin, cos, tan, and cot are rewritten in terms of sinh and cosh. With the targets sinh and cosh, the same is done, and cosh(x)^2 is rewritten in terms of sinh (or sinh(x)^2 in terms of cosh, respectively.)

With the targets arcsin, arccos, arctan, and arccot, the logarithm, all inverse trigonometric functions, and all inverse hyperbolic functions are rewritten in terms of the target function.

With the targets arcsinh, arccosh, arctanh, and arccoth, the logarithm, all inverse hyperbolic functions and all inverse trigonometric functions are rewritten in terms of the target function.

With the target lambertW, the function wrightOmega is rewritten in terms of lambertW.

With the target erf, the functions erfc, erfi, and dawson are rewritten in terms of erf.

With the target erfc, the functions erf, erfi, and dawson are rewritten in terms of erfc.

With the target erfi, the functions erf, erfc, and dawson are rewritten in terms of erfi.

With the target bernoulli, the function euler is rewritten in terms of bernoulli.

With the target diff, symbolic calls of the differential operator D are rewritten in terms of symbolic calls of the function diff. E.g., D(f)(x) is converted to diff(f(x), x). A univariate expression D(f)(x) is rewritten if x is an identifier or an indexed identifier. A multivariate expression D([n1, n2, ...], f)(x1, x2, ...) is rewritten if x1, x2 are distinct identifiers or indexed identifiers. Trying to rewrite a multivariate call D(f)(x1, x2, ...) of the univariate dervative D(f) raises an error.

With the target D, symbolic diff calls are rewritten in terms of the differential operator D. Derivatives of univariate function calls such as diff(f(x), x) are rewritten as D(f)(x). Derivatives of multivariate function calls are expressed via D([n1, n2, ...], f). E.g., diff(f(x, y), x) is rewritten as D([1], f)(x, y).

With the target andor, the logical operators xor, ==>, and <=> are rewritten in terms of and, or, and not.

With the targets min and max, expressions in max and min and, for real arguments, abs are rewritten in terms of the target function.

The targets harmonic and psi serve for rewriting symbolic calls of psi in terms of harmonic and vice versa.

With the target inverf, the function inverfc(x) is rewritten as inverf(1 - x).

With the target inverfc, the function inverf(x) is rewritten as inverfc(1 - x).

Examples

Example 1

This example demonstrates the use of rewrite:

rewrite(D(D(f))(x), diff)

diff(f(x, x), x) = rewrite(diff(f(x, x), x), D)

assume(n, Type::PosInt):
rewrite(fact(n), gamma), rewrite(gamma(n), fact);
delete n:

rewrite(sign(x), heaviside), rewrite(heaviside(x), sign);

rewrite(heaviside(x), piecewise)

Example 2

Trigonometric functions can be rewritten in terms of exp, sin, cos etc.:

rewrite(tan(x), exp), rewrite(cot(x), sincos),
rewrite(sin(x), tan)

rewrite(arcsinh(x), ln)

Example 3

Inverse trigonometric functions can be rewritten in terms of each other:

rewrite(arcsin(x), arctan)

The following result uses the function signIm ("sign of the imaginary part") to make the formula valid throughout the complex plane (apart from the singularities at ):

rewrite(arctan(x), arcsin)

Parameters

f

An arithmetical or boolean expression

target

The target function to be used in the representation: one of andor, arccos, arccosh, arccot, arccoth, arcsin, arcsinh, arctan, arctanh, arg, bernoulli, cos, cosh, cot, coth, diff, D, erf, erfc, erfi, exp, fact, gamma, harmonic, heaviside, inverf, inverfc, lambertW, ln, max, min, piecewise, psi, sign, sin, sincos, sinh, sinhcosh, tan, or tanh

Overloaded By

f

Was this topic helpful?