Numerical Integration warning

  • MATLAB
  • Thread starter EngWiPy
  • Start date
  • #1
1,367
61
Hi,

I am trying to evaluate the following integral numerically in MATLAB

[tex]\int_0^{\infty}\frac{e^{-jt}E_1^2(-jt)}{t}\,dt[/tex]

where ##j=\sqrt{-1}##, and ##E_1(x)## is the exponential integral.

My code is

Code:
fun = @(x) (exp(-1i*x).*(expint(-1i*x)).^2)./x;
q = integral(fun,0,Inf)
but I get the following warning message

Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 3.2e+04. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
What does this mean? Does it mean that the integral doesn't exist? Or I need to increase the precision?

Thanks
 

Answers and Replies

  • #3
1,367
61
Thanks, but I need a more specific answer to what is wrong in my case. The link you provided indicates there is a problem at certain values for their expression, which are different than mine.
 
  • #4
tnich
Homework Helper
1,048
336
Hi,

I am trying to evaluate the following integral numerically in MATLAB

[tex]\int_0^{\infty}\frac{e^{-jt}E_1^2(-jt)}{t}\,dt[/tex]

where ##j=\sqrt{-1}##, and ##E_1(x)## is the exponential integral.
There is no standard definition of ##E_1(x)##. Is it your intent to find a value for ##\int_0^{\infty}\frac{e^{-jt}}{t}\left(\int_{-jt}^{\infty} \frac {e^{-x}}x~dx\right)^2\,dt## ?
Note in particular the lower integration limit, i.e. ##-jt##.
 
  • #5
1,367
61
There is no standard definition of ##E_1(x)##. Is it your intent to find a value for ##\int_0^{\infty}\frac{e^{-jt}}{t}\left(\int_{-jt}^{\infty} \frac {e^{-x}}x~dx\right)^2\,dt## ?
Note in particular the lower integration limit, i.e. ##-jt##.
Yes, I use this definition of the exponential integral. So, I cannot evaluate the exponential integral because of the lower limit?
 
  • #6
tnich
Homework Helper
1,048
336
Yes, I use this definition of the exponential integral. So, I cannot evaluate the exponential integral because of the lower limit?
I asked that question because a lower limit of ##jt## for the inner integral (without the minus sign) would allow you to find an analytic solution. However, I think it is the lower limit (zero) of the outer integral that is causing your problem. Try a small positive value for that limit and see if MATLAB finds a solution. I think you will find that as that lower limit decreases toward zero, the value of the integral gets very large very quickly.
 
  • #7
1,367
61
I asked that question because a lower limit of ##jt## for the inner integral (without the minus sign) would allow you to find an analytic solution. However, I think it is the lower limit (zero) of the outer integral that is causing your problem. Try a small positive value for that limit and see if MATLAB finds a solution. I think you will find that as that lower limit decreases toward zero, the value of the integral gets very large very quickly.
When I put 0.001 as a lower limit instead of zero, I didn't get the warning. But I got it again when I changed the power of the exponential integral.

I have been trying to find an analytical solution, but with no success so far. I found some formulas for ##E_1^m(x)## in terms of simpler functions like this one

[tex]E_s^m(x)=\frac{1}{\Gamma(m+1)}\int_1^{\infty}\log(t)^m\,t^{-s}\exp(-tx)\,dt[/tex]

but stuck at evaluating an integral in the form of ##\int_0^{\infty}\frac{e^{-jt\alpha}}{t}\,dt## numerically.

Why the negative sign won't allow me to find an analytical solution? and what is the solution with a positive sign?

Thanks
 
Last edited:
  • #8
tnich
Homework Helper
1,048
336
When I put 0.001 as a lower limit instead of zero, I didn't get the warning. But I got it again when I changed the power of the exponential integral.

I have been trying to find an analytical solution, but with no success so far. I found some formulas for ##E_1^m(x)## in terms of simpler functions like this one

[tex]E_s^m(x)=\frac{1}{\Gamma(m+1)}\int_1^{\infty}\log(t)^m\,t^{-s}\exp(-tx)\,dt[/tex]

but stuck at evaluating an integral in the form of ##\int_0^{\infty}\frac{e^{-jt\alpha}}{t}\,dt## numerically.

Why the negative sign won't allow me to find an analytical solution? and what is the solution with a positive sign?

Thanks
With ##jt## as the lower limit you have ##\int f'(t)f^2(t)~dt##.
 
  • #9
1,367
61
MATLAB gives me wrong results. I am expecting a real number result between 0 and 1, but it gives me a large number in the order of ##10^3## and more!! How can I address the warning properly? I think this warning says something about the wrong result.
 
  • #10
tnich
Homework Helper
1,048
336
MATLAB gives me wrong results. I am expecting a real number result between 0 and 1, but it gives me a large number in the order of ##10^3## and more!! How can I address the warning properly? I think this warning says something about the wrong result.
Series representations of ##E_1(z)## include a ##-ln(z)## term. The value of ##-ln(0)## is ##\infty##. Why do you expect your integral to be finite?
If you work out the integral ##\int f'(t)f^2(t)~dt## with ##f(t) = E_1(jt)##, and then set ##t=0##, what do you get?
 
Last edited by a moderator:
  • #11
1,367
61
Series representations of ##E_1(z)## include a ##-ln(z)## term. The value of ##-ln(0)## is ##\infty##. Why do you expect your integral to be finite?
If you work out the integral ##\int f'(t)f^2(t)~dt## with ##f(t) = E_1(jt)##, and then set ##t=0##, what do you get?
Let me answer your question with a question: I am trying to find the cumulative distribution function (CDF) of a random variable from the characteristic function (CF). Now suppose that all the steps in evaluating the characteristic function, and the formula to find the CDF from the CF were correct, is it possible then to get an indefinite result? That is why I expect to get a finite result between 0 and 1 after some scaling, and the results here don't make sense in light of that, and I am suspecting to have some implementation issues (unless something wrong in the mathematical derivations).
 
Last edited:
  • #12
56
10
[I'll just throw this out as an idea. There are a few sites online that perform integrations. Although in the past I was surprised by their capabilities, I'm not sure whether they are sophisticated enough to handle what you're doing. But that approach could take you outside of the Matlab realm--to potentially provide data points for comparison purposes.]
 
  • #13
1,367
61
I am tying to have Mathematica installed. I have never used MATLAB for numerical integration before, but I used Mathematica, and I think it is better in handling numerical integration than MATLAB. Anyway, could you provide me with links to some of these websites to try them?
 
  • #15
1,367
61
When I tried to evaluate the integral using the first link, it said that the standard computation time exceeded, and the result was that the integral does not converge.
 
  • #16
56
10
When I tried to evaluate the integral using the first link, it said that the standard computation time exceeded, and the result was that the integral does not converge.
I think subconsciously I remembered occasionally seeing that when I saw the MATLAB limit-error you noted. Not that they are related.

Maybe take a little time and play with the sites. I recall that at least one of them has options for something like: "use numerical only", etc. I guess I'm hoping there may be a way to break the problem down to help isolate things. Maybe one of the resident Math whizzes who are familiar with sites like these can chime in.
 
  • #17
tnich
Homework Helper
1,048
336
Let me answer your question with a question: I am trying to find the cumulative distribution function (CDF) of a random variable from the characteristic function (CF). Now suppose that all the steps in evaluating the characteristic function, and the formula to find the CDF from the CF were correct, is it possible then to get an indefinite result?
The short answer is no.
 
  • #18
tnich
Homework Helper
1,048
336
The short answer is no.
The longer answer is, it looks like you are trying to convolve ##\frac 1 t## with itself. If that is the case, it is difficult to see how it could be either a CDF or a PDF unless it is constrained to a positive domain. In that case, the convolution would be similarly constrained. If that is not what you are trying to do, then maybe you have a mistake somewhere in your formulation or fourier transforms.
 
  • #19
tnich
Homework Helper
1,048
336
The longer answer is, it looks like you are trying to convolve ##\frac 1 t## with itself. If that is the case, it is difficult to see how it could be either a CDF or a PDF unless it is constrained to a positive domain. In that case, the convolution would be similarly constrained. If that is not what you are trying to do, then maybe you have a mistake somewhere in your formulation or fourier transforms.
By the way, your fourier transforms need an ##\omega## in them like this ##\int_{-\infty}^{\infty} e^{-j\omega t} f(t) ~dt##.
 
  • #20
1,367
61
Yes, there must be another variable I dropped for simplicity. Probably I need to check my derivations again. I am basically trying to find the CDF of the following random variable

[tex]\nu=\sum_{k=1}^K\frac{a_k}{b_k}[/tex]

where ##\{a_k, b_k\}## are i.i.d. exponential random variables with parameter 1.
 
  • #21
tnich
Homework Helper
1,048
336
Yes, there must be another variable I dropped for simplicity. Probably I need to check my derivations again. I am basically trying to find the CDF of the following random variable

[tex]\nu=\sum_{k=1}^K\frac{a_k}{b_k}[/tex]

where ##\{a_k, b_k\}## are i.i.d. exponential random variables with parameter 1.
OK. Rather than having me trying to reverse engineer your problem, why don't you just start at the beginning?
 
  • #22
1,367
61
I reached to this formula after asking many questions here over other forums about the mathematical details, and I was stuck on how to evaluate it. So, I was interested in the implementation details, rather than the mathematical derivations here. But if you can add anything to how I can evaluate the CDF mathematically (preferably without resorting to numerical integrations), that would great.
 
  • #23
tnich
Homework Helper
1,048
336
I reached to this formula after asking many questions here over other forums about the mathematical details, and I was stuck on how to evaluate it. So, I was interested in the implementation details, rather than the mathematical derivations here. But if you can add anything to how I can evaluate the CDF mathematically (preferably without resorting to numerical integrations), that would great.
How about a url for the thread with the derivation?
 
  • #24
1,367
61
How about a url for the thread with the derivation?
They were not about the derivations details, but rather the approach. Some members suggested to use the characteristic function because the means of the random variables ##a_k/b_k## are not defined (I originally wanted to use the moment generating function, but it doesn't work in this case). From there I continued from the definition of the characteristic function. But I can give you pieces of the derivations. First, is the characteristic function the way to go in your opinion?
 
  • #25
tnich
Homework Helper
1,048
336
They were not about the derivations details, but rather the approach. Some members suggested to use the characteristic function because the means of the random variables ##a_k/b_k## are not defined (I originally wanted to use the moment generating function, but it doesn't work in this case). From there I continued from the definition of the characteristic function. But I can give you pieces of the derivations. First, is the characteristic function the way to go in your opinion?
I used to ask for help the way you are doing it here. I would give a bare minimum of information and get back an answer that didn't help me.

I think I was parsimonious with information because I was afraid of exposing my ignorance, and I didn't want people to question the assumptions that had gotten me to the point where I was stuck. But in a lot of cases, those very assumptions were leading me astray.

I eventually learned to explain the overall problem I was trying to solve, why I wanted to solve it, and what I had figured out already. I found that people were much more willing to help me when I gave them the big picture, and that I got back useful information.
 

Related Threads on Numerical Integration warning

  • Last Post
Replies
1
Views
722
  • Last Post
Replies
3
Views
2K
Replies
8
Views
2K
Replies
16
Views
736
Replies
1
Views
6K
  • Last Post
Replies
3
Views
1K
  • Last Post
Replies
3
Views
27K
  • Last Post
Replies
4
Views
856
Replies
4
Views
61K
  • Last Post
Replies
2
Views
2K
Top