This types of problems are solved by observing projectile movements in $x$ and $y$ direction separately. In $x$ direction you have constant velocity movement
$$v_x = v_{x0} = v_0 \cos(\theta), \; (1)$$
$$x = v_{x0} t +x_0 = v_0 \cos(\theta) \; t +x_0, \; (2)$$
and in $y$ direction you have constant acceleration movement with negative acceleration $-g$
$$v_y = - g t + v_{y0} = - g t + v_0 \sin(\theta), \; (3)$$
$$y = - \frac{1}{2} g t^2 + v_{y0} t + y_0 = - \frac{1}{2} g t^2 + v_0 \sin(\theta) \; t + y_0. \; (4)$$
Your initial conditions are
$$x_0 = 0, \; y_0 \ne 0,$$
and final conditions (at moment $t=T$ projectile falls back on the ground) are
$$t = T, \; x = d, \; y = 0.$$
If you put initial and final conditions into equations (2) and (4) you end up with two equations and two unknowns $v_0, T$. By eliminating $T$ you get expression for $v_0$.
My calculations show that
$$v_0 = \frac{1}{\cos(\theta)}\sqrt{\frac{\frac{1}{2} g d^2}{d \tan(\theta)+y_0}}$$
which is I believe equal to your equation. Maybe your problem is that $d$ means displacement in direction $x$, while the total displacement is $\sqrt{d^2+y_0^2}$?
Best Answer
You can use the equation of trajectory for a projectile motion which is given as follows: $$y=xtan(\theta)+\frac{gx^2}{2u^2cos^2(\theta)}$$ Where you can take any launching or landing points by simply the $x$ and $y$ coordinates from the origin which is the launching point. Suppose you launched from a tower then simply add the height of the tower to the equation so it becomes something like : $$y=xtan(\theta)+\frac{gx^2}{2u^2cos^2(\theta)}+h$$ Here $\theta$ is the angle of launch, while $u$ is the speed of the launch. Note: Only take parts of the curve from $x=0$ Ofcourse you can calculate in others ways too like finding the horizontal displacement or the vertical displacement using the equations of motion if you know the information you’ve stated.