Center of Mass and Centroid Find the centroid of the region lying between the graphs of the functions $y=\sin x$ and $y=\cos x$ over the interval $[0,\frac\pi4]$.
I approached the question like this:


*

*Find the $M$
$$M = \int_0^{\tfrac\pi4}(\sin x-\cos x)\,dx = 1-\sqrt2$$

*Find the $M$ of $y$
$$M_y = \int_0^{\tfrac\pi4}x(\sin x-\cos x)\,dx = 1-\frac{\pi}{2\sqrt2}$$

*Find the $M$ of $x$
$$M_x = \int_0^{\tfrac\pi4}\frac12(\sin x-\cos x)^2\,dx = \frac18(\pi-2)$$

*The center of mass at $y = M_x/M$ and the center of mass at $x = M_y/M$
$$y = \frac{\dfrac18(\pi-2)}{1-\sqrt2},x = \frac{1-\dfrac{\pi}{2\sqrt2}}{1-\sqrt2}$$


I appreciate the help! Thank you for the comments. 
 A: See the picture below.

As you can see, $\cos x$ is above $\sin x$ or $\cos x>\sin x$ for $\left[0,\dfrac\pi4\right]$. Therefore
$$
\begin{align}
M&=\int_0^\frac\pi4(\cos x-\sin x)\ dx=\sqrt{2}-1,\\\\
M_y&=\int_0^\frac\pi4x(\cos x-\sin x)\ dx=\frac14(\sqrt{2}\pi-4),\quad\Rightarrow\quad\text{use IBP}
\end{align}
$$
and
$$
\begin{align}
M_x&=\frac12\int_0^\frac\pi4(\cos x+\sin x)(\cos x-\sin x)\ dx\\
&=\frac12\int_0^\frac\pi4(\cos^2 x-\sin^2 x)\ dx\\
&=\frac12\int_0^\frac\pi4\cos2x\ dx\\
&=\frac14.
\end{align}
$$
I think you can handle it from here. I hope this helps.
A: As a reference. The centroid $(x_c,y_c)$ of a region bounded by $f(x)$ and $g(x)$ and with $x\in [a,b]$ is defined as
$$
x_c = \frac{1}{A} \int_a^b x[f(x)-g(x)]dx
$$
and
$$
y_c = \frac{1}{A} \int_a^b x[f(x)-g(x)][f(x)+g(x)]/2dx
$$
where $A$ is the area of the region... Reference: http://en.wikipedia.org/wiki/Centroid
So you need to calculate the two integrals to get the centroid using your function.
as @Andre_Nicolas has said, in the region $\cos(x) > \sin(x)$.
