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:])))
Introduction
Conjecture 2 posited a general solution to one of the roots of a general cubic equation:
$$(-1)^{c + 1} \frac{(k - 1)!}{a!b!c!} \frac{c_0^a c_2^b c_3^c}{c_1^k}$$Conjecture 3 posted a general solution to one of the roots of a general quartic equation:
$$(-1)^{c + 1} \frac{(k - 1)!}{a!b!c!d!} \frac{c_0^a c_2^b c_3^c c_4^d}{c_1^k}$$Considered together, both of these conjectures 2 and 3 suggest obtaining a solution to the root of a general polynomial equation could be extended to higher degrees: In the case of the general quartic, a formula was
$$(-1)^{c + 1} \frac{(k - 1)!}{a!b!c!d!...} \frac{c_0^a c_2^b c_3^c c_4^d...}{c_1^k}$$Goal: Revisit the cubic case to gain a deeper understanding
Create 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 the solution of one of the roots of a general cubic polynomial, imported from Solving Polynomials (3).
with open('./SharedOutputs/SPE3.pickle', 'rb') as input:
imported_outputs_from_another_notebook = pickle.load(input)
g1 = imported_outputs_from_another_notebook['solutionOfGeneralCubicInTermsOfx']
g1 = sp.expand(g1.subs({t:c_0, a_0:0}))
g1
Recall the original form of the cubic equation: $ c_{1} x + c_{2} x^{2} + c_{3} x^{3} + t = 0 $ and that g1 is a possible solution of this general cubic equation.
Summary
To summarise the cubic situation so far: the each term in the solution for $x$ in the general cubic has power of $c_3$ in the denominatr, and powers of $c_0, c_2$ and $c_3$ in the numerator. The sign of the term appears to depend on the parity of the power of $c_3$ that appears (even parity means a negative sign). The terms are all balanced between numerator and denominator, that is, having a total degree of 0. (This is a reflection that the solution should not depend on a uniform rescaling of coefficients). All terms have a total index degree -1. The general term has the form:
$$(-1)^{c + 1} \frac{(k - 1)!}{a!b!c!} \frac{c_0^a c_2^b c_3^c}{c_1^k}$$To make the nomenclature simpler rewrite this in a new uniform manner. Call this formula $S$.
$$S(m_0, m_1, m_2, m_3) \equiv (-1)^{m_3 + 1} \frac{(m_1 - 1)!}{m_0!m_2!m_3!} \frac{c_0^{m_0} c_2^{m_2} c_3^{m_3} }{c_1^{m_1}}$$Note that each term in the solution of the general cubic meets two conditions, one related to the value of the total degree and one related to the value the total index degree. Using the updated variable names in $S$ these conditions are:
$$ m_0 + m_2 + m_3 - m_1 = 0 $$$$ 2 m_2 + 3 m_3 - m_1 = -1 $$Note that these conditions can be viewed as 2 equations in 4 unknowns (i.e. a system of equations with 2 degrees of freedom). This allows the system to be rewritten in terms of any two of the four variabbles $ m_0, m_2, m_3$ and $m_1 $
Let g2 and g3 be a system of equations based on constraints of the total degree and total index degree of the solution of the general cubic
m_0, m_1, m_2, m_3 = sp.symbols('m_0, m_1, m_2, m_3')
g2 = sp.Eq(m_0 + m_2 + m_3 - m_1, 0)
g3 = sp.Eq(2 * m_2 + 3 * m_3 - m_1, -1)
Let g4 be a solution to the system for $m_2$ and $m_3$.
g4 = sp.linsolve([g2, g3], [m_2, m_3])
g4
Note that if these solutions of $m_2$ and $m_3$ were to be subsituted into to $S$ reducing number of parameters of $S$, this would introduce negative signs with factorials that will create complexity. It would be better to choose a solution that has negatives to avoid these problems.
Let g5 be a solution to $m_0$ and $m_1$.
g5 = sp.linsolve([g2, g3], [m_0, m_1])
g5
Note these solutions involve only postive combinations of parameters. Subsitute these solutions into $S$ and create a new function, $C$ that is equivalent using only $m_2$ and $m_3$.
$$C(m_2, m_3) \equiv(-1)^{m_3 + 1} \frac{(2 m_{2} + 3 m_{3})!}{(1 + m_{2} + 2 m_{3})!m_2!m_3!} \frac{c_0^{1 + m_{2} + 2 m_{3}} c_2^{m_2} c_3^{m_3} }{c_1^{2 m_{2} + 3 m_{3} + 1}}$$To generate values for this function, note it can also be written as:
$$ x = \Sigma_{m_2 = 0}^+ \Sigma_{m_3 = 0}^+ C(m_2, m3) $$Evaulate this formula and store in an $n x n$ matrix.
def C(m2, m3, returnCoefficientsOnly = False, returnCoefficientsOnlyWithoutSigns = False):
c_0, c_1, c_2, c_3 = sp.symbols('c_0, c_1, c_2, c_3')
s1 = (-1)**(m3 + 1)
s2 = sp.factorial(2 * m2 + 3 * m3)
s3 = sp.factorial(1 + m2 + 2 * m3) * sp.factorial(m2) * sp.factorial(m3)
s4 = c_0**(1 + m2 + 2 * m3) * c_2**m2 *c_3**m3
s5 = c_1**(2 * m2 + 3 * m3 + 1)
if returnCoefficientsOnly:
s6 = s1 * (s2 / s3)
elif returnCoefficientsOnlyWithoutSigns:
s6 = (s2 / s3)
else:
s6 = s1 * (s2 / s3) * (s4 / s5)
return(s6)
Let g6 be a value of $n$ that can determine the matrix size
g6 = np.arange(8)
Let g8 be a matrix of values.
g7 = [[C(j, i) for i in g6] for j in g6]
g8 = sp.Matrix(g7)
g8
Note it is possible recover the values as a sum.
np.sum(g8)
Evaluate to get only coefficients and no signs in values.
g9= np.array([[C(j, i, returnCoefficientsOnlyWithoutSigns=True) for i in g6] for j in g6])
g10 = sp.Matrix(g9)
g10
Note it is straightforward to get at the rows, columms, diagonals, etc. of this 2D array.
g9[1,:], g9[:,1], g9.diagonal(), np.fliplr(g9).diagonal(3)
(array([1, 5, 28, 165, 1001, 6188, 38760, 245157], dtype=object), array([1, 5, 21, 84, 330, 1287, 5005, 19448], dtype=object), array([1, 5, 180, 10010, 678300, 51482970, 4206302100, 361913666400], dtype=object), array([55, 165, 180, 84, 14], dtype=object))
Summary
This formula provides a very powerful way at getting at the values of the cubic equation roots solution. Leads to a new question: the first column is Catalan. What else is happening here?