ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 31 May 2015 21:51:26 -0500Solving a quartic equationhttp://ask.sagemath.org/question/26993/solving-a-quartic-equation/ I'm attempting to rearrange an equation from an [answer on the Mathematics StackExchange](http://math.stackexchange.com/questions/1298722/find-parametric-line-between-two-2d-line-segments-that-is-an-exact-distance-from).
The answer given is this equation:
$$L^2 = (-ab(t)+p)^2-\left(\frac{(-ab(t)+p).(cd(t)-ab(t))}{(cd(t)-ab(t))^2}(cd(t)-ab(t))\right)^2$$
Where $a$, $b$, $c$, $d$, and $p$ are known 2D points, $L$ is a known length, and $t$ is an unknown scalar. $ab(t)$ indicates interpolation between $a$ and $b$.
I am interested in rearranging this to solve for $t$. Here's what I've tried in Sage:
<pre><code>def sqr(var): return var.dot_product(var)
var('ax bx cx dx px ay by cy dy py t L')
a = vector([ax, ay])
b = vector([bx, by])
c = vector([cx, cy])
d = vector([dx, dy])
p = vector([px, py])
g = a - a*t + b*t
h = c - c*t + d*t
u = p - g
v = h - g
eq = L^2 == sqr(u) - sqr((u.dot_product(v)/sqr(v)) * v)
eq.solve(t)
</pre></code>
At the `solve` step I have observed it to sit for quite a while without producing a result. Two questions:
1. Am I inputting the problem correctly?
2. Is there any way to know if this is likely to terminate in a reasonable time? I have no idea what the solver looks like under the hood, and wouldn't want to wait for some `O(n!)` calculation to terminate :)
nicholasbishopSun, 31 May 2015 21:51:26 -0500http://ask.sagemath.org/question/26993/