# Computing a point of refraction

Oddball question: say I want to travel from $(a, b)$ where $b > 0$ to $(c, d)$ where $d < 0$ using the shortest path, where I can travel at velocity $v_1$ in the upper half-plane and at velocity $v_2$ in the lower half-plane. (E.g., a light ray would take this path.) Where should I cross the $x$ axis? I want an explicit formula in terms of $a$, $b$, $c$, $d$, $v_1$ and $v_2$.

On the surface this is a "stupid calculus question" (take the derivative and set to zero) but the calculus approach led me to the fourth-degree equation

$$V_1^2((x−c)^2 +d^2)(x−a)^2 =V_2^2((x−a)^2 +b^2)(x−c)^2$$

where $V_1 = 1/v_1$, $V_2 = 1/v_2$. (Seems to be more convenient to work with the inverse velocities, $V_1$ and $V_2$ than with $v_1$ and $v_2$.) A fourth-degree equation can theoretically be solved but I didn't have the heart to do it... I'm hoping that either: (a) someone has already done it; (b) there's a simplification that I'm overlooking; or (c) someone has a computer algebra package that will crunch through it and deliver a nice analytic solution.

Thanks!

PS: I'm aware that the above equation can be used to prove the law of refraction, but that's not what I want; I want to find the actual solution $x$.

-
I found myself trying to do this last year while preparing a 1st-year calculus lecture, and decided in the end that it would be too much for the class. I seem to remember that the answer is not too bad but does not look particularly nice (computer algebra isn't necessary IIRC) –  Yemon Choi Feb 26 '13 at 23:24
Yemon, any chance you could recall your solution? Did you solve the quartic by hand? –  John Steinberger Feb 27 '13 at 15:57
John: I think there was some simplification I found, but I was in a rush and I might well have made a mistake. Sadly I have long since lost the back of the envelope (no joke) which I was scribbling on. –  Yemon Choi Feb 27 '13 at 22:19

By scaling and translation, you can assume WLOG that $a=0$ and $c=1$. Also let $r = (V_2/V_1)^2$. You are left with a quartic polynomial in $x$ having $3$ independent parameters. Yes, a computer algebra system can solve it, but the result will be "wallpaper": a very complicated expression that I won't even try to write here. However, common-subexpression elimination can produce the result in several more reasonable-looking steps. This is using Maple's codegen:-optimize:

t1 = 3^(1/2)
t2 = r-1
t3 = 1/t2
t4 = b^2
t5 = t4+1
t7 = d^2
t9 = (r*t5-t7-1)^2
t12 = t5^2
t14 = r^2
t16 = t14*r*t12*t5
t17 = -t7-1
t18 = t4^2
t19 = 3*t18*t17
t20 = 21*t7
t23 = 3*t7
t26 = t7^2
t27 = 3*t26
t30 = t17^2
t31 = 3*t30
t34 = t30*t17
t38 = (t3*r*(t16+t14*(t19+t4*(t20-6)-t23-3)+r*(t4*(t27-t20+3)+t31)+t34))^(1/2)
t42 = 48*t7
t52 = (6*t38*t2*t1*b*d+t16+t14*(t19+t4*(t42-6)-t23-3)+r*(t4*(t27-t42+3)+t31)+t34)^(1/3)
t53 = 1/t52
t55 = r*t4
t60 = ((t53*t9+r+t52-2*t55+2*t7-1)*t3)^(1/2)
t63 = 4*t2^2
t64 = t2^2
t65 = 1/t64
t68 = t55-t7+r-1
t73 = t68^2
t92 = (1/2*t65*t63-4/3*t3*t68-1/3*t52*t3-1/3*t53*t3*t73+1/t60*t1*(-2*t2*t65*t68+4*t3*t55+1/2/t64*t63))^(1/2)
t96 = 1/6*t60*t1-1/2*t92+1/2