<s>[INST] Minimum value of $ \frac{((x-a)^2 + p )^{\frac 12}}{v_1} + \frac{( (x-b)^2 + q )^{\frac12}} {v_2}$ I need to calculate the minimum value of the expression 
$ y = \frac{((x-a)^2 + p )^{\frac 12}}{v_1} + \frac{( (x-b)^2 + q )^{\frac12}} {v_2}$
I'm calculating the first derivative , then calculting the corresponding value for $x$ . But the calculation is getting complex. 
Here $v_1 , v_2 , p$ and $q$ are positive integers greatest than $1$. I have also tried using $AM >= GM$ . but that too reduces finding maximum of a degree $4$ polynomial
 [/INST] It's derivation of Snell's Law from Fermat's Principle
Assume $a<b$,
\begin{align}
  T(x) &= \frac{\sqrt{(x-a)^2+p}}{v_1}+\frac{\sqrt{(x-b)^2+q}}{v_2} \\
  T'(x) &=\frac{x-a}{v_1 \sqrt{(x-a)^2+p}}-
  \frac{b-x}{v_2 \sqrt{(x-b)^2+q}} \\
  0 &= \frac{\sin \theta_{1}}{v_{1}}-\frac{\sin \theta_{2}}{v_{2}} \\
  s &= \sin \theta_{1} \\
  \sin \theta_{2}  &= \frac{v_{2} s}{v_{1}} \\
  b-a &= \sqrt{p} \tan \theta_{1}+\sqrt{q} \tan \theta_{2} \\
  b-a &=
  \frac{s\sqrt{p}}{\sqrt{1-s^{2}}}+
  \frac{v_{2} s\sqrt{q}}{\sqrt{v_{1}^{2}-v_{2}^2 s^2}} \tag{$\star$} \\
 T_{\min} &=
  \frac{\sqrt{p}}{v_{1}\cos \theta_{1}}+\frac{\sqrt{q}}
       {v_{2}\cos \theta_{2}} \\
 &= \frac{\sqrt{p}}{v_{1}\sqrt{1-s^{2}}}+
    \frac{v_{1} \sqrt{q}}{v_{2}\sqrt{v_{1}^{2}-v_{2}^2 s^2}}
\end{align}
We seldom calculate the exact value of minimal $T$ but condition for minimum instead.
See also the link here.
</s>