Code

In[]:=
NestedRecursiveFunction[data_,pars_​​]:=Module[{pkeys,subfun,rep,finmem,null},​​pkeys=Keys[data["Partials"]];​​rep=Join[​​MapThread[Rule,{data["Parameters"],pars}],​​MapThread[Rule,{data["Variables"],​​Slot/@Range[Length[data["Variables"]]]}]​​];​​subfun=Function[{memo,vals},​​Module[{res,parts,rhs=Association[],newmemo,temp},​​parts=Association[];​​newmemo=memo;​​If[​​Not[Function[Evaluate[data["GrowTest"]/.rep]]@@vals]​​,​​{newmemo,Function[Evaluate[data["Root"]/.rep]]@@vals}​​,​​KeyValueMap[Function[{key,val},​​parts[key]=ReplaceAll[​​Function[Evaluate[val/.rep]]@@vals,​​Thread[Rule[pkeys,Lookup[parts,pkeys,True]]]​​];​​If[SameQ[Head[val],data["Function"]],​​temp=parts[key];​​If[TrueQ[res=Lookup[newmemo,​​Key[List@@parts[key]],True]],​​{newmemo,res}=subfun[newmemo,{##}]&@@parts[key];​​];​​rhs[Length[rhs]]=Equal[temp,res];​​parts[key]=res;​​];​​]​​,​​data["Partials"]​​];​​res=parts[data["Return"]];​​KeyValueMap[Sow[DirectedEdge[​​Equal[data["Function"]@@vals,res],#2,#1+1]​​]&,rhs];​​newmemo[vals]=res;​​{newmemo,res}​​]​​]​​];​​finmem=Association[];​​(*hackedanticipationformultivariates*)​​Function[​​Which[​​VectorQ[{##},IntegerQ],​​Last[subfun[​​finmem,​​{##}]],​​VectorQ[First[{##}],IntegerQ],​​Map[Function[val,Set[​​{finmem,null},​​subfun[finmem,{##}]&[val]];​​null],First[{##}]],​​True,​​$Failed​​]​​​​]​​]

Schemas

In[]:=
$PlusTimesShift=Association​​"Parameters"->{a.,b.,c.,d.},​​"Variables"->{n.},​​"Function"->f,​​"GrowTest"->n.>d.,​​"Root"->1,​​"Partials"->Association​​p.[0]->Subtract[n.,c.],​​p.[1]->f[p.[0]],​​p.[2]->Timesb.,p.[1],​​p.[3]->Subtract[n.,p.[2]],​​p.[4]->f[p.[3]],​​p.[5]->a.+p.[4]​​,​​"Return"->p.[5]​​;
In[]:=
$PlusPlusTimesShift=Association​​"Parameters"->{a.,a1,b.,c.,d.},​​"Variables"->{n.},​​"Function"->f,​​"GrowTest"->n.>d.,​​"Root"->1,​​"Partials"->Association​​p.[0]->Subtract[n.,c.],​​p.[1]->f[p.[0]],​​p.[2]->Timesb.,p.[1],​​p.[3]->Subtract[n.,p.[2]],​​p.[4]->f[p.[3]],​​p.[5]->a.+a1n.+p.[4]​​,​​"Return"->p.[5]​​;
In[]:=
$PlusTimesShiftShift=Association​​"Parameters"->{a.,b.,c.,c2,d.},​​"Variables"->{n.},​​"Function"->f,​​"GrowTest"->n.>d.,​​"Root"->1,​​"Partials"->Association​​p.[0]->Subtract[n.,c.],​​p.[1]->f[p.[0]],​​p.[2]->Timesb.,p.[1],​​p.[3]->Subtract[n.,p.[2]+c2],​​p.[4]->f[p.[3]],​​p.[5]->a.+p.[4]​​,​​"Return"->p.[5]​​;
In[]:=
$TwoTerms=Association​​"Parameters"->​​a.,b.,c.,d.,​​e.,f.,g.,h.​​,​​"Variables"->{n.},​​"Function"->F.,​​"GrowTest"->n.>2,​​"Root"->1,​​"Partials"->Association​​(*firstterm*)​​p.[0]->Subtract[n.,d.],​​p.[1]->F.[p.[0]],​​p.[2]->Subtracta.n.,b.*p.[1]+c.,​​p.[3]->F.[p.[2]],​​(*secondterm*)​​p.[4]->Subtract[n.,h.],​​p.[5]->F.[p.[4]],​​p.[6]->Subtracte.n.,f.p.[5]+g.,​​p.[7]->F.[p.[6]],​​(*sum*)​​p.[8]->p.[3]+p.[7]​​,​​"Return"->p.[8]​​;

Display

​

f[n_]:=1 + f[n-f[n-1]]

Fix ( ) to be [ ]
https://www.wolframscience.com/nks/p129--recursive-sequences/ [ case (a) ]
Closed form: OEIS A002024
https://oeis.org/A002024/a002024_3.pdf
Add annotation to indicate initial condition nodes

f[n_]:=2 + f[n-f[n-1]]

Fix display to include arrows etc. Possibly change the baseline for the tagged items

f[n_]:=3 + f[n-f[n-1]]

Explain why it’s (apparently) sampling down to -a

f[n_]:=3 + f[n-f[n-2]]

Get a proof that this only gets to f[-3]

Brad’s closed form

? Conical structure is perhaps like progressively longer blocks in simple case

f[n_]:=a + f[n-b f[n-c]]

f[n_]:=3 f[n- f[n-1]]

Investigate the relation between the initial values and the final sequence

f[n_]:=a0+a1 n + f[n-b f[n-c]]

f[n_]:=a + f[n-b f[n-c]-d]

[ General Issues ]

A machine with one stack isn’t universal, but two are