Automatic differentiation for numerical integration

AI Thread Summary
The discussion revolves around the challenges of applying reverse-mode automatic differentiation (AD) to numerical integration, specifically when dealing with integrals that cannot be analytically solved. The user has successfully implemented a Levenberg-Marquardt optimization routine using reverse-mode AD but encounters difficulties when trying to differentiate integrals involving fitting parameters. They explore the possibility of using forward-mode AD instead, as reverse-mode may not effectively handle the integral derivatives. Additionally, the user seeks recommendations for existing AD tools that can compute derivatives of integrals, aiming to avoid redundant efforts in developing a new implementation. The conversation highlights the intersection of automatic differentiation and numerical integration in optimization contexts.
raul_l
Messages
105
Reaction score
0
I've written a Levenberg-Marquardt nonlinear optimization routine that employs the reverse-mode automatic differentiation algorithm for building the Jacobian. So far it has worked marvelously for me.
However, now I have to use functions that contain integrals that cannot be analytically taken and have to be numerically calculated, i.e.
f(x,\mathbf{p}) = g(x,\mathbf{p}) \int^{b(\mathbf{p})}_{a(\mathbf{p})}{h(x,\mathbf{p},t)dt}
where p is the parameter vector, f is the fitting function, g is some function of x and p and h is the integrand which is also a function of x and p and to be integrated over t.
Now, most of this can be easily differentiated if I just define the derivatives of elementary functions and take some time to write the rest of AD implementation (which I have done in C++). However, when I use the identity
\nabla_{ \mathbf{p} } \int^{b(\mathbf{p})}_{a(\mathbf{p})}{h(x,\mathbf{p},t)dt} = h(x,\mathbf{p},b(\mathbf{p}))\nabla_{\mathbf{p}}b(\mathbf{p}) - h(x,\mathbf{p},a(\mathbf{p}))\nabla_{\mathbf{p}}a(\mathbf{p}) + \int^{b(\mathbf{p})}_{a(\mathbf{p})}{\nabla_{ \mathbf{p} } h(x,\mathbf{p},t)dt}
to attack the integral I get stuck with the last term. This is my question: Is it possible to use the reverse-mode automatic differentiation to calculate integrals of type
\int^{b(\mathbf{p})}_{a(\mathbf{p})}{\nabla_{ \mathbf{p} } h(x,\mathbf{p},t)dt}
where I first have to calculate partial derivatives with respect to the fitting parameters and then integrate? (The bounds could also be constants, it doesn't matter.)
I've done some googling and come across articles that discuss the application of automatic differentiation to numerical integration algorithms for ordinary differential equations (ODEs). But this is something else because here I explicitly have to calculate the value of the integral. So no help so far. I've done some thinking and it appears that reverse-mode can't be used to handle the integrals, but forward-mode might be doable. Any thoughts from experts?
 
Technology news on Phys.org
I see that my question was too complicated.
So I'll ask something simpler. Does anyone know of any AD tools that are capable of calculating the derivatives of integrals (like above)? I just want to make sure that I'm not reinventing the wheel by writing my own implementation of this.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top