# Density function of a mass?

For the definition of mass, in the case of 2 dimensions

$$M=\iint_{R}\rho (x,y)dydx$$

is it possible to find the density function $\rho$? If not, is it possible to construct this density function $\rho$ from a piecewise graph? For example, specifically the area enclosed by $0 \leq b-mx \leq b, y \geq 0, x \geq 0$. I know the specific result using a density function of variable x only, using $f(x)=b-mx, g(x)=0$ which is $M=b^2/2m$, i'm just wondering if the result $M$ will be different using a function of x and y instead and how it will be constructed since this approach was never covered in my calculus class.

Maybe a more direct question would be, is it possible to make a density function $\rho(x,y)$ from

$$\rho=\begin{cases} & 0 \leq b-mx \leq b \\ & x \geq 0 \\ & y \geq 0 \end{cases}$$ ?

No. There are infinitely many density functions that would give you the exact same value $M$ for that $R$. So you cannot determine which density function was used just from the knowledge of $M$ and $R$. This is fairly easy to see if you think about it physically: For a given distribution of mass, you could simply move some of the mass from one region inside the area to another region inside the area. The total mass $M$ would not change. The area $R$ would not change, but the density would go down in the region the mass was removed from, and up in the region where it was added. Since there are no restrictions on how this mass might be moved around, there are infinitely many possibilities, each of which produces a different density function.
As for making a density function, the only mathematical requirements are that $\rho$ be defined on all of $R$ and that it has finite integral there. If we are actually talking about mass density, then there is also a physical requirement that $\rho \ge 0$ everywhere. But there are other densities for which this is not required (e.g., charge density).
So for example, if $R = \{(x,y)\mid 0\le x \le 1, 0 \le y \le 1\}$ is the unit square, we find that $$M = \iint_R 1\, dA = 1\\M = \iint_R 2x\, dA = 1\\M = \iint_R 4xy\, dA = 1$$ But $$M = \iint_R 4xy^2\, dA = \frac 23$$