# How to condense many FindSequenceFunctions into a single one?

I have a function $f(n,k)$ that is rather large and complex, but if I hold $k$ constant and feed values into Mathematica over many $n$, I can get a closed-form expression for that $k$.

However, I can't seem to find a good way to feed the whole function into Mathematica due to structural reasons, but is there a way I can get a closed-form expression by chaining them somehow?

For example, if I have the FindSequenceFunction for $k=1$, $k=2$, $k=3$, etc, can I then run a similar FindSequenceFunction across all of these expressions and get a closed form for $f(n,k)$?

In short, yes. However, it really depends on whether FindSequenceFunction can recognize the closed form of f(n,k). Here is a contrived example to show that it is possible:

Suppose we know ahead of time that f(n,k) = n^2 + k^2.

In[1] := f[n_,k_] := n^2 + k^2


We will first let FindSequenceFunction return the closed-form solutions for f when k = 1, k = 2, k = 3, ...

In[2] := FindSequenceFunction[Table[f[n, 1], {n, 10}]]
Out[2] = 1 + #1^2 &
In[3] := FindSequenceFunction[Table[f[n, 2], {n, 10}]]
Out[3] = 4 + #1^2 &
In[4] := FindSequenceFunction[Table[f[n, 2], {n, 10}]]
Out[4] = 9 + #1^2 &


To generalize, let fsf be a table of these intermediate functions:

In[5] := Table[FindSequenceFunction[Table[f[n, k], {n, 10}]], {k, 5}]
Out[5] = {1 + #1^2 &, 4 + #1^2 &, 9 + #1^2 &, 16 + #1^2 &, 25 + #1^2 &}
In[6] := fsf = (#[n] & /@ %)
Out[6] = {1 + n^2, 4 + n^2, 9 + n^2, 16 + n^2, 25 + n^2}


We can then simply find the closed-form solution for f(n,k) as follows:

In[7] := closedForm = FindSequenceFunction[fsf][k]
Out[7] = k^2 + n^2
In[8] := closedForm == f[n,k]
Out[8] = True