Hi Melody
Sorry, but I don't think that your proof is a proof. The problem is at the point where you say ' it follows that '
$$f^{\:2}(x)=g^{\:2}(x)$$.
Just because two functions share the same property, it doesn't follow that they are the same function. For example if we have f(-x) = -f(x) and g(-x) = -g(x), it doesn't mean that f(x) and g(x) are the same function. It is simply saying that both f and g are odd functions, and there will be a whole stack of different possibles for either one of them.
I don't have a proof of this relationship that I really like. That would be a series of steps that took me from
$$f^{\:2}(x)\equiv 1+xf(x+1),$$
through to
$$f(x)\equiv1+x.$$
I do have a couple of routines that might just pass.
Suppose (for no particularly good reason that I can think of) that f(x) is a polynomial of degree n. Then, on the LHS we have a polynomial of degree 2n and on the RHS a polynomial of degree n+1. For these to be identically equal we need 2n = n + 1, from which n = 1. Therefore, let f(x) = ax + b. Substitute that in and equate coefficients across the identity and you find that a = b = 1.
If I had to guess how Ramanujan came up with the result I would go for the following. I think that he was doodling, so to speak.
$$(1+x)^{2}=1+2x+x^{2}=1+x(2+x)$$
so
$$1+x=\sqrt{1+x(2+x)}\dots \dots (1) .$$
Similarly,
$$(2+x)^{2}=(1+(1+x))^{2}=1+2(1+x)+(1+x)^{2}=1+(1+x)(3+x)$$
so
$$2+x=\sqrt{1+(1+x)(3+x)}$$
so, substituting that into (1),
$$1+x=\sqrt{1+x\sqrt{1+(1+x)(3+x)}}.$$
Now repeat the routine with 3 + x = 1 + (2 + x) and so on.