In my calculus 2 course, we have been studying how to calculate the center of mass of a 1 dimensional "rod" with dimensions $[a,b]$ (so that the left end of the rod is at $x=a$ and the right end of the rod is at $x=b$). My instructor has taught us to calculate center of mass using the following formula:

$$\bar{x} = \frac{\int\_a^b{x\rho(x)dx}}{\int\_a^b{\rho(x)dx}}$$

Where $x=\bar{x}$ is the center of mass, and $\rho(x)$ is the density function. 

From what I understand, this formula essentially calculates the mean of the distribution of mass along the rod. However, I have developed a different equation to calculate center of mass: 

$$\int\_a^t{(t-x)\rho(x)dx}=\int\_t^b{(x-t)\rho(x)dx}$$

Where $x=t$ is the center of mass. 

This equation appears to calculate the median of the distribution of mass along the rod. 

Since the mean and the median are not always equal to each other, one of these methods is not always correct. I assume my instructor's method is correct, but- when calculating the center of mass- why would calculating the mean of the mass distribution be more advantageous than calculating the median of the mass distribution? 

Thanks in advance!