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}$?
In two dimensions, Newton's second law can be written in vector form as
$$
\mathbf F_\mathrm{net} = m\mathbf a
$$
In this case, the net force is
$$
\mathbf F_\mathrm{net} = m\mathbf g - kv^2\frac{\mathbf v}{v} = m\mathbf g - kv\mathbf v
$$
so the equation of motion is
$$
m\mathbf a = m\mathbf g - kv\mathbf v
$$
In components, if we choose the positive $y$ direction to be vertical, and using $v = \sqrt{v_x^2 + v_y^2}$ as you point out, we obtain
$$
ma_x = -k\sqrt{v_x^2+v_y^2} v_x, \qquad ma_y = -mg-k\sqrt{v_x^2+v_y^2}v_y
$$
as you can see, these differential equations are coupled; the $x$ equation involves $v_y$ and the $y$-equation involves $v_x$ unlike the case in which there is no drag. You should be able to numerically solve these simultaneous equations pretty easily on Mathematica.
In particular, you can solve these equations by specifying the initial position $\mathbf x(0) = (x(0), y(0)$ and the initial velocity $\mathbf v(0) = (v_x(0), v_y(0)) = (v(0)\cos\theta, v(0)\sin\theta)$ where $\theta$ is the initial angle at which the projectile is launched.
Best Answer
Firstly, construct a reference frame and $y$ is upward. Secondly, list motion equation. $$m\ddot{x}=0$$ $$m\ddot{y}=-mg$$ Thirdly, solve motion equation. $$x(t)=v_0^xt+x_0$$ $$y(t)=-\frac{1}{2}gt^2+v_0^yt+y_0$$ in which $v_0^x,x_0,v_0^y,y_0$ are initial conditions at time $t=0$.