### 10.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 10.3.5).
- combine(expr,trig) or combine(expr,sin) or combine(expr,cos) gives the same result as tcollect(expr) (see Section 10.2.4).

#### Examples

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

cos x sin x+ln x+ln y+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+ln x+ln y+ |
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)

cos x sin x+ex ey+ln | ⎛ ⎝ | x y | ⎞ ⎠