Combining terms of the same type

### 9.4.2 Combining terms of the same type

The combine command joins subexpressions of various types.

- combine takes two arguments:
  - expr, an expression.
  - function, the name of a function or class of functions. function can be one of exp, log, ln, sin, cos, or trig.
- combine(expr,function) returns the expression with subexpressions corresponding to the second argument combined.

The combine command can duplicate the effect of other commands.

- combine(expr,ln) or combine(expr,log) gives the same result as lncollect(expr) (see Section 9.3.5).
- combine(expr,trig) or combine(expr,sin) or combine(expr,cos) gives the same result as tcollect(expr) (see Section 9.2.4).

#### Examples

combine(exp(x)*exp(y)+sin(x)*cos(x)+ln(x)+ln(y),exp)

cosx sinx+lnx+lny+ex+y |  |  |  |  |  |  |  |  |  |

combine(exp(x)*exp(y)+sin(x)*cos(x)+ln(x)+ln(y),trig)

or:

combine(exp(x)*exp(y)+sin(x)*cos(x)+ln(x)+ln(y),sin)

or:

combine(exp(x)*exp(y)+sin(x)*cos(x)+ln(x)+ln(y),cos)

ex ey+lnx+lny+ |
sin | ⎛ ⎝ | 2 x | ⎞ ⎠
2

combine(exp(x)*exp(y)+sin(x)*cos(x)+ln(x)+ln(y),ln)

or:

combine(exp(x)*exp(y)+sin(x)*cos(x)+ln(x)+ln(y),log)

cosx sinx+ex ey+ln | ⎛ ⎝ | x y | ⎞ ⎠