Recursive integration

Viewed 1228

This is a simplified version of the actual question I am working on.

Suppose that we have a sequence of (mathematical) functions, f_0, f_1, f_2, ..., such that enter image description here

We fix a function f_0, say, f_0(x)=x. In this simple case, f_n(x) = 1/((n+1)!) x^{n+1}. Is there an elegant and efficient way to program this recursively, so that Python returns the function f_n given an arbitrary function f_0?

I started out trying to return f_2, but this already failed:

from scipy.integrate import quad

f_0=lambda x: x
f_1=lambda x: quad(f_0,0,x)
f_2=lambda x: quad(f_1,0,x)

returns the error

error: Supplied function does not return a valid float. 

after trying to evaluate e.g. f_2(3).

2 Answers
Related