简体   繁体   English

如何克服数值积分中的奇点(在 Matlab 或 Mathematica 中)

[英]How to overcome singularities in numerical integration (in Matlab or Mathematica)

I want to numerically integrate the following:我想在数字上整合以下内容:

eq1

where在哪里

eq2

and a , b and β are constants which for simplicity, can all be set to 1 .abβ是常数,为简单起见,都可以设置为1

Neither Matlab using dblquad , nor Mathematica using NIntegrate can deal with the singularity created by the denominator.使用dblquad的 Matlab 和使用NIntegrate的 Mathematica 都不能处理分母产生的奇点。 Since it's a double integral, I can't specify where the singularity is in Mathematica.由于它是一个双积分,我无法指定 Mathematica 中的奇点在哪里。

I'm sure that it is not infinite since this integral is based in perturbation theory and without the我确信它不是无限的,因为这个积分是基于微扰理论并且没有

在此处输入图像描述

has been found before (just not by me so I don't know how it's done).以前发现过(只是不是我发现的,所以我不知道它是如何完成的)。

Any ideas?有任何想法吗?

(1) It would be helpful if you provide the explicit code you use. (1) 如果您提供您使用的显式代码,将会很有帮助。 That way others (read: me) need not code it up separately.这样其他人(阅读:我)不需要单独编码。

(2) If the integral exists, it has to be zero. (2) 如果积分存在,它必须为零。 This is because you negate the n(y)-n(x) factor when you swap x and y but keep the rest the same.这是因为您在交换 x 和 y 时否定了 n(y)-n(x) 因子,但保持 rest 相同。 Yet the integration range symmetry means that amounts to just renaming your variables, hence it must stay the same.然而,积分范围对称意味着仅重命名变量,因此它必须保持不变。

(3) Here is some code that shows it will be zero, at least if we zero out the singular part and a small band around it. (3) 这里有一些代码显示它将为零,至少如果我们将奇异部分和围绕它的小带归零的话。

a = 1;
b = 1;
beta = 1;
eps[x_] := 2*(a-b*Cos[x])
n[x_] := 1/(1+Exp[beta*eps[x]])
delta = .001;
pw[x_,y_] := Piecewise[{{1,Abs[Abs[x]-Abs[y]]>delta}}, 0]

We add 1 to the integrand just to avoid accuracy issues with results that are near zero.我们在被积函数上加 1 只是为了避免结果接近于零的准确性问题。

NIntegrate[1+Cos[(x+y)/2]^2*(n[x]-n[y])/(eps[x]-eps[y])^2*pw[Cos[x],Cos[y]],
  {x,-Pi,Pi}, {y,-Pi,Pi}] / (4*Pi^2)

I get the result below.我得到下面的结果。

NIntegrate::slwcon: 
   Numerical integration converging too slowly; suspect one of the following:
    singularity, value of the integration is 0, highly oscillatory integrand,
    or WorkingPrecision too small.

NIntegrate::eincr: 
   The global error of the strategy GlobalAdaptive has increased more than 
    2000 times. The global error is expected to decrease monotonically after a
     number of integrand evaluations. Suspect one of the following: the
     working precision is insufficient for the specified precision goal; the
     integrand is highly oscillatory or it is not a (piecewise) smooth
     function; or the true value of the integral is 0. Increasing the value of
     the GlobalAdaptive option MaxErrorIncreases might lead to a convergent
     numerical integration. NIntegrate obtained 39.4791 and 0.459541
     for the integral and error estimates.

Out[24]= 1.00002

This is a good indication that the unadulterated result will be zero.这是一个很好的迹象,表明纯正的结果将为零。

(4) Substituting cx for cos(x) and cy for cos(y), and removing extraneous factors for purposes of convergence assessment, gives the expression below. (4) 用 cx 代替 cos(x) 和 cy 代替 cos(y),并去除无关因素以进行收敛性评估,得到以下表达式。

((1 + E^(2*(1 - cx)))^(-1) - (1 + E^(2*(1 - cy)))^(-1))/
 (2*(1 - cx) - 2*(1 - cy))^2

A series expansion in cy, centered at cx, indicates a pole of order 1. So it does appear to be a singular integral.以 cx 为中心的 cy 中的级数展开表示一个 1 阶极点。所以它看起来确实是一个奇异积分。

Daniel Lichtblau丹尼尔·利赫特布劳

The integral looks like a Cauchy Principal Value type integral (ie it has a strong singularity).积分看起来像一个柯西主值类型的积分(即它具有很强的奇异性)。 That's why you can't apply standard quadrature techniques.这就是为什么你不能应用标准的正交技术。

Have you tried PrincipalValue->True in Mathematica's Integrate?您是否在 Mathematica 的 Integrate 中尝试过 PrincipalValue->True?

In addition to Daniel's observation about integrating an odd integrand over a symmetric range (so that symmetry indicates the result should be zero), you can also do this to understand its convergence better (I'll use latex, writing this out with pen and paper should make it easier to read; it took a lot longer to write than to do, it's not that complicated):除了 Daniel 关于在对称范围内积分奇数被积函数的观察(因此对称性表明结果应该为零),您还可以这样做以更好地理解它的收敛性(我将使用 latex,用笔和纸写出来应该使它更容易阅读;写比做要花更长的时间,这并不复杂):

First, epsilon(x)-\epsilon(y)\propto\cos(y)-\cos(x)=2\sin(\xi_+)\sin(\xi_-) where I have defined \xi_\pm=(x\pm y)/2 (so I've rotated the axes by pi/4).首先, epsilon(x)-\epsilon(y)\propto\cos(y)-\cos(x)=2\sin(\xi_+)\sin(\xi_-)其中我定义\xi_\pm=(x\pm y)/2 (所以我将轴旋转了 pi/4)。 The region of integration then is \xi_+ between \pi/\sqrt{2} and -\pi/\sqrt{2} and \xi_- between \pm(\pi/\sqrt{2}-\xi_-) .那么积分区域是\pi/\sqrt{2}-\pi/\sqrt{2}之间的\xi_+\xi_- \pm(\pi/\sqrt{2}-\xi_-)之间的 \xi_- 。 Then the integrand takes the form \frac{1}{\sin^2(\xi_-)\sin^2(\xi_+)} times terms with no divergences.那么被积函数的形式为\frac{1}{\sin^2(\xi_-)\sin^2(\xi_+)}乘以没有分歧的项。 So, evidently, there are second-order poles, and this isn't convergent as presented.因此,显然,存在二阶极点,这并不像呈现的那样收敛。

Perhaps you could email the persons who obtained an answer with the cos term and ask what precisely it is they did.也许您可以 email 获得 cos 项答案的人并询问他们究竟做了什么。 Perhaps there's a physical regularisation procedure being employed.也许正在使用物理正则化程序。 Or you could have given more information on the physical origin of this (some sort of second order perturbation theory for some sort of bosonic system?), had that not been off-topic here...或者你可以提供更多关于这个物理起源的信息(某种玻色子系统的某种二阶微扰理论?),如果这不是题外话......

May be I am missing something here, but the integrand f[x,y]=Cos^2[(x+y)/2]*(n[x]-n[y])/(eps[x]-eps[y]) with n[x]=1/(1+Exp[Beta*eps[x]]) and eps[x]=2(ab*Cos[x]) is indeed a symmetric function in x and y: f[x,-y]= f[-x,y]=f[x,y].可能是我在这里遗漏了一些东西,但是被积函数 f[x,y]=Cos^2[(x+y)/2]*(n[x]-n[y])/(eps[x]-eps [y]) 与 n[x]=1/(1+Exp[Beta*eps[x]]) 和 eps[x]=2(ab*Cos[x]) 确实是 x 和 y 中的对称 function: f[x,-y]= f[-x,y]=f[x,y]。 Therefore its integral over any domain [-u,u]x[-v,v] is zero.因此它在任何域 [-u,u]x[-v,v] 上的积分为零。 No numerical integration seems to be needed here.这里似乎不需要数值积分。 The result is just zero.结果只是零。

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

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