开发者

NIntegrate fails to converge near a point that is not inside my definite integral?

开发者 https://www.devze.com 2023-04-13 04:21 出处:网络
I am trying to calculate a definite integral.I write: NIntegrate[expression, {x, 0, 1}, WorkingPrecision -> 100]

I am trying to calculate a definite integral. I write:

NIntegrate[expression, {x, 0, 1}, WorkingPrecision -> 100]

"expression" is described below. The WorkingPrecision was added in to help with another error.

I get an error:

"NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in x near {x} = {<<156>>}. NIntegrate obtained <<157>> and <<160>> for the integral and error estimates. >>"

Why am I getting this error for near{x} = {<<156>>} when I am only looking at 0<x<1? And what do the double pointy brackets around the number mean?

The expression is really long, so I think it would be more meaningful to show how I generate it.This is a basic version (some of the exponents I need to be variables, but these are the lowest values, and I still get the error).

F[n_] := (1 - (1 - F[n-1])^2)^2;
F[0] = x;
Expr[n_]:= (1/(1-F[n]))Integrate[D[F[n],x]*x,{x,x,1}];

I get the开发者_如何学JAVA error when I integrate Expr[3] or higher. Oddly, when I use regular Integrate and then //N at the end, I get a complex number for n=2.


The <<156>> does not mean that the integral is being evaluated at x=156. <<>> is called Skeleton and is used to indicate that a large output was suppressed. From the documentation:

Skeleton[n] represents a sequence of n omitted elements in an expression printed with Short or Shallow. The standard print form for Skeleton is <<n>>.


Coming to your integral, here's the error that I get:

NIntegrate fails to converge near a point that is not inside my definite integral?

So you can see that this long number was suppressed in your case (depending on your preferences). The last >> is a link that takes you to the corresponding error message in the documentation.

If you try the advice in the document, which is to increase MaxRecursion, you'll eventually get a new error ::slwcon

NIntegrate fails to converge near a point that is not inside my definite integral?

So this now tells you that either your WorkingPrecision is too small or that you have a singularity (which is brought on by a small working precision). Increasing WorkingPrecision to 200 gives the following output:

NIntegrate fails to converge near a point that is not inside my definite integral?


You can look a little further into the nature of your expressions.

num = Numerator@Expr@3;
den = Denominator@Expr@3;
Plot[{num, den}, {x, 0, 1}, WorkingPrecision -> 100, PlotRange -> All]

NIntegrate fails to converge near a point that is not inside my definite integral?

So beyond 0.7ish, your expression has the potential for serious stability issues, resulting in singularities. It is the numerator rather than the denominator, that requires high precision to converge to the right value.

num /. x -> 0.99
num /. x -> 0.99`100

Out[1]= -0.015625
Out[2]= 1.2683685178049112809413795626911317545171610885215799438968\
06379991565*10^-14

den /. x -> 0.99
den /. x -> 0.99`100

Out[3]= 1.28786*10^-14
Out[4]= 1.279743968014714505561671861369465844697720803022743298030747945923286\
915425027352809730413954909*10^-14

You can see here the difference between the numerator and denominator when you don't have sufficient precision, causing a near singularity.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号