combine
Combines terms of an expression using rules for powers, logarithms and trigonometric functions.
Category: Mathematics > Formula Manipulation and Simplification
Syntax
R = combine(S)
Applies the available combination rules.
R = combine(S, target)
Applies the rules for one target: 'sincos', 'exp', 'log' or 'powers'.
Description
combine works in the opposite direction of expand. It turns products of sines and cosines into sines or cosines of sums of angles, products of powers with the same base into a single power, and so on. For example sin(x)*cos(x) becomes sin(2*x)/2 with the 'sincos' target.
Input arguments
S- Symbolic expression.
target- Optional string naming the rule set.
Output arguments
R- Rewritten expression, equal to
S.
Example
Trigonometric and power rules
syms x
combine(sin(x)*cos(x), 'sincos')
combine(sin(x)*sin(2*x), 'sincos')
combine(x^2*x^3, 'powers')
Output
ans = sin(2*x)/2
ans = cos(x)/2 - cos(3*x)/2
ans = x^5
Notes
Combination of logarithms with numeric constants (log(x) + log(2)) is not reliable in MatLivre, so prefer the trigonometric and power rules.