Nestedly Recursive Functions
Nestedly Recursive Functions
Study as a way to understand evaluation sequences....
In[]:=
NRCallGraph[max_,id_:True,opts:___Rule]:=With[{g=Graph[Flatten[Thread/@Last[Reap[Module[{f},f[n_]:=f[n]=3f[Sow[n-f[If[id,Sow[n-1,n],n-1]],n]];f[n_/;n<1]=1;Table[f[n],{n,max}]],_,Rule]]]]},Graph[g,opts,VertexStyle->(#->If[#<=0,White,Green]&/@VertexList[g])]]
In[]:=
NRCallGraph[5,True,VertexLabelsAutomatic]
Out[]=
In[]:=
NRCallGraph[7,True,VertexLabelsAutomatic]
Out[]=
In[]:=
NRCallGraph[10,True,VertexLabelsAutomatic]
Out[]=
In[]:=
NRCallGraph[12,True,VertexLabelsAutomatic]
Out[]=
In[]:=
NRCallGraph[20,True,VertexLabelsAutomatic]
Out[]=
In[]:=
NRCallGraph[20,False,VertexLabelsAutomatic]
Out[]=
In[]:=
Graph[#,GraphLayout"LayeredDigraphEmbedding"]&/@WeaklyConnectedGraphComponents[NRCallGraph[50,False,VertexLabelsAutomatic]]
Is it obvious that there will always be termination [yes, because there is an “absorbing boundary at n < 1”]
Is it obvious that there will always be termination [yes, because there is an “absorbing boundary at n < 1”]
Compare https://cs.uwaterloo.ca/journals/JIS/VOL11/Rowland/rowland21.pdf [ + cites]
Note: the evaluation ordering / layering of this graph is somewhat nontrivial....
Note: the evaluation ordering / layering of this graph is somewhat nontrivial....
How to make the causal graph from this?
How to make the causal graph from this?
Construct call graphs for https://www.wolframscience.com/nks/p130--recursive-sequences/
Construct call graphs for https://www.wolframscience.com/nks/p130--recursive-sequences/