MATLAB/OCTAVE- Numerical integration of an integrand containing terms obtained from numerical solution of a system of ODE

荒凉一梦 提交于 2019-12-12 01:37:52

问题


I want to calculate the following integral on Octave(or Matlab):

However, I don't have an explicit expression for H and K. The H and K are actually numerical solutions of the following differential equations. The initial conditions of h,k, dh/dr, and dk/dr are 0,1,1/2,0 respectively.

How do I go about doing this? Can I solve it directly somehow, or do I need to find the numerical solutions to H and K first, find a polynomial approximation, and then integrate? I am completely new to Matlab and numerical methods, so a detailed method describing everything will be most appreciated.


回答1:


If you have the ability to solve for H and K at any point desired, then the best option is going to be to evaluate them at specific points called 'nodes' and then use a numerical integration scheme to compute your integral. The basic idea is that, depending on the integration scheme, you can get results of different accuracy.

A basic finite sum would be simply evaluating your H and K at equidistant points and then taking dx to be the space in between them. This can obviously be problematic with an infinite integral like you have, but you can also recast the kernel into a finite domain (take the 1/(x+1) of everything and then your integrands turn from (0,+inf) to (1,0) - obviously you will need to take the negative of the resulting integral and turn (1,0) into (0,1)).

Using a finite domain you can use the finite sum method described, or a more accurate integration scheme over a finite domain like Gauss-Legendre Quadrature. http://en.wikipedia.org/wiki/Gaussian_quadrature

Finally, if you need to keep the infinite domain, it is possible use a quadrature type which is more suitable for infinite domains such as Gauss-Laguerre quadrature which will require you to premultiply your kernel by Exp(x) so that the resulting weights (Exp(-x)) do not change your kernel. http://en.wikipedia.org/wiki/Gauss–Laguerre_quadrature



来源:https://stackoverflow.com/questions/11470095/matlab-octave-numerical-integration-of-an-integrand-containing-terms-obtained-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!