Clear Filters
Clear Filters

Why can't I get this integration to work?

1 view (last 30 days)
Hi, I'm trying to integrate the function I(z) from -infinity to infinity. This is my code:
syms P w0 r n lamda z
Pi = sym(pi);
zR = Pi*w0^2*n/lamda;
I(z) = 2*P*zR^2/(Pi*w0^2)*1/(zR^2+z^2)*exp(-2*r^2*zR^2/(w0^2*zR^2+w0^2*z^2));
I1 = int(I, z, -inf, inf)
I1 = 
but it just prints
I1 = int((2*P*n^2*w0^2*pi*exp(-(2*n^2*r^2*w0^4*pi^2)/(lamda^2*(w0^2*z^2 + (n^2*w0^6*pi^2)/lamda^2))))/(lamda^2*(z^2 + (n^2*w0^4*pi^2)/lamda^2)), z, -Inf, Inf)
Can someone tell me what I'm doing wrong?

Accepted Answer

Walter Roberson
Walter Roberson on 6 Oct 2023
Moved: Walter Roberson on 6 Oct 2023
syms P w0 r n lamda z real
Pi = sym(pi);
zR = Pi*w0^2*n/lamda;
I(z) = 2*P*zR^2/(Pi*w0^2)*1/(zR^2+z^2)*exp(-2*r^2*zR^2/(w0^2*zR^2+w0^2*z^2));
IE = expand(I)
IE(z) = 
I1 = int(IE, z, -inf, inf)
I1 = 
Now look at the form of that integral. Can we find a simpler integral that has the same general form but still cannot be integrated? Yes.
syms B C x
F = exp(-B/(x^2+C))
F = 
int(F, x, -inf, inf)
ans = 
A key point for this is that if you hardcode B as 1 then MATLAB can proceed, and likewise if you hard-code C as 0. But the combination of the two is more than MATLAB can deal with.
Maple is not able to deal with this integral either
Your actual integral is worse than this.
Your basic problem, then, is that there is no closed form integral for that expression that can be found by MATLAB (or Maple either)

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!