How to prove the centroid formula The coordinates of the centroid denoted as $(x_c,y_c)$ is given as $$x_c = \frac{\displaystyle \int_R x \, dy \, dx}{\displaystyle \int_R dy \, dx}$$ $$y_c = \frac{\displaystyle \int_R y \, dy \, dx}{\displaystyle \int_R dy \, dx}$$
but how can we get these?
 A: Suppose every region of the plane has a weight equal to its area.  Then the weight of $R$ is $\displaystyle \int_R dy\,dx.$
Think of $dy$ and $dx$ as infinitely small increments of $y$ and $x$, so that $dy\,dx$ is the infinitely small weight of an infinitely small rectangle.
Imagine that the $y$-axis is a fixed fulcrum.  Then the torque exerted on the plane by the weight of the infinitely small rectangle is the infinitely small weight times the distance from the $y$-axis to the rectangle.  That distance is $x$.  So the infinitely small torque is $x\,dy\,dx.$  The total torque exerted by the whole region is therefore
$$
\text{torque} = \int_R x\,dy\,dx.
$$
The centroid should be so located that if the total weight of $R$ rests at the centroid, then the total torque would be the same.  We have
\begin{align}
\text{torque}  & = (\text{total weight of }R)\times(x\text{-coordinate of the centroid}) \\[10pt]
& = \int_R 1 \,dy\,dx \times(x\text{-coordinate of the centroid}). 
\end{align}
Now equate the two expressions for the torque and you get the $x$-coordinate of the centroid.
(This is an idea that goes back to Archimedes, almost 23 centuries ago, who used it to find that the center of gravity of a solid hemisphere) is $5/8$ of the way from the pole to the center of the sphere, and various similar propositions.  He explicitly used infinitesimals in his arguments, and stated explicitly that he regarded arguments relying on infinitesimals as falling short of complete proofs. If he had allowed that infinitesimals actually exist, then at least one of his arguments for the area of a region bounded by an arc of a parabola and a secant line would have shown only that the area differs by an infinitesimal from a certain amount, rather than that the area is that amount.  I don't think anyone before Archimedes wrote about centers of gravity, but tell me if I'm wrong about that.)
A: Note: There is already a perfectly good answer to the question working from a standard conceptual definition of the centroid (a point where all the mass can be collected without changing the total torque); my goal here is simply to show that this is equivalent to another standard conceptual definition.

There are various definitions of centroid. One of the definitions of the centroid of a region in a plane assumes that the region has a mass uniformly distributed over its area  -- you could think of it as a very thin plate of rigid material (sometimes called a lamina) cut to the shape of the given region --
and that this object has its balance point at the centroid $(x_c,y_c).$
This implies that you should be able to balance the lamina on a fulcrum made from the edge of a knife placed parallel to the $y$-axis along the line $x = x_c.$
In order to do this, you want each bit of mass on the right side of the fulcrum to be exactly balanced by a corresponding bit of mass on the left side, and vice versa, with no mass unaccounted for.
Two such masses balance if the magnitudes of their torques (weight times distance from the fulcrum) are the same, and since weight is proportional to mass, this gives us $$m_1 \lvert x_1 - x_c\rvert = m_2 \lvert x_2 - x_c\rvert$$ for masses $m_1$ and $m_2$ at $x$-coordinates $x_1 < x_c$ and $x_2 > x_c$ (one on the left of the fulcrum, the other on the right).
Taking the inequalities $x_1 < x_c$ and $x_2 > x_c$ into account, we have
$$ m_1 (x_1 - x_c) + m_2 (x_2 - x_c) = 0. $$
We have a similar sum for every other pair of corresponding masses,
so if we take all the corresponding bits together we have an overall sum
$$ \sum_i m_i (x_i - x_c) = 0. $$
Of course this sum is only exactly correct for a finite collection non-zero masses $m_i$ placed at a finite collection of $x$-coordinates $x_i$, but it is a Riemann sum of the actual formula that says the lamina balances on a knife edge placed along the line $x = x_c,$
$$ \iint_R (x - x_c) \, \mathrm dy \, \mathrm dx = 0, $$
where the integral is taken over the region $R$ in the $x,y$ plane occupied by the lamina and mass of each area element in that region is assumed to be equal to the area of the area element.
Observe that
\begin{align}
\iint_R (x - x_c) \, \mathrm dy \, \mathrm dx
 &= \iint_R x \,\mathrm dy\,\mathrm dx - \iint_R  x_c \,\mathrm dy\,\mathrm dx \\
 &= \iint_R x \,\mathrm dy\,\mathrm dx - x_c \iint_R \,\mathrm dy \,\mathrm dx ,
\end{align}
that is, if $x_c$ is the $x$-coordinate of the balance point it
satisfies $ \iint (x - x_c) \, \mathrm dy \, \mathrm dx = 0 $
and therefore
$$ \iint x \, \mathrm dy \, \mathrm dx =  x_c \iint_R \,\mathrm dy \,\mathrm dx
= (\text{area of the region $R$}) x_c, $$
which is equivalent to the statement
$$ \text{torque} = (\text{total weight of $R$})\times(\text{$x$-coordinate of the centroid}) $$
given in this answer.
And of course it is also equivalent to the formula in the question,
$$
x_c = \frac{\displaystyle\iint_R x \,\mathrm dy\,\mathrm dx}
{\displaystyle\iint_R \,\mathrm dy \,\mathrm dx}.
$$
