# Combining terms of the same type: combine

### 5.25.2 Combining terms of the same type: combine

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

#### Examples.

- Input:
  combine(exp(x)*exp(y)+sin(x)*cos(x)+ln(x)+ln(y),exp)
  Output:

  cosx· sinx+lnx+lny+ex+y

- Input:
  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)
  Output:

  ex ey+lnx+lny+

  sin | ⎛ ⎝ | 2 x | ⎞ ⎠

  2

- Input:
  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)
  Output:

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