Function Repository Resource:

NestedBranching

Source Notebook

Generate a nested branching model

Contributed by: Katja Della Libera

ResourceFunction["NestedBranching"][b,n]

generates a branching model of depth n specified by the rule b, a list of complex numbers representing the result of the first step.

Details and Options

The "stem" of the model is assumed to be a line from -1 to 0.
The option "Output" defaults to "Graphic", which can be used to determine the output format and accepts the following specifications:
"Graphic"a visual representation of the model turned by 90° to face upward
"Points"a nested list representing the points at each layer
"EndPoints"the endpoints of the model
"Lines"a list of lists of length two representing the lines with no rotation or conversion from complex numbers

Examples

Basic Examples (1) 

Get six layers of a branching model with two branches:

In[1]:=
ResourceFunction["NestedBranching"][{0.7 + 0.2 I, 0.7 - 0.2 I}, 6]
Out[1]=

Scope (2) 

Retrieve the points instead of a graphic:

In[2]:=
ResourceFunction["NestedBranching"][{0.7 + 0.2 I, 0.7 - 0.2 I}, 3, "Output" -> "Points"]
Out[2]=

Visualize the points using ComplexListPlot:

In[3]:=
ComplexListPlot[
 ResourceFunction["NestedBranching"][{0.7 + 0.2 I, 0.7 - 0.2 I}, 3, "Output" -> "Points"]]
Out[3]=

The endpoints are just the last list in the points:

In[4]:=
ResourceFunction["NestedBranching"][{0.7 + 0.2 I, 0.7 - 0.2 I}, 3, "Output" -> "EndPoints"]
Out[4]=

The lines can also be retrieved:

In[5]:=
ResourceFunction["NestedBranching"][{0.7 + 0.2 I, 0.7 - 0.2 I}, 3, "Output" -> "Lines"]
Out[5]=

The model works for any number of branches and does not have to be symmetric:

In[6]:=
ResourceFunction["NestedBranching"][{0.4 + 0.2 I, 1.1, 0.7 - 0.2 I},
  5]
Out[6]=

Neat Examples (1) 

A simple Manipulate allows for the manual manipulation of the real and imaginary parts of each value in b:

In[7]:=
Manipulate[
 ResourceFunction["NestedBranching"][{Complex[a, b], Complex[c, -d]}, depth], {{a, 0.3, "Re[a]"}, 0, 1}, {{b, 0.3, "Im[a]"}, 0, 1}, {{c, 0.3, "Re[b]"}, 0, 1}, {{d, 0.3, "Im[b]"}, 0, 1}, {{depth, 7, "Depth"}, 1, 10, 1}, SaveDefinitions -> True]
Out[7]=

Publisher

Katja Della Libera

Version History

  • 1.0.0 – 17 June 2020

Related Resources

License Information