# NIntegrate failed to converge to prescribed accuracy for an Integral function with several singular points

The integral function is given as

f[x_] := (110 (1 + x^3) (13 - 1139 x^4 + 26 x^6))/( 3 x (1 - 113 x^4 + 2 x^6) (1 - 58 x^4 + 2 x^6))


with five singular points when x>=0

x0 /. NSolve[x0 (1 - 113 x0^4 + 2 x0^6) (1 - 58 x0^4 + 2 x0^6) == 0 && x0 >= 0, x0]


out[]={0, 0.30684, 0.362775, 5.38511, 7.51664}

when the numerical integration is calculated from 0.2 to 6

NIntegrate[f[x], {x, 0.2, 6},Exclusions -> (x0 /.
NSolve[x0 (1 - 113 x0^4 + 2 x0^6) (1 - 58 x0^4 + 2 x0^6) == 0 &&
x0 >= 0, x0]), Method -> "PrincipalValue"]

(*213.109*)


the value 213.109 is given. However, when the numerical integration is calculated from 0 to 6, a warning is shown

NIntegrate[f[x], {x, 0., 6}, Exclusions -> (x0 /.NSolve[x0 (1 - 113 x0^4 + 2 x0^6) (1 - 58 x0^4 + 2 x0^6) == 0 &&
x0 >= 0, x0]), Method -> "PrincipalValue"]


NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in x near {x} = {4.77568*10^-30}. NIntegrate obtained 361150. and 141538. for the integral and error estimates.

Q1: How could i obtain the right numerical for the integration range from 0 to 6?

Q2: Is there a analytical solution for the integration?

Any help will be appreciated!

• You have to exclude the singularities of f[x]! – Ulrich Neumann Jun 5 at 8:42
• Yeah, the singularities should be excluded. But some other problems still exist, and it is presented in the re-edit question. – keanhy14 Jun 5 at 10:28
• You can't use the principal value method on $[a,b]$ when there is an asymptote (pole) at $a$. Such is the case when the integration range starts at $0$ for your integrand. – Michael E2 Jun 5 at 21:25
• By the way, your integral can be evaluated symbolically (exactly) using Integrate[f[x], {x, a, b}, PrincipalValue -> True] for whatever numbers a and b you wish to choose. If a = 0, then Integrate will tell you that the integral does not converge. – Michael E2 Jun 5 at 21:29
• @MichaelE2 Thank you for your comments. Follow your idea, 'Integrate[f[x],{x,0.2,4},PrincipalValue->True]' gives the result with an imaginary number and the warning message {*Integrate::idiv: Integral of ((1+x^3) (13-1139 x^4+26 x^6))/(x (1-113 x^4+2 x^6) (1-58 x^4+2 x^6)) does not converge on {0.2,4}.* } – keanhy14 Jun 6 at 3:14

The integrand is a rational function, so there is definitely a symbolic solution. It seems that Integrate[f[x], {x, 1/5, 4}] is a bit too hard for Integrate to figure out. But if we use partial fractions and integrate the parts separately, we can get the answer.

roots = x /. Solve[3 x (1 - 113 x^4 + 2 x^6) (1 - 58 x^4 + 2 x^6) == 0, x]

coeffs = Solve[
Table[(110 (1 + x^3) (13 - 1139 x^4 + 26 x^6))/12 ==
Numerator@ Together@Sum[A[k]/(x - roots[[k]]), {k, Length@roots}] /.
x -> roots[[j]],
{j, Length@roots}],
Table[A[k], {k, Length@roots}]
];

int = Sum[
Integrate[A[k]/(x - roots[[k]]) /. First@coeffs, {x, 1/5, 4},
PrincipalValue -> True],
{k, Length@roots}]

N[int, 16]

(*  214.1951292990900 + 0.*10^-14 I  *)


Compare with NIntegrate[]:

NIntegrate[
(110*(1 + x^3)*(13 - 1139*x^4 + 26*x^6))/
(3*x*(1 - 113*x^4 + 2*x^6)*(1 - 58*x^4 + 2*x^6)),
{x, 1/5,
Root[1 - 113*#1^4 + 2*#1^6 & , 3, 0],
Root[1 - 58*#1^4 + 2*#1^6 & , 3, 0], 4},
Method -> "PrincipalValue"]

(*  214.195  *)

• Grateful for your answer! You point out that "there is definitely a symbolic solution when the integrand is a rational funtion", would you mind to recommd some books or other materials for me to learn more about it? – keanhy14 Jun 6 at 13:52
• @keanhy14 It's in most every calculus textbook and follows from the method of partial fractions and the facts that $A/(Bx+C)^k$ and $(Ax + B)/(Cx^2+Dx+E)^k$ can be integrated in terms of $\ln$ and $\arctan$. Over the complex numbers, polynomials can be factored completely into linear factors, so you only need that t $A/(Bx+C)^k$ can be integrated in terms of logarithms. The denominator of your example has distinct linear factors so I used the "shortcut" method for the PF decomposition. See also en.wikipedia.org/wiki/List_of_integrals_of_rational_functions – Michael E2 Jun 6 at 17:19
• That's exactly what i need, thank you! – keanhy14 Jun 7 at 2:08

You have one singular point between 4 and 6. First I find it, then identify it in NIntegrate as {4,singularPoint,6}, and then specify Method->"PrincipalValue":

f[x_] := (110 (x^3 + 1) (26 x^6 - 1139 x^4 + 13))/(
3 x (2 x^6 - 113 x^4 + 1) (2 x^6 - 58 x^4 + 1));
Plot[f[x], {x, 4, 6}]
myRoots = x /. Solve[Denominator[f[x]] == 0, x];
myRoots[] // N
NIntegrate[f[x], {x, 4, myRoots[], 6}, Method ->
"PrincipalValue"]

-1.08626 + 1.72876*10^-15 I

• Thank you for you suggestion of the strategy of "PrincipalValue", and it really works for [4, 6]. However, where the integration range is [0,6]. The warning is shown at x=0, see the re-edit question. – keanhy14 Jun 5 at 10:22
• The function behaviour f[x]~1/xnear x=0 shows that the integration cannot converge! – Ulrich Neumann Jun 5 at 10:30

evaluate the singularities (roots of the denominator)

xEX = x /. NSolve[Denominator[f[x]] == 0, x, Reals]
Plot[f[x], {x, -10, 10}, GridLines -> {xEX, None}] integration

NIntegrate[f[x], {x, 4, 6}, Exclusions -> xEX,Method -> "PrincipalValue"]
(*-1.08626*)

• Thank you for you suggestion! The strategy of "PrincipalValue" really works for [4, 6]. However, when the integration range is [0,6]. The warning is shown at x=0, see the re-edit question. – keanhy14 Jun 5 at 10:25