“Addition-Addition Rules”
“Addition-Addition Rules”
In[]:=
RGraphAddAdd[{a_,b_,c_},init_List,max_,id_:False,labs_:True]:=Graph[DirectedEdge[#[[1,1]],#[[2,1]],#[[1,2]]]&/@Last[Reap[Module[{f},f[n_]:=f[n]=a+f[Sow[n-b-f[If[id,Sow[n-c,(n->2)],n-c]],(n->1)]];(f[#[[1]]]=#[[2]])&/@init;Table[f[n],{n,max}]],_,Rule]],GraphLayout->"LayeredDigraphEmbedding",VertexLabels->If[labs,Placed["Name",Center],None],VertexSize->If[labs,.7,Automatic],VertexStyle->Directive[EdgeForm[Lighter[Blue,.5]],Lighter[Blue,.9]],EdgeStyle->{DirectedEdge[_,_,1]->Blue,DirectedEdge[_,_,2]->Red}]
In[]:=
RValuesAddAdd[{a_,b_,c_},init_List,max_]:=Module[{f},f[n_]:=f[n]=a+f[n-b-f[n-c]];(f[#[[1]]]=#[[2]])&/@init;Table[f[n],{n,max}]]
In[]:=
Table[{a,b,c}->ListLinePlot[RValuesAddAdd[{a,b,c},{n_/;n<1->1},100],PlotTheme->"Minimal",ImageSize->Tiny],{a,3},{b,3},{c,3}]
Out[]=
{1,1,1}
,{1,1,2}
,{1,1,3}
,{1,2,1}
,{1,2,2}
,{1,2,3}
,{1,3,1}
,{1,3,2}
,{1,3,3}
,{2,1,1}
,{2,1,2}
,{2,1,3}
,{2,2,1}
,{2,2,2}
,{2,2,3}
,{2,3,1}
,{2,3,2}
,{2,3,3}
,{3,1,1}
,{3,1,2}
,{3,1,3}
,{3,2,1}
,{3,2,2}
,{3,2,3}
,{3,3,1}
,{3,3,2}
,{3,3,3}
In[]:=
ListLinePlot[RValuesAddAdd[{3,1,3},{n_/;n<1->1},500]]
Out[]=
In[]:=
ListStepPlot[FoldList[Max,0,RValuesAddAdd[{3,1,3},{n_/;n<1->1},500]]]
Out[]=
In[]:=
{First[#],Length[#]}&/@Split[FoldList[Max,0,RValuesAddAdd[{3,1,3},{n_/;n<1->1},500]]]
Out[]=
{{0,1},{4,2},{7,5},{10,8},{13,11},{16,14},{19,17},{22,20},{25,23},{28,26},{31,29},{34,32},{37,35},{40,38},{43,41},{46,44},{49,47},{52,50},{55,53},{58,5}}
In[]:=
ListPlot[Last/@%]
Out[]=
In[]:=
Transpose[%773]
Out[]=
{{0,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58},{1,2,5,8,11,14,17,20,23,26,29,32,35,38,41,44,47,50,53,5}}
In[]:=
Differences/@%
Out[]=
{{4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3},{1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,-48}}
In[]:=
FindSequenceFunction[Take[RValuesAddAdd[{3,1,3},{n_/;n<1->1},500],{10,-10}],n]
Out[]=
$Aborted
In[]:=
FoldList[Plus,0,{a,b,c}]
Out[]=
{0,a,a+b,a+b+c}
In[]:=
With[{seq=RValuesAddAdd[{3,1,3},{n_/;n<1->1},500]},ListStepPlot[Prepend[seq,0]-FoldList[Max,0,seq]]]
Out[]=
In[]:=
With[{seq=RValuesAddAdd[{3,1,3},{n_/;n<1->1},50]},ListStepPlot[Prepend[seq,0]-FoldList[Max,0,seq]]]
Out[]=
n copies of the first block type, followed by 2 copies of the second block....
Other Initial Conditions
Other Initial Conditions
Multiplied Case
Multiplied Case