Cauchy integral theorem vs. integral formula
5 次查看(过去 30 天)
显示 更早的评论
Let's have the following integral:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423818/image.png)
Here y and η are real and positive number. We can solve this integral using Cachy integral theorem by converting this integeral to a complex integral. Let's assume a contour over upper half of the complex plane. Then, we will have:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423823/image.png)
this integral have two simple poles at
and
. The residues at both poles are
and
, respectively. Hence, the total integral will be:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423828/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423833/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423838/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423843/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423853/image.png)
Now, I want to check that if this integral is actually zero, using numerical integration. For that I write the following code:
clear; clc;
a = -1000000; %close to -infinity
b = 1000000; %close to +infinity
n = rand(1); %\eta: some randome number
y = rand(1)*10; %some randome number
f = @(x, n, y) 1 ./ ((x - 1i*n) .* (x - y - 1i*n));
x = linspace(a,b,1e5); dx =x(2)-x(1);
yy = f(x,n,y);
%plot(x,yy)
sum = sum(yy)*dx
this gives me number for one set of random n and y.
1.3303 + 0.2697i
which is not near to zero. what could be the reason?
0 个评论
采纳的回答
Paul
2023-7-1
Hi Luqman,
The numerical integration is using a step size that is proably too large to capture the rapid variation in the integrand near the poles. And the limits of the the numerical integration are going way out into the tails of the integrand that are not really contributing mugh to the integral.
Original code
clear; clc;
a = -1000000; %close to -infinity
b = 1000000; %close to +infinity
rng(101)
n = rand(1); %\eta: some randome number
y = rand(1)*10; %some randome number
f = @(x, n, y) 1 ./ ((x - 1i*n) .* (x - y - 1i*n));
x = linspace(a,b,1e5); dx =x(2)-x(1);
dx % large relative to 1/x
yy = f(x,n,y);
yy([1 end])
%plot(x,yy)
% don't override names of built-in functions
thesum = sum(yy)*dx
Tighten the limits, which also makes the dx smaller
x = linspace(-30,60,1e5); dx =x(2)-x(1);
dx
yy = f(x,n,y);
yy([1 end])
%plot(x,yy)
thesum = sum(yy)*dx
Also, we can use integral
g = @(x) f(x,n,y);
integral(g,-inf,inf)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!