Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a binary tree representation of Bernoulli numbers by Woon's method
ResourceFunction["BernoulliBTree"][n] generates a binary tree representation of Bernoulli numbers with n levels by Woon's method. | |
ResourceFunction["BernoulliBTree"][n,prop] uses the specified property for tree nodes. |
Generate a Bernoulli tree with 3 levels with factorial components:
In[1]:= |
Out[1]= |
Generate a Bernoulli tree with 4 levels with numeric values from the factorial components:
In[2]:= |
Out[2]= |
It is easy to convert the binary tree to an actual Bernoulli number:
In[3]:= |
Out[3]= |
Tabulate the results from the function to that from the built-in BernoulliB function:
In[4]:= |
Out[4]= |
Only the root item in the tree is an exception:
In[5]:= |
Out[5]= |
Define a simple check to determine if a given list is an element on the binary tree:
In[6]:= |
In[7]:= |
Out[7]= |
In[8]:= |
Out[8]= |
In[9]:= |
Out[9]= |
It is also possible to use umbral calculus technique based on the set of functions that creates left and right child in the binary tree. Let's define the expansion method on the non-commutative multiplication first:
In[10]:= |
In[11]:= |
In[12]:= |
In[13]:= |
Define the root node and child-generation functions:
In[14]:= |
In[15]:= |
In[16]:= |
Define the conversion formula from the lists in the tree to the factorial fraction:
In[17]:= |
For instance, the 4th Bernoulli number corresponds to this expression in the binary tree:
In[18]:= |
Out[18]= |
In[19]:= |
Out[19]= |
Use the same method on more items:
In[20]:= |
Out[20]= |
The result above is the same as those from BernoulliB:
In[21]:= |
Out[21]= |
The Bernoulli binary tree grows exponentially. A hard limit of 12 is set for the input:
In[22]:= |
Out[22]= |
If MaTeX is installed, one can use TEX form to display the conversion formula:
In[23]:= |
In[24]:= |
Create a binary tree and store the position of each element in a HashTable:
In[25]:= |
Show the conversion formula from a row in the tree to the corresponding Bernoulli number:
In[26]:= |
We can show a truncated part of the formula:
In[27]:= |
Out[27]= |
To find the actual Bernoulli number from the formula above, simply apply Activate function to rowSum:
In[28]:= |
Out[28]= |
It is also possible to use MaTeX function on the nodes of a binary tree:
In[29]:= |
Use TreeElementShapeFunction to apply MaTeX function on the nodes of the Bernoulli binary tree with 4 levels:
In[30]:= |
Out[30]= |
Or one can use the same code on a subtree with 4 levels. Some adjustment for Magnification in MaTeX function is recommended because the length of the denominators grow with different speed according the node position in the tree:
In[31]:= |
In[32]:= |
Out[32]= |
Wolfram Language 14.0 (January 2024) or above
This work is licensed under a Creative Commons Attribution 4.0 International License