STATUS: Draft
import numpy as np
import sympy as sp
import pickle
from IPython.display import HTML
import ipywidgets as widgets
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
mpl.rcParams['legend.fontsize'] = 10
import pandas as pd
import itertools
# function to print latex
def renderListToLatex(e):
latex_rendering = []
for i in range(len(e)):
latex_rendering.append("$$" + sp.latex(e[i]) + "$$<br/>")
return(HTML("".join(latex_rendering[0:])))
Create the needed variables
c_0, c_1, c_2, c_3, c_4, x, t, a_0, a_1, a_2, a_3, a_4, a_5, a_6, a_7, a_8, a_9, x_1, x_2, s_1, s_2 = sp.symbols('c_0, c_1, c_2, c_3, c_4, x, t, a_0, a_1, a_2, a_3, a_4, a_5, a_6, a_7, a_8, a_9, x_1, x_2, s_1, s_2')
Let g1 be an object from Solving Polynomial Equations (5).
with open('./SharedOutputs/SPE5.pickle', 'rb') as input:
importedFromSPE5 = pickle.load(input)
g1 = importedFromSPE5['cubicSolutionsAsPolynomial']
Introduction
So far cases up to a cubic degree have been examined. Conjecture 1 in Solving Polynomial Equations (5) describes the relationship between $c_0, c_1, c_2$ and $c_3$ and claimed that this relationship can explain the the value of the coefficent. Note that this has not explain the choice the sign of the term however but the sign can be explained by the following conjecture.
Conjecture 2
Any value of the coefficient can be generated by:
$$(-1)^{c + 1} \frac{(k - 1)!}{a!b!c!}$$where $a, b, c$ and $k$ are following values from any term in a solution for x in terms of $c_0, c_1, c_2$ and $c_3$:
$$\frac{c_0^a c_2^b c_3^c}{c_1^k}$$Test this on the available data. Let g8 be g7 as a polynomial
g1
def solutionInTermsOfCoefficientsOfGeneralCubic(g):
k = g[1]
a = g[2]
b = g[3]
c = g[4]
solution = ((-1)**(k + 1)) * (sp.factorial(k -1) / (sp.factorial(a) * sp.factorial(b) * sp.factorial(c) ) )
return(solution)
# needs checking of origina formula
# NOTE THE C AT THE THE FRONT IS THE C in teh new formula
[solutionInTermsOfCoefficientsOfGeneralCubic(list(g1.terms()[i][0])) for i in range(1, len(g1.terms()))]
[132, -330, 180, 42, -12, -84, 28, 14, -21, 3, 5, -5, 2, -1, 1, 1]
The quartic case
Goal: Check if this holds in the quartic case. Assume that any values above $t^8$ are 0
Let g1 be a general quartic equation
g1 = sp.Eq(c_0 + c_1 * x + c_2 * x**2 + c_3 * x **3 + c_4 * x **4, 0)
g1
Let g2 be a power series in $t$.
g2 = a_0 + a_1 * t + a_2*t**2 + a_3*t**3 + a_4*t**4 + a_5*t**5 + a_6*t**6 + a_7*t**7 + a_8*t**8
g2
Let g4 be a g3 with a subsitution of x for g1 and a substitution of $t$ for $c_0$.
g3 = g1.subs(x, g2)
g4 = g3.subs(c_0, t)
g4
Let g5 be the expanion of g4. Recall that $t^8 = 0$ and let g6 be g5 with a subsitution of $t^8 = 0$
g5 = g4.expand()
order = 9
coeffs = sp.Poly(g5, t).coeffs()
g6= sum(t**n * coeffs[-(n+1)] for n in range(order))
g6 = sp.Eq(g6, 0)
g6
Let g7 be the value of of g6 evaluated where $t=0$
g7 = g6.subs(t, 0)
Let g8 be the factorisation of g7
g8 = sp.factor(g7)
g8
Note there are multiple solutions to g8 and one of these is 0. Assume the case where $a_0 = 0$
g9 = sp.Poly(g6.subs(a_0, 0), t)
g9
Iteratively solve this for values of $a_0$ through $a_8$.
g10 = [sp.Eq(g9.coeffs()[i], 0) for i in range(len(g9.coeffs()))]
g10.append(sp.Eq(a_0, 0))
variables = [a_0, a_1, a_2, a_3, a_4, a_5, a_6, a_7, a_8]
g11 = sp.nonlinsolve(g10, variables)
interimSolutions = list(list(g11)[0])
g11 = [sp.Eq(interimSolutions[i], variables[i]) for i in range(len(interimSolutions))]
Visualise the results of solutions of $a_0$ through $a_8$
latex_rendering = []
for i in range(len(g11)):
latex_rendering.append("$$" + sp.latex(g11[i].simplify()) + "$$")
HTML("".join(latex_rendering[1:]))
Substitute values $a_0$ through $a_8$ back into general quartic
$$ \left(a_{0} + a_{1} t + a_{2} t^{2} + a_{3} t^{3} + a_{4} t^{4} + a_{5} t^{5} + a_{6} t^{6} + a_{7} t^{7} + a_{8} t^{8}\right) + c_{2} \left(a_{0} + a_{1} t + a_{2} t^{2} + a_{3} t^{3} + a_{4} t^{4} + a_{5} t^{5} + a_{6} t^{6} + a_{7} t^{7} + a_{8} t^{8}\right)^{2} + c_{3} \left(a_{0} + a_{1} t + a_{2} t^{2} + a_{3} t^{3} + a_{4} t^{4} + a_{5} t^{5} + a_{6} t^{6} + a_{7} t^{7} + a_{8} t^{8}\right)^{3} + c_{4} \left(a_{0} + a_{1} t + a_{2} t^{2} + a_{3} t^{3} + a_{4} t^{4} + a_{5} t^{5} + a_{6} t^{6} + a_{7} t^{7} + a_{8} t^{8}\right)^{4} + t = 0 $$g13 = g2
for i in range(len(g11)):
g13 = g13.subs(g11[i].rhs, g11[i].lhs)
Subsitute $c_0$ for t
g14 = g13.subs(t, c_0)
g14 = sp.expand(g14)
g14
Convert g14 into a Poly type and check that conjecture 2 holds.
g15 = sp.Poly(g14)
g15
Conjecture 3
The pattern still holds, note there is another variable, $c_4$. The conjecture can be extended to
$$(-1)^{c + 1} \frac{(k - 1)!}{a!b!c!d!}$$where $a, b, c, d$ and $k$ are following values from any term in a solution for x in terms of $c_0, c_1, c_2, c_3$ and $c_4$:
$$\frac{c_0^a c_2^b c_3^c c_4^d}{c_1^k}$$Create a function for this conjecture and test it against the data
def solutionInTermsOfCoefficientsOfGeneralQuartic(g):
k = g[0]
a = g[1]
b = g[2]
c = g[3]
d = g[4]
solution = (-(-1)**(k + 1)) * (sp.factorial(k -1) / (sp.factorial(a) * sp.factorial(b) * sp.factorial(c) * sp.factorial(d) ) )
return(solution)
print([solutionInTermsOfCoefficientsOfGeneralQuartic(list(g15.terms()[i][0])) for i in range(0, len(g15.terms()))])
[-429, 1287, -495, -990, -132, 495, 165, 330, -45, -45, -120, -180, -42, 72, 12, 84, -4, -28, -28, -14, 7, 21, -6, -3, -5, 5, -1, -2, 1, -1, -1]
Summary
The data still still holds. This means that for these values, these are solutions that can be generate and the terms in the original equations can be used to ascertain roots in these cases. The conjectures suggest a more general solution, related to larger power of t and larger powers of general polynomials
# Write data that will be used again
data = {'solutionForXForQuartic': g14,
'generalQuarticEquation':g1,
'xSubstitution': g2}
f = open('./SharedOutputs/SPE6.pickle', 'wb')
pickle.dump(data, f)
f.close()