简体   繁体   English

如何避免数值积分中的奇异性

[英]How to avoid Singularity in numerical integration

I want to numerically integrate the following with Matlab:我想将以下内容与 Matlab 进行数值整合:

fun = @(t) (((1 - (-1)^n * cos(n*pi*t/R))) ./ t);
hn = integral(fun, 0, (sqrt(R^2 - x^2)));

For now, I just avoided to evaluate the integral in 0, are they any way to encounter the singularity at this point.现在,我只是避免评估 0 中的积分,他们有什么办法可以在这一点上遇到奇点。

If you use eps instead of 0 as the lower limit in your integral , I guess then you can also make it如果您使用eps而不是0作为integral下限,我想您也可以做到

R=101; 
X=linspace(0,R,1001)';
for n=1:10 
    for c=1:length(X) 
        x=X(c); 
        fun=@(t) (((1 - (-1)^n*cos(n*pi*sqrt(t.^2+x.^2)/R)))./sqrt(t.^2+x.^2)); 
        hn(c,n) = integral(fun,eps,(sqrt(R^2-x^2))); 
    end
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM