Numerical Integration warning issue

4 visualizzazioni (ultimi 30 giorni)
John D.
John D. il 31 Mag 2018
Commentato: Jan il 1 Giu 2018
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

Risposte (1)

Jan
Jan il 31 Mag 2018
Modificato: Jan il 31 Mag 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 Commenti
John D.
John D. il 31 Mag 2018
Modificato: John D. il 31 Mag 2018
What if I put the lower limit a very small number, but not a zero. Is this supposed to solve the problem? I tried it, and it doesn't. Is the integral in essence not integrable?
Jan
Jan il 1 Giu 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.

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by