# Shuffle instructions for Recursion

Total shuffle beginner here, apologies ahead of time. To me it seems the shuffle instructions could be an ideal method to perform recursive computations. In the examples we typically see additive reductions, but who says the reduction function has to be addition?

For example

aa[-1]=1;
aa[0]=b[0];
bb[-1]=0;
bb[0]=1;
aa[n_]:=aa[n]=b[n]aa[n-1]+a[n]aa[n-2];
bb[n_]:=bb[n]=b[n]bb[n-1]+a[n]bb[n-2];
b[0]=0;

with a and b being arrays with arbitrary numbers (say, integers or floats or doubles). The above is in Mathematica, and the construction aa[n_]:=aa[n]=… ensures that a computed result is also stored/cached/memoized and not recomputed over and over again (“if it’s already computed, take it from memory, if it isn’t, compute it and put in memory”).

As the numbers will get bigger and bigger I see the danger of overflow. And for non-integer types I see the danger of accumulating round-off error, which would make the result unusable. However, this would also be the case for a loop version, that problem doesn’t seem specific to shuffling.

And how much faster would that be with shuffle? If it isn’t faster than the trivial-to-write loop version, shuffling wouldn’t be worth the effort.

If someone could give me a shuffle-based solution to compute simply the Fibonacci numbers, that would be a good start for me. The example above is trickier, because aa also depends on b and bb also depends on a.

Thanks!