Centroid formula ($\bar y$) integral - why difference of squares, rather than squared difference? When finding the $y$-coordinate of a centroid, for $f$ as a function of $x$, I understand the formula:
$\bar y = \frac12 \int f(x)^2 dx$      when the lower function is $y=0$
What I don't understand is why, for upper function $f= f(x)$ and lower function $g = g(x)$
$\bar y = \frac12 \int (f(x)^2 - g(x)^2) dx$
I would have expected 
$y-bar = \frac12 \int (f(x)-g(x))^2 dx$
In other words, I would have expected $f-g$ to be subtracted first, then squaring, rather than squaring first, then subtracting.
 A: I tend to think of these thing in terms of multivariate calculus and double integration.
$\bar y = \displaystyle\frac {\iint y\ dy\ dx}{\iint \ dy\ dx} = \frac {\int \frac 12 y^2 dx}{\int y\ dx}\\
\bar x = \displaystyle\frac {\iint x\ dy\ dx}{\iint \ dy\ dx} = \frac {\int xy\ dx}{\int y\ dx}$
Looking more closely at $\bar y$ bounded above and below by $f(x)$ and $g(x)$
respectively.
$\displaystyle\iint_{g(x)}^{f(x)} y \ dy \ dx = \int \frac 12 y^2|_{g(x)}^{f(x)}\ dx = \frac 12 \int (f(x))^2 - (g(x))^2\ dx$
But you probably haven't learned double integration yet....
The next thing I can say is that there is a certain parallel between these formula and the formula for volume of integration.
Revolution around the x axis (via washers)
$\displaystyle\pi \int f(x)^2 - g(x)^2\ dx $
Revolution around the y axis (via shells)
$\displaystyle2\pi \int x(f(x) - g(x))\ dx $
They are similar integrals to what you use for the centroid.  The difference is a factor of $2\pi$ and a factor of the area of the region.  
Pappus' theorem ties these two concepts together.  The volume of a solid is of revolution is the area of the cross section times the distance that the centroid travels.
A: Note that for each small strip dx we need to evaluate Area $\times$ Centroid y-coordinate that is
$$(f-g)dx \cdot \frac12(f+g)=\frac12(f^2-g^2)dx$$
note also that the centroid y coordinate is given by
$$\bar y=\frac{\frac12\int(f^2-g^2)dx}{\int (f-g) dx}$$
