Interesting question. Here's an alternative approach using a symmetrical relationship involving launch and terminal velocities that I found, which helps simplify the solution. $\hspace{4cm}$[![enter image description here][1]][1] Let $u,v,w$ be velocities at launch, at the first wall and at the second wall respectively. Let $k$ be the horizontal distance between the two walls. Hence $k^2=L^2-(h_2-h_1)^2$. Squaring equation $(1)$ [here](https://math.stackexchange.com/q/2660468/168053) (${v^*}{w^*}=gk$) for minimum velocities (omitting $^*$ for minimum velocities for clarity of notation) and using the standard energy conservation/kinematics formula $V^2=U^2+2AS$ gives $$\begin{align} v^2w^2&=g^2k^2\\ (u^2-2gh_1)(u^2-2gh_2)&=g^2 \big(L^2-(h_2-h_1)^2\big)\\ u^4-2g(h_1+h_2)u^2+4gh_1h_2+g^2(h_2-h_1)^2&=g^2L^2\\ u^4-2g(h_1+h_2)u^2+g^2(h_1+h_2)^2&=g^2L^2\\ \big(u^2-g(h_1+h_2)\big)^2&=g^2L^2\\ u^2-g(h_1+h_2)&=gL\\ \text{Minimum launch velocity, }\;\;\;\;\;\;\color{red}u&\color{red}{=\sqrt{g(h_1+h_2+L)}} \end{align}$$ No trigonometric ratios or calculus. ___ Alternatively, using the results [here](https://math.stackexchange.com/a/2687554/168053), and omitting $^*$ for minimum velocities for clarity of notation, $${v}^2=g(L+H-h)\qquad $$ Using conservation of energy, $$\begin{align} {u}^2 &={v}^2+2gh\\ &=g(L+H-h)+2gh\\ &=g(L+H+h)\\ &=g(L+h_1+h_2)\\ \color{red}u&\color{red}{=\sqrt{g(h_1+h_2+L)}}\end{align}$$ ___ **ALTERNATIVE METHOD** **(Added 9 March 2021)** Let $p = h_2-h_1$. Energy: $$v^2-w^2=2gp\tag {1}$$ Minimal energy (see Note $1$): $$v^2+w^2=2gL \tag {2}$$ $[(1)+(2)] \div 2:$ $$v^2=g(p+L)\tag {3}$$ Also, $$u^2-v^2=2gh_1 \tag{4}$$ $(3)+(4):$ $$\begin{align} u^2&=g(p+L+2h)\\ &= g(h_1+h_2+L)\\ \color{red}{u}&\color{red}{=\sqrt{g(h_1+h_2+L)}}\end{align}$$ ___ **Note 1** Let the horizontal and vertical components of $v$ and $w$ be indicated with subscripts $1$ and $2$ respectively. Note that $v_1=w_1$. Vertical component: $$w_2 = v_2 - gt \Longrightarrow t=\dfrac {v_2+w_2}g$$ Horizontal component: $$k=v_1t=w_1 t =\frac {v_1+w_1}2 t=\frac {(v_1+w_2)(v_2+w_2)}{2g}$$ Pythagoras: $$\begin{align} L^2 &=p^2+k^2\\ &=\left(\frac {v^2-w^2}{2g}\right)^2+\left(\frac {(v_1+w_1)(v_2+w_2)}{2g}\right)^2\\ 4g^2L^2 &=(v^2-w^2)^2+[(v_1+w_1)(v_2+w_2)]^2\\ &=(v^2-w^2)^2+4v^2w^2-4(v_1w_1-v_2w_2)^2 &&(*)\\ &=(v^2+w^2)^2-4(v_1 w_1 - v_2 w_2)^2\\ &\le (v^2+w^2)^2 \end{align}$$ Hence, for minimum energy, $$v^2+w^2 = 2gL.$$ ___ $(*)$ $$\begin{align} [(v_1+w_1)(v_2+w_2)]^2 &=(v_1 v_2+w_1 w_2+w_1 v_2+v_1 w_2)^2\\ &=(2(v_1 w_2+v_2 w_1))^2&&(v_1=w_1)\\ &=4(v_1^2 w_2^2+v_2^2 w_1^2 +2v_1v_2w_1w_2)\\ &=4[(v_1^2+v_2^2)(w_1^2+w_2^2)-v_1^2 w_1^2-v_2^2 w_2^2+2v_1v_2w_1w_2\\ &=4v^2w^2-4(v_1 w_1 - v_2 w_2)^2\end{align}$$ [1]: https://i.sstatic.net/QDalSm.jpg