Numerical Integration warning issue
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am trying to evaluate the following numerical integration
temp = 0;
for m=0: K
fun = @(x) imag((1i)^(m)*nchoosek(K,m)*(exp(-1i*(m+1)).*(expint(-1i*x)).^m))./x;
temp = temp + integral(fun,0,Inf);
end
temp = 0.5-(1/pi)*temp;
where K is a positive integer. But I get the following warning message
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 2.4e+00. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
and the result I get is not correct (I am expecting a result between 0 and 1 because it is a cumulative distribution function).
How can I solve this issue?
Thanks
0 comentarios
Respuestas (1)
Jan
el 31 de Mayo de 2018
Editada: Jan
el 31 de Mayo de 2018
Examine the case of m=0, K=5. Then your function is:
fun = @(x) imag(exp(-1i)) ./ x;
% Or
fun = @(x) sin(-1) ./ x;
You integrate from 0 to Inf. Check the value a x=0:
fun(0)
-Inf
The integral from 0 to 1 is -Inf already. Why do you expect to get a finite value if you expand the integral until x=Inf?
The integral of sin(-1)/x can be found symbolically also: sin(-1) * ln(x) .
2 comentarios
Jan
el 1 de Jun. de 2018
@John D.: There is a pole at x=0 for the function sin(-1)/x. Integrating over a pole is a mathematical problem. You can cope with it by starting at a small value, but then it is not the interval from 0 to Inf anymore. The smaller the distance to x=0 get as left limit of the integral, the large is the result and it reaches infinity for x=0. So there is no meaningful lower limit to choose. It is not a numerical problem, but the mathematical nature of the equation.
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!