Explanation for the formula for the centroid $\bar{x}$ First, can someone provide a simple explanation for the $\bar{x}$ formula: $$\frac{\iint xdA}{area}$$ My understanding of the formula is as follows: we let $z=x$, calculate the volume, and divide by the area to find $\bar{z}$, which is the same as $\bar{x}$.
Although I provided an explanation, I honestly still don't totally understand how that formula works; my teacher just assumed we knew it and didn't cover it. Unfortunately, most the websites I looked at just stated the formula or spent a lot of time explaining torque, moment, etc. An intuitive explanation or one that involved Riemann sums would be immensely helpful.
Second, I wanted to test this formula out with this example: $$\frac{\int_0^6 \int_0^{-(x/6)+1} xdydx}{3} = 2$$
But I didn't want to just use this formula: I wanted to try to find the $x$ for which the volumes on "either side" of this $x$ value are the same. Quickly, I discovered that $$\int_0^3 \int_0^{-(x/6)+1} xdydx = \int_3^6 \int_0^{-(x/6)+1} xdydx$$
so $x=3$. But then shouldn't that mean $\bar{x} = 3$ because the volume on either side is the same? Or is this nonsense?
Most likely, it's nonsense, and I think it's due to me not totally understanding the $\bar{x}$ formula.
 A: Mass
Imagine a lamina with constant density, $\rho$. The mass $m$ of the lamina and the area $A$ occupied by the lamina are in equal proportion. $1/4$ of the lamina has $1/4$ of the mass of the lamina, and so on. Now, what happens when the density isn't constant? This is what calculus was built for.
Say the density changes from point to point within a certain lamina. We can say that at a position $(x,y)$, the density $\rho(x,y)$ can be expressed as
$$\rho(x,y)=\frac{dm}{dA}$$
Now, to find the total mass of the object, we can integrate density with respect to volume:
$$dm = \rho(x,y) \  dA$$
$$m= \iint_R \rho(x,y) \ dA$$
So now that we have mass covered, let us define moments.
Moments
Say I give you a bat and a kettlebell. You're going to hold the bat horizontally and I will hang the kettlebell on different parts of the bat. In other words, I'm going to change the mass distribution of the system (bat and kettlebell) several times. You will find that the closer I hang the kettlebell to where you're holding, the easier the bat is to move. Mathematically speaking, suppose your hands are located at the origin. When I hang the kettlebell closer to your hands, the center of mass of the system moves closer to the origin. When I hang it further away from your hands, the center of mass moves farther from the origin. We turn the concept of how easily the bat moves into the idea of a moment.
We know that the further the kettlebell is from your hands, the harder the bat is to move. This means that moments are proportional to distance from the origin. Moments are proportional to mass, too: if I give you a $10$ kg kettlebell versus a $20$ kg kettlebell, you will undoubtedly notice a difference.
In 2D space, we use the $x$ and $y$ axes, so we will have moments relative to the $x$ axis and the $y$ axis. In other words, we will be rotating the bat around the two axes. Given the empirical evidence we have discussed, we can define the moments about the $x$ and $y$ axes as
$$M_x = m_1 y_1+m_2 y_2+...+m_n y_n = \sum_{i=1}^{n} m_i y_i$$
$$M_y = m_1 x_1 + m_2 x_2 + ... + m_n x_n = \sum_{i=1}^{n} m_i x_i$$
Now, the problem becomes complicated when instead of macroscopic kettlebells, you have microscopic changes in mass from point to point. Our friend calculus will be helpful here. Each piece of mass will be tiny, so our moments will become
$$M_x = \lim_{n \to \infty} y_1 \Delta m + y_2 \Delta m+...+ y_n \Delta m = \lim_{n \to \infty} \sum_{i=1}^{n} y_i \Delta m$$
$$M_y = \lim_{n \to \infty} x_1 \Delta m + x_2 \Delta m+...+ x_n \Delta m = \lim_{n \to \infty} \sum_{i=1}^{n} x_i \Delta m$$
Though we know that $\Delta m$ is just the density, $\rho (x,y)$, times the tiny piece of area $\Delta A$, so we now have
$$M_x = \lim_{n \to \infty} \sum_{i=1}^{n} y_i \Delta m = \lim_{n \to \infty} \sum_{i=1}^{n} y_i \rho (x,y) \Delta A = \iint_R y \rho (x,y) \ dA$$
$$M_y = \lim_{n \to \infty} \sum_{i=1}^{n} x_i \Delta m = \lim_{n \to \infty} \sum_{i=1}^{n} x_i \rho (x,y) \Delta A = = \iint_R x \rho (x,y) \ dA$$
Center of Mass
To find center of mass on any axis, we simply divide the moment about the opposing axis by the total mass. This means that
$$\overline{x} = \frac{M_y}{m} = \frac{\iint_R x \rho (x,y) \ dA}{\iint_R \rho(x,y) \ dA}$$
$$\overline{y} = \frac{M_x}{m} = \frac{\iint_R y \rho (x,y) \ dA}{\iint_R \rho(x,y) \ dA}$$
Hopefully this helps aid your understanding. I'm not too good with Riemann sums so I may need to edit this answer, but I think this should give you what you need.
A: A good place to start is working out the $x$-coordinate of the center of mass, $\bar{x}$, for a collection of point masses at various locations. Let's say we have points $1,\ldots,n$ with masses $m_1,\ldots,m_n$ and $x$-coordinates $x_1,\ldots,x_n$. Are you okay with the formula for $\bar{x}$ being the following?
$$\bar{x} = \frac{\sum_{i=1}^n m_i x_i}{\sum_{i = 1}^n m_i}$$
This is called, appropriately, a weighted average. I find the best way to see this is to work out a concrete example and treat a point mass of mass 2 as actually two point masses of mass 1 at the same location, so the numerator is just adding up the $x$ coordinates with appropriate multiplicity and the denominator is the overall number of point masses of mass 1.
Now go back to your problem of finding the center of mass of a continuous area. Imagine splitting your area up into a whole bunch of tiny squares. You want to add up over all those tiny squares their $x$-coordinates times their mass ($x \cdot \delta \cdot dA$), where $\delta$ is the density, which we'll assume to be constant (if the density is heavier on one side this will move the center of mass). You then want to divide by the total mass, which is just $\delta \cdot \text{area}$. The $\delta$s then cancel from your formula, to give you:
$$\frac{\iint x dA}{\text{area}}$$
Your concrete example is almost correct. We want to find some line $x = a$ such that the mass on one side "pulls" on the center as much as the mass on the other side. The amount that each point "pulls" on the center depends on its distance from the center: points further away "pull" harder. Since the distance from a point to the center is $x-a$, you want to solve the equation:
$$\int_0^a \int_0^{-(x/6)+1} (a-x) \; dydx = \int_a^6 \int_0^{-(x/6)+1} (x-a) \;dy dx$$
