# Find projectile Initial Velocity given max range, gravity, and height

So I've been trying to work out how to reverse a formula I found and worked on. I have thoroughly tested these formulas at desmos.com/calculator and have a realistic physics simulation playing in real-time over and over. It works EXACTLY as I need it to, however, I noticed that given an Initial Velocity, Gravity, and Launch Height, I can calculate the maximum distance of the projectile by first finding the angle (theta) that produces the longest shot from height y0 using this formula , then using this formula to calculate the maximum range of the projectile.

I was wondering how I could reverse this so that given a Range, Gravity, and Height, you can find the Initial Velocity needed to reach it. I tried for about 3 hours to do it myself, manipulating the formulas and embedding the angle formula into the distance one and then simplifying it a LOT, but got stuck right at the end.