As shown in diagram,
Let’s consider a general point at a radial distance \(x\) away from the centre of the giant. Let the sphere’s radius here be \(r\).
By the definition of the bulk modulus, we have,
\[\beta = - { dP \over dV } V\]
\[\implies -dP = \beta {dV \over V}\]
Here, we need to find gravitational pressure, \(dP\)
\[dP = {dF \over A} = {I \rho dV \over A}\]
Here, \(I\) refers to the gravitational field due to the planet(within the planet), and \(\rho\) is its density.
\[dP = \frac{4}{3} \pi G \rho x \left( \rho \frac{dV}{A} \right)\]
\[\implies dP = \frac{4}{3} \pi G \rho^2 x \; dx\]
Substituting this expression back and integrating with limits,
\[\int_R^x \frac{4}{3} \pi G \rho^2 x \; dx = \beta \int_{r_0}^r \frac{ 4 \pi r^2 \; dr }{\frac{4}{3} \pi r^3}\]
This gives,
\[r = r_0 e^{ { 2\pi G \rho^2 (x^2 - R^2) \over 3 \beta } }\]
Note that, \(G \sim 10^{-11}\) and \(\beta \sim 10^{10}\) for most materials.
The order of the exponent’s argument is around \(10^{-21}\), which is clearly negligible.
Further,
Variation in density of the same body,
Say \(\tilde{\rho}_s\) is the initial density. Since mass is conserved here,
\[\tilde{\rho}_s V_i = \rho_s V_f\]
We get,
\[\rho_s = \tilde{\rho}_s e^{ { 2 \pi G \rho^2 (R^2 - x^2) \over \beta } }\]