# fit recursive function to data

I have a function $g(x, n)$, which is a recursive expression: $x$ is a variable and $n$ the number of iterations. In my case $n=3$ for all $x$. An example is the following:

f[__, 0] = 1;
f[x_, n_] := x*f[x, n - 1]
g[x_, n_] := ArcTan[f[x, n]] + Cos[f[x, n]]/Exp[f[x, n]/100];

data = Table[{i, 2*g[i, 3]}, {i, -3, 3, 0.1}];


I would like to fit a function $a\times g(x,3)$ to the generated data. A succesful fit should give $a=2$. Can I get an example of how to do this in Mathematica?

-
A working example would be helpful. – Mr.Wizard Sep 9 '13 at 12:05
@Mr.Wizard I have added an example, thanks for the suggestion – BillyJean Sep 9 '13 at 12:15

FindFit[data, a*g[x, 3], a, x]

{a -> 2.}