Answer:
The gravitational force is

Step-by-step explanation:
The sketch describing this question is shown on the first uploaded image
from the sketch
represent a unit vector pointing outward (This is shown the distance and the direction of the object
Now the gravitational force of a object on the surface earth with mass m is
Mathematically represented as

Where
is the mass o the earth and
is the radius of the earth
The minus sign shows that it is acting in the negative x-axis
Making the acceleration due to gravity a subject of the formula we have

Considering when the distance of the object to the center of the earth is r
Note: Any mass of the earth that is outside the distance covered by radius r as shown in the diagram does not affect the gravitational force
The mass of the enclosed earth can be mathematically represented as

Where
is the mass density which is mathematically represented as

Now substituting these equation 3

Now substituting equation 5 into equation 1 to obtain the gravitational force as a function of distance r

From equation 2 we see that the
So substituting for g we have
