Solution (source code)

= Solution

Let
$$
A=\rho_c+\rho_m,
\qquad
b=\frac{\rho_m}{R_c},
\qquad
d=\frac{\rho_mR_c^3}{12}.
$$
The <enclosed mass> is
$$
m(r)=
\begin{cases}
\dfrac{4\pi}{3}\rho_cr^3,&0\leq r\leq R_c,\\
4\pi\left(\dfrac{Ar^3}{3}-\dfrac{br^4}{4}-d\right),&R_c\leq r\leq R_p.
\end{cases}
$$
This is continuous at the core boundary. <Hydrostatic equilibrium> gives $dP/dr=-Gm(r)\rho(r)/r^2$, with $P(R_p)=0$. Define
$$
F(r)=4\pi G\left(
\frac{A^2r^2}{6}
-\frac{7Abr^3}{36}
+\frac{b^2r^4}{16}
+bd\log(r/R_c)
+\frac{Ad}{r}
\right).
$$
Since $F'(r)=Gm(r)(A-br)/r^2$, the mantle pressure is
$$
\boxed{P(r)=F(R_p)-F(r),
\qquad R_c\leq r\leq R_p}.
$$
Inside the uniform core, the <shell theorem> gives $m(r)=4\pi\rho_cr^3/3$, so
$$
\boxed{
P(r)=F(R_p)-F(R_c)
+\frac{2\pi G\rho_c^2}{3}(R_c^2-r^2),
\qquad 0\leq r\leq R_c}.
$$