Search code examples
pythonpolynomial-mathsageequation-solving

Obtain only a single solution for System of Polynomials in Sage


I am trying to solve a system of polynomial equations obtained by comparing coefficients of different polynomials.

# Statement of Problem:
# We are attempting to find complex numbers a, b, c, d, e, J, u, v, r, s where
# ((a*x + c)^2)*(x^3 + (3K)*x + 2K) - ((b*x^2 + d*x + e)^2)     = a^2*(x - r)^2*(x - s)^3 and 
# ((a*x + c)^2)*(x^3 + (3K)*x + 2K)) - ((b*x^2 + d*x + e - 1)^2) = a^2*(x - u)*(x - v)^4


R.<x> = CC['x']
a, b, c, d, e, r, s, u, v, K = var('a, b, c, d, e, r, s, u, v, K')
y2 = x^3 + (3*K)*x + 2*K
q0 = ((a*x + c)^2)*(y2) - ((b*x^2 + d*x + e)^2)
p0 = (a^2)*((x-r)^2)*((x-s)^3)
t = (b^2 - 2*a*c)/a^2
Q0 = q0.expand()
P0 = p0.expand()
P0 = P0.substitute(s = ((t - 2*r)/3))

Relations0 = []
i = 0
while i < 6:
    Relations0.append(P0.coefficient(x, n = i) - Q0.coefficient(x, n = i))
    i = i+1 

q1 = ((a*x + c)^2)*(y2) - ((b*x^2 + d*x + e - 1)^2)
p1 = (a^2)*(x-u)*((x-v)^4)
Q1 = q1.expand()
P1 = p1.expand()
P1 = P1.substitute(u = t - 4*v)

Relations1 = []
i = 0
while i < 6:
    Relations1.append(P1.coefficient(x, n = i) - Q1.coefficient(x, n = i))
    i = i+1
Relations = Relations0 + Relations1

Telling Sage to solve the system of polynomials using solve(Relations, a,b,c,d,e,r,v,K) seems highly inefficient and has only led to Sage having its memory limit exceeded. Moreover, trying to reduce the number of equations and variables by solving for some of the variables is also inefficient and has not given any fruitful results. Since attempting to find all solutions has proven so difficult, is there any way to extract only a single solution?


Solution

  • Both equations have degree 5, which makes 12 identities. However, the degree 5 identities are identical and always satisfied for both equations. Thus you have effectively 10 or less equations for 10 variables.

    Divide by a^2, i.e., replace c, b, d, e by c/a, b/a, d/a, e/a and introduce f=1/a to reduce the degrees of the coefficient equations.

    Then the resulting coefficient equations for

    (x + c)^2*(x^3 + 3*K*x + 2*K) - (b*x^2 + d*x + e)^2  =  (x - r)^2*(x - s)^3;
    (x + c)^2*(x^3 + 3*K*x + 2*K) - (b*x^2 + d*x + e - f)^2  =  (x - u)*(x - v)^4;
    

    or on http://magma.maths.usyd.edu.au/calc/

    A<b, c, d, e, f, r, s, u, v, K> :=PolynomialRing(Rationals(),10,"glex");
    P<x> := PolynomialRing(A);
    
    eq1 := (x + c)^2*(x^3 + 3*K*x + 2*K) - (b*x^2 + d*x + e)^2  -  (x - r)^2*(x - s)^3;
    eq2 := (x + c)^2*(x^3 + 3*K*x + 2*K) - (b*x^2 + d*x + e - f)^2  -  (x - u)*(x - v)^4;
    
    I := ideal<A|Coefficients(eq1) cat Coefficients(eq2-eq1)>; I;
    

    giving

    Ideal of Polynomial ring of rank 10 over Rational Field
    Order: Graded Lexicographical
    Variables: b, c, d, e, f, r, s, u, v, K
    Basis:
    [
        r^2*s^3 + 2*c^2*K - e^2,
        -3*r^2*s^2 - 2*r*s^3 + 3*c^2*K + 4*c*K - 2*d*e,
        3*r^2*s + 6*r*s^2 + s^3 - 2*b*e + 6*c*K - d^2 + 2*K,
        -2*b*d + c^2 - r^2 - 6*r*s - 3*s^2 + 3*K,
        -b^2 + 2*c + 2*r + 3*s,
        -r^2*s^3 + u*v^4 + 2*e*f - f^2,
        3*r^2*s^2 + 2*r*s^3 - 4*u*v^3 - v^4 + 2*d*f,
        -3*r^2*s - 6*r*s^2 - s^3 + 6*u*v^2 + 4*v^3 + 2*b*f,
        r^2 + 6*r*s + 3*s^2 - 4*u*v - 6*v^2,
        -2*r - 3*s + u + 4*v
    ]
    

    have degrees 5,4,3,2,2,5,4,3,2,1 giving an upper bound of 28800 for the number of solutions. As the Groebner basis algorithms that are commonly used have a complexity bound of O(d^(n^2)) for the better algorithms, your runtime will be optimistically be characterized by the number 28800^10 (Bezout bound instead of d^n in (d^n)^n), which is rather large however small the constant. Even removing one variable for the linear equation will not change much in these estimates.

    Thus any symbolic solution will take a long time and result in univariate polynomials of rather high degrees as part of any triangular polynomial basis.