Why is $(1+x)^2$ less accurate than $ (x+2)x+1$ for small $x$? I've known that accuracy is based on the amount of roundings (or multiplications) that occur, but from what I can tell, both equations will require the same amount. 
My first thought was to related $(1+x)^2$ to $1+2x+x^2$ and say that there are two mandatory roundings that happen, but that equation is also equivalent to $(x+2)x+1$, so it wouldn't make sense to make my standard point off of that.
Any help will be greatly appreciated, thank you.
 A: A heuristic explanation: suppose that $x$ is very small; then the floating point approximation to $1+x$ will often be erroneous because of 'float rounding': for instance, suppose that you have 10 digits of core 'float' accuracy and that $x\approx 10^{-8}$; then $1+x$ will lose all but two digits of $x$'s accuracy, and when we square $1+x$ then the remaining digits stay lost.  By contrast, when adding $2+x$ we may lose another bit of accuracy initially, but the result is then multiplied by $x$ and this multiplication gains the 'full accuracy' of its second $x$ factor.
(On the other hand, the fact that $1$ is then added to the result leaves me skeptical, because much of that accuracy is promptly lost again; I would like this explanation much more if it were comparing e.g. $(x+2)x$ vs. $(x+1)^2-1$.)
A: In interval arithmetic, this question is answered differently than you may expect.  In particular, the accuracy of every formula can be rigorously proven directly by evaluating increasingly small intervals up to the accuracy limit of the system.
Here is an example of how it works:
Given $x=[a,b]$ as the interval being evaluated with $a\lt b$, evaluate the following:
$$f_1(x)=(x+1)^2$$
$$f_2(x)=(x+2)x+1$$
$$f_3(x)=x^2+2x+1$$
$$f_1([a,b])=([a,b]+1)^2=[a+1,b+1]^2=[\min((a+1)^2,(b+1)^2),\max((a+1)^2,(b+1)^2)]$$
$$f_2([a,b])=([a,b]+2)[a,b]+1=[a+2,b+2][a,b]+1=[\min(a(a+2),a(b+2),b(a+2),b(b+2))+1,\max(a(a+2),a(b+2),b(a+2),b(b+2))+1]$$
$$f_3([a,b])=[a,b]^2+2[a,b]+1=[\min(a^2,b^2),\max(a^2,b^2)]+[2a,2b]+1=[\min(a^2,b^2)+2a+1,\max(a^2,b^2)+2b+1]$$
Given that we know only that $a\lt b$, $f_1$ and $f_3$ demonstrate the greatest similarity, but it should be obvious that if $|a|\gt|b|$ then $f_1\ne f_3$.  If we say that a measure of the accuracy is the ratio of the length of the input interval compared to the length of the output interval, then $f_1$ has greater accuracy than $f_3$ overall.
This isn't the best possible demonstration of how interval arithmetic works, but it should show how intervals can be used in evaluating functions.  In particular, it is clear that the accuracy is the opposite of that demonstrated in other answers here.
