STATUS: Draft
import numpy as np
import sympy as sp
import pickle
from IPython.display import HTML, Image
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)
import treelib as tr
# 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: Understand the formal object that is a sum of all polygons with all of their subdivisions into triangles
Let $F1$ for a function that implements $C$.
def F1(m2, m3, returnCoefficientsOnly = False, returnCoefficientsOnlyWithoutSigns = True, 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 a matrix of values retlating the part of the formula that calculates unsigned coefficients: $ \frac{(2 m_{2} + 3 m_{3})!}{(1 + m_{2} + 2 m_{3})!m_2!m_3!}$
P1 = np.arange(8)
P2 = np.array([[F1(j, i) for i in P1] for j in P1])
P3 = sp.Matrix(P2)
P3
Observe: It is possible to create operations such as addition and multiplication on newly defined types
Let $P$ be an ongoing sum of the of polygons of increasing sizes arrangeed in different combinations of triangles, expressed as
$$ P = | + P \bar{\triangledown} P $$Observe: Note the $|$ operator here represents a 1-gon and the $\bar{\triangledown}$ operator is yet to be defined
Ref: This is taken from Concrete Mathematics (Ex. 22, Ch7) as part of a question to devise a new operation to explain the relationship between the solutions to a polynomial equation and the subdivisions of a polygon.
Observe: This conjecture introduces both a new type, $P$, and a new operation, $\triangledown$
Observe: This conjecture deals with the sum of the number of ways of subdividing a 2-gon into triangles + the the number of ways to subdivide a 3 gon into triangles + the number of ways ot subdivide a 4-gon into triangles and so on.
Observe: A way to make sense of this is take a multiset point of view
Definition: A Multiset is a data structure, part of the different available data structures including lists, ordered lists, multisets and sets.
Definition: Consider the following example:
Image("./Images/SP18_1.PNG")
Observe: This creates an 10-gon. Note the distinguised (top) edges get glued to the free edges of $\bar{\triangledown}$.
Observe $\bar{\triangledown}$ is a multiplication with a trianglular subdivision and distinguised top edges
Aim: Create a rooted planar tree version of this
Image("./Images/SP18_2.PNG")
Observe: The trees can be joined to the existing edges of the $\bar{\triangledown}$ operator which is represented as the top tree with root $R$
Observe: Recall the above conjecture:
$$ P = | + P \bar{\triangledown} P $$Observe: For a polygon with that an be subdived by traingles with distinsuished top edge, there can be seen a distinguised interior triangle with that top edge (seen in the $\bar{\triangledown}$ operator.
Observe: Every polygon that can be subdivided into triangles with a distinguised top edge is the product of 2 unique such polygons, one on left, and one on the right, with the exception of the degenerate case (2 sided polygons)
Observe: Therefore $ P = | + P \bar{\triangledown} P $ yields all combinations + addition of $|$ to account for the 2 sided case.
Summary: The above has only defined an operation that is possible to undertaken in relation to polygonal subdivision. More work is required to be able to compute with this operation
Aim: Understand this in the context of multiset data structures
</hr>
Definition: a multiset is an unordered collection with repetitions allowed
Observe: The $\bar{\triangledown}$ has been defined as an operation on planar polygon subdivisons, or planar rooted complete binary trees
Observe: The $\bar{\triangledown}$ binary operation is is not commutative and is not associative but can be extended to multisets
Observe Tree like structures using this operator
Observe: This structure naturally has addition and natural number multiplication.
Observe: Trees can be combined in the manner above.
Image("./Images/SP18_3.PNG")
Observe: this can be written as $2T_1 + T_2 \bar{\triangledown} T_3$
Observe: This represents an algebra of MSets.
Todo: Find a way to do this computationally