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
pd.set_option('display.max_colwidth', None)
# 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:])))
Aim: To explore the rows and columns in the coefficient array generated by the solutions to the general cubic.
Method. Explore OIES resources, and Robert Dickau's page on Catalan Numbers and Fuss-Catalan Numbers
Observe: the generating function of the coefficients in the general solution to the cubic equation
$$C(m_2, m_3) \equiv \frac{(2 m_{2} + 3 m_{3})!}{(1 + m_{2} + 2 m_{3})!m_2!m_3!}$$Let $F1$ be a function that implements $C$ and returns a solution to a general cubic equation.
def F1(m2, m3, returnCoefficientsOnly = False, returnCoefficientsOnlyWithoutSigns = False, returnCoefficientsAsFactorialStrings = 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)
s7 = str(2 * m2 + 3 * m3) + "!"
s8 = str(1 + m2 + 2 * m3) + "!" + str(m2) + "!" + str(m3) + "!"
if returnCoefficientsOnly:
s6 = s1 * (s2 / s3)
elif returnCoefficientsOnlyWithoutSigns:
s6 = (s2 / s3)
elif returnCoefficientsAsFactorialStrings:
s6 = str(s7 + " | " + s8)
else:
s6 = s1 * (s2 / s3) * (s4 / s5)
return(s6)
Let $P3$ be an array of coefficients generated by $F1$.
P1 = np.arange(8)
P2 = np.array([[F1(j, i, returnCoefficientsOnlyWithoutSigns=True) for i in P1] for j in P1])
P3 = sp.Matrix(P2)
P3
Observe: Some facts are known about these numbers. The first column is the Catalan Numbers, the first row is the Fuss-Catalan numbers.
Ref: Good reference for this Richard Stanley Enumerative Combinatorics (2 Volumes).
Ref: Found on Robert Dickau's webpage, which shows the relatiship to the Catalan and Fuss Catalan numbers as different approaches subdivide n-gons into smaller n-gons
Observe: Recall that important OEIS references are A00108, A001764 which both note Euler like interpretations of divisions of polygons.
Observe: From Robert Dickau's, as Catalan -> Fuss Catalan -> etc.:
$ \frac{\binom{2n}{n}}{(n + 1)} \equiv$ number of ways to draw a 3-gon in increasing polygon
$ \frac{\binom{3n}{n}}{(3n + 1)} \equiv$ number of ways to draw a 4-gon in increasing polygon
etc...
Observe: The Catalan binomial function written as a factorial where $ \binom{n}{k} = \frac{n!}{k!(n - k)!}$
$$ \frac{\binom{2n}{n}}{(n + 1)} \equiv \frac {\frac{2n!}{n!(2n - n)!}}{n + 1} \equiv \frac {\frac{2n!}{n!^2}}{n + 1} \equiv \frac{\left(2 n\right)!}{\left(n + 1\right) n!^{2}} $$Observe: the relationship between binomials and fatorials.
Todo: Examine different patterns that appear in the generating functions
# Starter code
x, n = sp.symbols('x, n')
# 5 sides, 5 ways to arrange triangles
P4 = np.prod([(2 * n - i) for i in range(0,4)])
P5 = np.prod([(n - i) for i in range(0,2)])
#print((P4 / ((n + 1) * P5 * P5)).subs(n, 2))
#(P4 / ((n + 1) * P5 * P5)).simplify()
# 6 sides, 14 ways to arrange triangles
P4 = np.prod([(2 * n - i) for i in range(0,8)])
P5 = np.prod([(n - i) for i in range(0,4)])
#print((P4 / ((n + 1) * P5 * P5)).subs(n, 4))
#(P4 / ((n + 1) * P5 * P5)).simplify()
# 7 sides, 42 ways to arrange triangles
P4 = np.prod([(2 * n - i) for i in range(0,10)])
P5 = np.prod([(n - i) for i in range(0,5)])
#print((P4 / ((n + 1) * P5 * P5)).subs(n, 5))
#(P4 / ((n + 1) * P5 * P5)).simplify()
#print((sp.binomial(2 * n, n) / (n + 1)).subs(n, 6))
#print((sp.factorial(2 * n) / ((n + 1) * sp.factorial(n) * sp.factorial(n))).subs(n,6))