Talk:Common subexpression elimination

This problem seems much more complicated than the article suggests. For example,

$$ x^3+3 x^2 y+3xy^2+y^3-x^2-2xy+2xc-y^2+2yc-c^2 $$

takes 19 multiplications and 9 additions to evaluate, but it can be rewritten as

$$ (x+y)^3 + (x+y-c)^2 $$

which only requires 3 multiplications and 3 additions. How does subexpression elimination know how to do this?