combine -- combine terms of the
same algebraic structure
Introductioncombine(f) tries to rewrite products of
powers in the expression f as a single power.
combine(f, target) combines several calls
to the target function(s) in the expression f to a single
call.
Call(s)combine(f)
combine(f, target)
combine(f, [target1, target2, ...])
Parametersf |
- | an arithmetical expression, an array, a list, a polynomial, or a set |
target |
- | one of the identifiers arctan,
exp, ln, sincos, or sinhcosh |
Returnsan object of the same type as the input object f.
Side
Effectscombine reacts to properties of identifiers appearing
in the input.
f
Further
DocumentationChapter ``Manipulating Expressions'' of the Tutorial.
Related
Functionsdenom, expand, factor, normal, numer, radsimp, rectform, rewrite, simplify
Detailscombine(f) applies the following
rewriting rules to products of powers occurring as subexpressions in an
arithmetical expression f:
combine is the inverse
functionality of expand. See example 1.
Since MuPAD's internal simplifier
automatically applies the above rules in the reverse direction in
certain cases, combine sometimes has no effect. See
example 2.
combine(f, target) applies rewriting
rules applicable to the target function(s) to an arithmetical expression f. Some of the
rules are only valid under certain additional restrictions. With
respect to most of the rules, combine implements the
inverse functionality of expand. Here is a list of the
rewriting rules for the various targets:
target = arctan:
target = exp (see example 4:)
target = ln (see example 5:)
target = sincos (see example 3):
target = sinhcosh:
combine works recursively on the subexpressions of
f.combine is applied to f subsequently for each
of the targets in the list. See example 6.f is array, a list, or a set,
combine is applied to all entries of f; see
example 7. If f is a polynomial or a series expansion, of type Series::Puiseux or Series::gseries,
combine is applied to each coefficient; see
example 8.
Example
1Without a second argument, combine combines
powers of the same base:
>> combine(sin(x) + x*y*x^(exp(1)))
exp(1) + 1
sin(x) + y x
Moreover, combine also combines powers with
the same exponent in certain cases:
>> combine(sqrt(2)*sqrt(3))
1/2
6
Example
2In most cases, however, combine does not
combine powers with the same exponent:
>> combine(y^5*x^5)
5 5
x y
Example
3With the second argument sincos,
combine rewrites products of sines and cosines as a sum of
sines and cosines with more complicated arguments:
>> combine(sin(a)*cos(b) + sin(b)^2, sincos)
sin(a + b) cos(2 b) sin(a - b)
---------- - -------- + ---------- + 1/2
2 2 2
Note that powers of sines or cosines with negative integer exponents are not rewritten:
>> combine(sin(b)^(-2), sincos)
1
-------
2
sin(b)
Example
4With the second argument exp, the
well-known rules for the exponential function are applied:
>> combine(exp(3)*exp(2), exp)
exp(5)
>> combine(exp(a)^2, exp)
exp(2 a)
Example
5This example shows the application of rules for the logarithm, and at the same time the dependence on properties of the identifiers appearing in the input. The logarithm of a product does not always equal the sum of the logarithms of its factors; but for positive numbers, this rule may be applied:
>> combine(ln(a)+ln(b), ln)
ln(a) + ln(b)
>> assume(a>0): assume(b>0): combine(ln(a)+ln(b), ln)
ln(a b)
>> unassume(a): unassume(b):
Example
6The second argument may also be a list of targets. Then the rewriting rules for each of the targets in the list are applied:
>> combine(ln(2)+ln(3)+sin(a)*cos(a), [ln, sincos])
sin(2 a)
ln(6) + --------
2
Example
7combine maps to sets:
>> combine({sqrt(2)*sqrt(5), sqrt(2)*sqrt(11)})
1/2 1/2
{10 , 22 }
Example
8combine maps to the coefficients of
polynomials:
>> combine(poly(sin(x)*cos(x)*y, [y]), sincos)
/ / sin(2 x) \ \
poly| | -------- | y, [y] |
\ \ 2 / /
However, it does not touch the polynomial's indeterminates:
>> combine(poly(sin(x)*cos(x)), sincos)
poly(sin(x) cos(x), [sin(x), cos(x)])
Backgroundcombine
by implementing additional rewriting rules for other target functions.
This works by defining a new slot "target" of
combine; you need to unprotect
the identifier combine first in order to do that.
Afterwards, the command combine(f, target)
leads to the call combine::target(f) of the corresponding
slot routine.combine handles a subexpression
g(x1,x2,...) of f by calling itself
recursively for the operands x1, x2, etc.
Users can change this behavior for their own mathematical function
given by a function environment
g by implementing a "combine" slot of
g. To handle the subexpression g(x1,x2,...),
combine then calls the slot routine
g::combine with the argument sequence
x1,x2,... of g._power and sqrt are obsolete;
their functionality is covered by a call to combine
without a second argument.combine now reacts to properties of identifiers in the
input.