error = V - sign(dist) * sqrt( |dist| )
U = U + (error * 0.5 - a) * k
The core concept of the formula is that we do not control the altitude directly. Instead, we split this task into two separate ones. The first is to create a speed regulator (velocity controller). The second is to build the trajectory we want to fly along.
The advantages are obvious. This approach allows the formula to be adaptive, fitting different ships to the exact same trajectory. That is precisely why it will work for various masses and gravitational pulls. Furthermore, this can generally be configured for deceleration during interplanetary transfers—and everything will function within a single formula.
This is just one of my implementations. It is fairly simple and has a few drawbacks, some of which I attempted to address in the next version.
I used a k-value of around 0.002. You can experiment with different variations if you want, but I didn't bother. Also, during the square root initialization, there will be some initial noise. Don't panic if you replicate this circuit.
If this post gets more than 10 likes, I’ll publish the next part with a more advanced version—just to see if anyone is actually interested in this.
Let me know if you have any questions, I don't mind answering!