Finding Projectile Angle With Different Elevation When Velocity And Range Are Known I'm trying to derive a formula to find the angle $θ$ required to hit a target that may be higher or lower than the initial launch position.
My known variables are $g, v_0, y_0, y_f, x_0, x_f$ where:


*

*$θ$ is the initial launch angle and the variable being solved for

*$g$ is the gravity constant

*$v_0$ is the initial angular velocity

*$y_0$ is the initial launch elevation

*$y_f$ is the final landing position (in such cases where the projectile lands lower or higher than the launch position)

*$x_0$ is the initial horizontal launch displacement

*$x_f$ is the horizontal landing position, or range

*$t$ is the time in seconds during the path of motion


I started by converting the formula for x position into one for time ($x = x_0 + v_{x0}t$ becomes $t = \frac{x}{x_0 + v_{x0}}$
I set the equation for total flight time ($\frac{v_{y0}}{g} + \frac{\sqrt 2h}{g}$) equal to this equation, since $v_{xf} = v_{x0}$ and $x_f$ is known. Leading me to $\frac{x}{x_0 + v_{x0}} = \frac{v_{y0}}{g} + \frac{\sqrt 2h}{g}$
I took the equation for maximum height, $\frac{gt^2}{2}$ and substituted the expression for time into it, giving me $\frac{gx^2}{2x_0^2 + 4x_0v_{x0} + v_{x0}^2}$. Since $v_{y0}$ can be expressed in terms of $v_{x0}$, I also substituted that in ($v_{x0} = v_0\cdot cosθ$ and $v_{y0} = v_0\cdot sinθ$ so $v_{y0} = v_{x0}\cdot tanθ$.
From there I continued to simplify and rearrange until I ended up with $θ = cos^{-1}\frac{2gx^2}{v_0}$, however this doesn't give me the correct answer and this is my third attempt over the past several hours.
I've been using the following values in a standard trajectory formula that finds $x_f$ from $θ, v_0, y_0, x_0$:


*

*$g = 9.81 m/s$

*$θ = 70 degrees$

*$v_0 = 75 m/s$

*$y_0 = 3 m$

*$y_f = 0 m$

*$x_0 = 0 m$
When I plug these into a standard trajectory formula, I find that the range is 369.65957m, which I have been using for $x_f$. I expect to find $θ \approx 70$ when I solve for $θ$ using $v_0$ and $x_f$, but other formulas I have found on the web end up giving me ~45 or ~89 degrees.
Thanks for any help!
 A: Move the launch coordinates to $(0,0)$ by setting $x_f=x_f-x_0$, $y_f=y_f-y_0$ and $x_0=y_0=0$. 
We can then write the following equations for the projectile's $x$ and $y$ components: 
$$y= (v_0\sin \theta) t- \frac{1}{2}gt^2$$
$$x = (v_0\cos \theta) t$$
Let us see at what time $t_1$ the projectile is at the target $x$-coordinate, i.e when is $x=x_f$:
$$ t_1 = \frac{x_f}{v_0 \cos \theta}$$
Inserting $t_1$ into the equation for the $y$ component of the projectile, must give the height $y_f$ of the projectile at this time:
$$y_f= (v_0\sin \theta) \frac{x_f}{v_0 \cos \theta}- \frac{1}{2}g(\frac{x_f}{v_0 \cos \theta})^2 \tag{1}$$
Remembering that $$\frac{1}{\cos^2 \theta}=1+\tan^2 \theta$$ 
we can rearrange equation $1$ to become: $$gx_f^2\tan^2 \theta - 2v_0^2x_f \tan \theta + 2v_0^2y_f + gx_f^2 = 0$$
Solving this quadratic equation for $\tan \theta$ gives the formula in the Wiki link I gave in my comment above, i.e. $$\theta = \arctan \left( \frac{v_0^2 \pm \sqrt{v_0^4 - g(gx_f^2+2y_fv_0^2)}}{gx_f} \right)$$
