What’s going on here:
Distribute[(a - b)^2]
Output:a^2 + b^2
While Distribute[(a - b) (c - d)]
gives
a c - b c - a d + b d
Mathematica Version 9.0.1
What’s going on here:
Distribute[(a - b)^2]
Output:a^2 + b^2
While Distribute[(a - b) (c - d)]
gives
a c - b c - a d + b d
Mathematica Version 9.0.1
In[2]:= FullForm[(a - b)^2]
Out[2]= Power[Plus[a, Times[-1, b]], 2]
so the square operation is distributed over a and -b inside Plus.
For the desired result, try
In[4]:= Distribute[Unevaluated[(a - b) (a - b)]]
Out[4]= a^2 - 2 a b + b^2
see also ‘Possible Issues’ in the documentation of Distribute.
Thank you.
But in future I will use Expand instead of Distribute.
Best regards