# Revision history [back]

There is a simpification possible. Instead of expanding the expression (which makes for a nice Pynac benchmark) we transform the equation into a fraction and get the numerator:

....
sage: g = a - a*t + b*t
sage: h = c - c*t + d*t
sage: u = p - g
sage: v = h - g
sage: eq = L^2 == sqr(u) - sqr((u.dot_product(v)/sqr(v)) * v)
sage: rhs = eq.rhs()
sage: num = (rhs.rational_simplify()-L^2).numerator()
sage: solve(num, t)


This is much smaller but unfortunately still takes forever to solve.

There is a simpification possible. Instead of expanding the expression (which makes for a nice Pynac benchmark) we transform the equation into a fraction and get the numerator:

....
sage: g = a - a*t + b*t
sage: h = c - c*t + d*t
sage: u = p - g
sage: v = h - g
sage: eq = L^2 == sqr(u) - sqr((u.dot_product(v)/sqr(v)) * v)
sage: rhs = eq.rhs()
sage: num = (rhs.rational_simplify()-L^2).numerator()
sage: solve(num, t)


This is much smaller but unfortunately still takes forever to solve.solve. Using collect and coefficient you can let Sage show you the coefficient of t^0, t, t^2, t^3, and t^4 to get an idea of what's involved and which equations determine the solution process of the quartic. For example this is the constant coefficient:

sage: num.coefficient(t,0)
-L^2*ax^2 - L^2*ay^2 + 2*L^2*ax*cx - L^2*cx^2 + ay^2*cx^2 + 2*L^2*ay*cy - 2*ax*ay*cx*cy - L^2*cy^2 + ax^2*cy^2 - 2*ay^2*cx*px + 2*ax*ay*cy*px + 2*ay*cx*cy*px - 2*ax*cy^2*px + ay^2*px^2 - 2*ay*cy*px^2 + cy^2*px^2 + 2*ax*ay*cx*py - 2*ay*cx^2*py - 2*ax^2*cy*py + 2*ax*cx*cy*py - 2*ax*ay*px*py + 2*ay*cx*px*py + 2*ax*cy*px*py - 2*cx*cy*px*py + ax^2*py^2 - 2*ax*cx*py^2 + cx^2*py^2


There is a simpification possible. Instead of expanding the expression (which makes for a nice Pynac benchmark) we transform the equation into a fraction and get the numerator:

....
sage: g = a - a*t + b*t
sage: h = c - c*t + d*t
sage: u = p - g
sage: v = h - g
sage: eq = L^2 == sqr(u) - sqr((u.dot_product(v)/sqr(v)) * v)
sage: rhs = eq.rhs()
sage: num = (rhs.rational_simplify()-L^2).numerator()
sage: solve(num, t)


This is much smaller but unfortunately still takes forever to solve. Using collect and coefficient you can let Sage show you the coefficient of t^0, t, t^2, t^3, and t^4 to get an idea of what's involved and which equations determine the solution process of the quartic. For example this is the constant coefficient:

sage: num.coefficient(t,0)
-L^2*ax^2 - L^2*ay^2 + 2*L^2*ax*cx - L^2*cx^2 + ay^2*cx^2 + 2*L^2*ay*cy - 2*ax*ay*cx*cy - L^2*cy^2 + ax^2*cy^2 - 2*ay^2*cx*px + 2*ax*ay*cy*px + 2*ay*cx*cy*px - 2*ax*cy^2*px + ay^2*px^2 - 2*ay*cy*px^2 + cy^2*px^2 + 2*ax*ay*cx*py - 2*ay*cx^2*py - 2*ax^2*cy*py + 2*ax*cx*cy*py - 2*ax*ay*px*py + 2*ay*cx*px*py + 2*ax*cy*px*py - 2*cx*cy*px*py + ax^2*py^2 - 2*ax*cx*py^2 + cx^2*py^2


You could also get from Sage the general solution to the quartic via:

sage: (a,b,c,d,e)  = var('a,b,c,d,e')
sage: sol = solve(a*x^4+b*x^3+c*x^2+d*x+e,x)


This returns a vector of 4 solutions. You could then simply substitute your coefficients for a,b,c,d,e in one of the solutions:

sage: sol1 = sol
sage: sol1 = sol1.subs(e==num.coefficient(t,0)).subs(d==num.coefficient(t,1)).subs(c==num.coefficient(t,2)).subs(b==num.coefficient(t,3)).subs(a==num.coefficient(t,4))
sage: len(str(ex1))
497783


This solution however is still too big to handle. It needs 500 pages to print! Simplifying is out of the question.

There is a simpification possible. Instead of expanding the expression (which makes for a nice Pynac benchmark) we transform the equation into a fraction and get the numerator:

....
sage: g = a - a*t + b*t
sage: h = c - c*t + d*t
sage: u = p - g
sage: v = h - g
sage: eq = L^2 == sqr(u) - sqr((u.dot_product(v)/sqr(v)) * v)
sage: rhs = eq.rhs()
sage: num = (rhs.rational_simplify()-L^2).numerator()
sage: solve(num, t)


This is much smaller but unfortunately still takes forever to solve. Using collect and coefficient you can let Sage show you the coefficient of t^0, t, t^2, t^3, and t^4 to get an idea of what's involved and which equations determine the solution process of the quartic. For example this is the constant coefficient:

sage: num.coefficient(t,0)
-L^2*ax^2 - L^2*ay^2 + 2*L^2*ax*cx - L^2*cx^2 + ay^2*cx^2 + 2*L^2*ay*cy - 2*ax*ay*cx*cy - L^2*cy^2 + ax^2*cy^2 - 2*ay^2*cx*px + 2*ax*ay*cy*px + 2*ay*cx*cy*px - 2*ax*cy^2*px + ay^2*px^2 - 2*ay*cy*px^2 + cy^2*px^2 + 2*ax*ay*cx*py - 2*ay*cx^2*py - 2*ax^2*cy*py + 2*ax*cx*cy*py - 2*ax*ay*px*py + 2*ay*cx*px*py + 2*ax*cy*px*py - 2*cx*cy*px*py + ax^2*py^2 - 2*ax*cx*py^2 + cx^2*py^2


You could also get from Sage the general solution to the quartic via:

sage: (a,b,c,d,e)  = var('a,b,c,d,e')
sage: sol = solve(a*x^4+b*x^3+c*x^2+d*x+e,x)


This returns a vector of 4 solutions. You could then simply substitute your coefficients for a,b,c,d,e in one of the solutions:

sage: sol1 = sol
sage: sol1 = sol1.subs(e==num.coefficient(t,0)).subs(d==num.coefficient(t,1)).subs(c==num.coefficient(t,2)).subs(b==num.coefficient(t,3)).subs(a==num.coefficient(t,4))
sage: len(str(ex1))
len(str(sol1))
497783


This solution however is still too big to handle. It needs 500 pages to print! Simplifying is out of the question.