2

How do I replace an algebraic expression with a symbol? I'm trying to replace repeated terms such as $(a+b)$ with c, for example, so that $x(4a + 4b) + x^2(6a + 6b)$ becomes $x4c + x^26c$ .

1 Answers1

1
fun = x (4 a + 4 b) + x^2 (6 a + 6 b);

Collect[fun, {a, b}]/2 /. a | b :> c

c*(4x + 6x^2)

Expand[%]

4cx + 6cx^2

eldo
  • 67,911
  • 5
  • 60
  • 168