I have a function H(t) returning a float. I then want to numerically compute several integrals involving this function. However, one of the integrals basically invokes the previous integral, e.g.
from scipy.integrate import quad
def H(t):
return t
def G1(t):
return quad(lambda x: H(x)*H(t-x),0,1)[0]
def G2(t):
return quad(lambda x: G1(x)*H(t-x),0,1)[0]
res = quad(G1,0,1) + quad(G2,0,1)
I will need to do this for a large number of functions (i.e. continue like this with G3, G4... Gn) and my end-result will depend on all of them. Since I have to compute G1 for many values of t anyway in order to perform quad(G1,0,1), is it possible to store those computed values and use them when computing quad(G2,0,1)? I could maybe try to write my own simplistic integration function, but how would I go about storing and re-using these values?