I am given the problem to find $B(y)$ by solving the following integral numerically:
$$B(y) = \int_{z=0}^{\infty}\frac{1}{\sigma (y,z)}\frac{\partial^2 A(y,z)}{\partial z^2}+\frac{\partial A(y,z)}{\partial z}\frac{\partial}{\partial y}\frac{1}{\sigma (y,z)}\;\;\partial z$$
Here, $A(y,z)$ and $\sigma(y,z)$ are both known on a grid of points along the $y$- and $z$-directions.
I am familiar with numerical integration (e.g. Simpson's rule, Gaussian quadrature) but usually it is for simple functions of the form
$$\int_a^b f(x) \;\;dx $$
I am not sure how to proceed with more complex forms like:
$$\int_a^b f'(x)g''(x)\;\;dx $$
Where and how do I begin? Can someone point me to any resources that deal with these sorts of numerical problems?
Thanks
Consider you prototypical problem $$ \int_a^b f'(x) g''(x) dx.$$ I will assume that you have $f$ and $g$ computed at equidistant points $x_j = a + jh$, where $Nh = b-a$ for some integer $N$.
If you use the composite trapezoidal rule, then the error will be $O(h^2)$. It follows that you need approximations of $f'$ and $g''$ which are at least $O(h^2)$.
You can use finite difference approximations of the derivatives. For all the internal points, i.e., $j=1,2,3,\dotsc, N-1$ you can use the space central approximations. $$ f'(x) = \frac{f(x+h)- f(x-h)}{2h} + O(h^2)$$ and $$ g''(x) = \frac{g(x+h) - g(x) + g(x-h)}{h^2} + O(h^2).$$ At the end points of the intervals, you must use one sided approximations which are also $O(h^2)$ accurate. At $x=a$ you can use $$ f'(a) = \frac{-3 f(a) + 4 f(a+h) - f(a+2h)}{2h} + O(h^2)$$ You can derive the remaining approximations by Taylor expansions.