Let's say we're launching a projectile and we want it to max out at a height of .5g, which, if given Earth, comes to about 9,000 km. (In this, I'm using g as the gravity at the surface, not as the gravity experienced by the object.) Now, I fully understand how to launch a projectile to 9000 km given a constant gravity. In this, $h = v^2/2g$, and assuming that h = 9,000 km and that g = 9.8 m/s, we get 13,300 m/s.
However, especially as the projectile approaches this height, the force of gravity experienced by this object is not constant. Because of this, 13,300 m/s is greater than escape velocity, so it would have no max height. I'm at a loss on how to find the velocity of the projectile. Critically, the height depends on the velocity and the time. The velocity depends on the gravity and the time. The gravity depends on the height. As such, there's a circle of sorts, where I can't seem to figure out one without knowing the others, and since I don't know the others, I can't make any headway.
I figured one could use recursion to solve this - setting up timepoints, using the height from the previous timepoint, calculating the gravity, then using this gravity to figure out how much velocity will decrease by the next timepoint, and using all of this to figure out the next height - but this "solution" only offers an approximation, is inaccurate, and computationally intensive. A program would be required, and I was hoping that the results could be gleaned with a calculator rather than a computer program.
Feel free to ignore air resistance and assume starting height is 0. If required for the solution or an example, feel free to assume we're talking about Earth.
Given these parameters, what would be the formula for the initial vertical velocity required to reach a certain height, given that such a height is high enough that the force of gravity changes?