This is taken from Trefethen and Bau, 13.3.
Why is there a difference in accuracy between evaluating near 2 the expression $(x-2)^9$ and this expression:
$$x^9 - 18x^8 + 144x^7 -672x^6 + 2016x^5 - 4032x^4 + 5376x^3 - 4608x^2 + 2304x - 512 $$
Where exactly is the problem?
Thanks.

$(x-2)$ is small by definition of $x$, $(x-2)^9$ is even much smaller but can be computed with small relative error. The single terms of the expanded polynomial are much larger and therefore you will suffer from catastrophic cancellation (see e.g. Wiki or do a web search). Example: $$x=2 + 10^{-2} \Longrightarrow (x-2)^9 = 10^{-18}.$$ This is below the machine epsilon for double! Now with your expanded polynom you have to compute $-512 + 23.04 \pm \dots$.
And here is the actual computation with double and evaluation of the polynomial using Horner for $x=2.01:$
As expected the polynomial result is completely wrong (in terms of relative error), but note that even the relative error for the first is about $2\cdot 10^{-13},$ which is a result from the fact that $0.01$ cannot represented exactly as double.