A square based pyramid on cube - methods for finding the centre of gravity. A uniform solid body is constructed using a square-based pyramid mounted on a cube. If each edge of the solid has length $l$ show that the centre of gravity of the body lies within the cube is, $\frac {11l}{(24 + 4√2)}$from the base of the pyramid.
Now workings so far. This is equating centre of mass with centre of gravity as the object is small compared to the earth.
Volume of cube = $l^3$, and of the pyramid = $\frac{√2l^3}{6}$, using the height of the pyramid as $\frac{l}{√2}$, from Pythagoras. If $O$ is at the base of the pyramid we can say that for the pyramid the height above $O$ is $\frac{l}{4√2}$, as the centre of gravity (centre of mass) is  $\frac{h}{4}$ above the base, and we are expecting the centre of gravity to be in the cube. The height below the base for the cube is $\frac{-l}{2}$.
Would it be better to have $O$ at the base of the cube? Is the centre of gravity for a pyramid 'always' $\frac{h}{4}$ from its base?
 A: Let $\rho$ be the mass density of solids then we have $$\text{mass of the cube}=(\text{density})\times (\text{volume of cube})$$$$m_1=\rho l^3$$ 
Taking center $O$ of the base of pyramid as the origin point & distance measured below the base is taken as negative & distance above the base is taken as positive.
The normal distance of the center of gravity of cube from the center $O$ of base of pyramid $$y_1=-\frac{l}{2}$$   
Similarly, $$\text{mass of the pyramid}=(\text{density})\times (\text{volume of pyramid})$$ $$=\rho\left(\frac{1}{3}(\text{area of base})\times (\text{vertical height})\right)$$
$$=\rho \left(\frac{1}{3}(l^2)\times \frac{l}{\sqrt 2}\right)$$ 
$$m_2=\frac{\rho l^3}{3\sqrt2 }$$ 
The normal distance of the center  of gravity of pyramid from the center $O$ of base $$y_2=\frac{1}{4}\left(\frac{l}{\sqrt 2}\right)=\frac{l}{4\sqrt 2}$$ 
 Hence, the normal distance of the center of gravity of combined solid (cube+pyramid) from the center $O$ of base of pyramid is given by the following formula
$$\color{blue}{y=\frac{m_1y_1+m_2y_2}{m_1+m_2}}$$
Setting the corresponding values, we get $$y=\frac{\rho l^3\left(-\frac{l}{2}\right)+\frac{\rho l^3}{4\sqrt2 }\left(\frac{l}{3\sqrt 2}\right)}{\rho l^3+\frac{\rho l^3}{3\sqrt2 }}$$ 
$$=-\color{}{\frac{11 l}{24+4\sqrt 2}}$$
Negative sign shows that the center of gravity is below the center $O$ of base of the pyramid i.e. it lies within the cube at a distance $\color{red}{\frac{11 l}{24+4\sqrt 2}}$ from the center $O$ of the base. 


*

*Center $O$ can be taken as the reference (origin) point anywhere as desired.

*Center of the gravity of the solid pyramid from the base is always at a normal distance $\frac{h}{4}$ from its base 
while, center of the gravity of the hollow pyramid from the base is always at a normal distance $\frac{h}{3}$ from its base 
