MathOverflow is a question and answer site for professional mathematicians. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


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$.

share|cite|improve this question
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
up vote 1 down vote accepted

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

The final answer is t96.

share|cite|improve this answer
Hi Robert, thanks. I'm holding out a little longer before accepting your question in the hope that someone will come up with something a little simpler. Maybe someone could try Mathematica's version of this functionality and see who wins :) – John Steinberger Feb 28 '13 at 19:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.