Update I made a mistake in the first formula, now everything is correct as far as I can tell.
I am calculating integrals with the Obara–Saika recurrence scheme[1]. Now I want to calculate also the gradients of each integral. I suppose it is calculated like in the equation below which I derived with the product rule.
$$ \hat\partial_i ( a || b ) = - 2\zeta_a ( a + {\bf 1}_i || b ) - 2\zeta_b (a ||b + {\bf 1}_i) + \sum^{l_a}_{j=1} \delta_{ij} ( a - {\bf 1}_j || b ) + \sum^{l_b}_{k=1} \delta_{ik} ( a || b - {\bf 1}_k ) $$
I use the same nomenclature as Obara and Saika did, since the paper is somewhat loaded with math I will explain those here again. $\hat\partial_i$ is the derviative in $i$-direction, $a$ and $b$ are cartesian gaussian functions, $\zeta_a$ is the orbital exponent of the gaussian function $a$, $\zeta$ is a shortcut for $\zeta_a + \zeta_b$, $\delta_{ij}$ is the kronecker delta and ${\bf 1}_i$ is an increment or decrement of the polynom of the gaussian function in $i$ direction—that basicly means you get an $d_{ij}$ from $p_i+{\bf 1}_j$. Oh, I almost forgot that one, $(a||b)$ denotes an integral over two gaussian functions.
Update or What I have done so far:
I've done some calculations with the Obara–Saika recurrsion so far, that suggest that the expression I derived for the derivative is correct. If you calculate the derivative explicitly as Erik Kjellgren had done in his answer you get the expression I have shown above. It is a bit cryptic and but if you take a closer look you will see it. Please note that we both have tackled a different problem, I have calculated the derivative in x-direction, while he has calculated the derivative for the movement of the nucleus A in x direction. So mabye I am dealing with the wrong problem.
Let's solve both starting with my problem. The gauss integral as used in the paper from Obara and Saika is given as
$$ \varphi({\bf r}; \zeta, {\bf n}, {\bf R}) = (x-R_x)^{n_x}(y-R_y)^{n_y}(z-R_z)^{n_z}\times\exp(-\zeta({\bf r-R})^2) $$
this is nearly the same as used by Erik, but I want to stay in this whole post in the same nomenclature. The next step is to calculate the derivative
$$ \hat\partial_i ( a || b ) = \hat\partial_i \int{\rm d}{\bf r} N(\zeta_a,{\bf a})\varphi({\bf r}; \zeta_a, {\bf a}, {\bf A}) N(\zeta_b,{\bf b})\varphi({\bf r}; \zeta_b, {\bf b}, {\bf B}) \\ = N(\zeta_a,{\bf a})N(\zeta_b,{\bf b}) \hat\partial_i \int{\rm d}{\bf r} (x-A_x)^{a_x}(y-A_y)^{a_y}(z-A_z)^{a_z}\times\exp(-\zeta_a({\bf r-A})^2) \\\times (x-B_x)^{b_x}(y-B_y)^{b_y}(z-B_z)^{b_z}\times\exp(-\zeta_b({\bf r-B})^2) \\ = N(\zeta_a,{\bf a})N(\zeta_b,{\bf b}) \int{\rm d}{\bf r}\biggl( \hat\partial_i (x-A_x)^{a_x}(y-A_y)^{a_y}(z-A_z)^{a_z}\times\exp(-\zeta_a({\bf r-A})^2) \\+ (x-A_x)^{a_x}(y-A_y)^{a_y}(z-A_z)^{a_z}\times\hat\partial_i \exp(-\zeta_a({\bf r-A})^2) \\+ \hat\partial_i (x-B_x)^{b_x}(y-B_y)^{b_y}(z-B_z)^{b_z}\times\exp(-\zeta_b({\bf r-B})^2) \\+ (x-B_x)^{b_x}(y-B_y)^{b_y}(z-B_z)^{b_z}\times\hat\partial_i \exp(-\zeta_b({\bf r-B})^2)\biggr) \\ = - 2\zeta_a ( a + {\bf 1}_i || b ) - 2\zeta_b (a ||b + {\bf 1}_i) + \sum^{l_a}_{j=1} \delta_{ij} ( a - {\bf 1}_j || b ) + \sum^{l_b}_{k=1} \delta_{ik} ( a || b - {\bf 1}_k ) $$
Okay this was straigth forward. Because I don't know anything about the derivative I applied kronecker-deltas. This should be okay because you can also write something like that for the above expression:
$$ \hat\partial_i ( a || b ) = - 2\zeta_a ( a + {\bf 1}_i || b ) - 2\zeta_b (a ||b + {\bf 1}_i) + \delta_{ix} a_x ( a - {\bf 1}_x || b ) + \delta_{iy} a_y ( a - {\bf 1}_y || b ) + \delta_{iz} a_z ( a - {\bf 1}_z || b ) + \delta_{ix} b_x ( a || b - {\bf 1}_x ) + \delta_{iy} b_y ( a || b - {\bf 1}_y ) + \delta_{iz} b_z ( a || b - {\bf 1}_z ) $$
I am now at the same point as Erik Kjellgren, nothing new so far, but maybe a bit more general. Now I am going to get rid of the integrals with the Obara–Saika recurrsion, because that is what it is all about.
$$ \hat\partial_i ( a || b ) = - 2\zeta_a ( a + {\bf 1}_i || b ) - 2\zeta_b (a ||b + {\bf 1}_i) + \sum^{l_a}_{j=1} \delta_{ij} ( a - {\bf 1}_j || b ) + \sum^{l_b}_{k=1} \delta_{ik} ( a || b - {\bf 1}_k ) \\ = -2\zeta_a \Bigl( (P_i-A_i)(a||b) + \sum^{l_a}_{j=1} \delta_{ij}\frac 1{2\zeta} ( a - {\bf 1}_j || b ) + \sum^{l_b}_{k=1} \delta_{ik}\frac 1{2\zeta} ( a || b - {\bf 1}_k ) \Bigr)\\ -2\zeta_b \Bigl( (P_i-B_i)(a||b) + \sum^{l_a}_{j=1} \delta_{ij}\frac 1{2\zeta} ( a - {\bf 1}_j || b ) + \sum^{l_b}_{k=1} \delta_{ik}\frac 1{2\zeta} ( a || b - {\bf 1}_k ) \Bigr)\\ + \sum^{l_a}_{j=1} \delta_{ij}( a - {\bf 1}_j || b ) + \sum^{l_b}_{k=1} \delta_{ik}( a || b - {\bf 1}_k ) $$
After applying the basic recurrence scheme I got something that looks interesting and promising
$$ \hat\partial_i ( a || b ) = -2\zeta_a (P_i-A_i)(a||b)-2\zeta_b (P_i-B_i)(a||b) \\ - \sum^{l_a}_{j=1} \delta_{ij} ( a - {\bf 1}_j || b ) - \sum^{l_b}_{k=1} \delta_{ik} ( a || b - {\bf 1}_k ) \\ + \sum^{l_a}_{j=1} \delta_{ij}( a - {\bf 1}_j || b ) + \sum^{l_b}_{k=1} \delta_{ik}( a || b - {\bf 1}_k ) $$
The rest is simple math and so I derived the following expression
$$ \hat\partial_i (a||b) = -\bigl((2\zeta_a({\rm P}_i - {\rm A}_i) + 2\zeta_b({\rm P}_i - {\rm B}_i)\bigr) (a||b) $$
where $\bf A$ and $\bf B$ are the centers of the gaussian functions $a$ and $b$ and $\bf P$ is the center of the product of both gaussian functions.
Orginal question
Have any of you experience with gradients of molecular integrals and can give me a hint on that issue? Is this the right way to calculate the gradient?
[1] S. Obara and A. Saika, J. Chem. Phys. 84 (7), 1986