# Possible error in solving Improper integral

**URL:** <https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329>\
**Category:** Questions\
**Tags:** calculus, numerical-computation\
**Created:** [April 2, 2025, 8:48am UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329 "2025-04-02T08:48:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![juniotor2023](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@juniotor2023](https://community.wolfram.com/u/juniotor2023)\
**Post date:** [April 2, 2025, 8:48am UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/1 "2025-04-02T08:48:31Z")

</div>

NIntegrate[ArcTan/(x^2 - x + 1), {x, 0, Infinity}]

```
1.89941
 Integrate[ArcTan[x]/(x^2 - x + 1), {x, 0, Infinity}] // N

```

1.89941 - 3.64593 I !!!

```
Integrate[ArcTan[x]/(
  x^2 - x + 1), {x, 0, Infinity}] -> ( x -> (1 - y)/(1 + y )) -> 
  Integrate[(2 ArcTan[(1 - y)/(1 + y)])/(1 + 3 y^2), {y, -1, 1}] -> 
   2 Integrate[(Pi/4 - ArcTan[y])/(1 + 3 y^2), {y, -1, 1}] -> 
    Pi/2 Integrate[1/(1 + 3 y^2), {y, -1, 1}] - 
      2 Integrate[ArcTan[y]/(1 + 3 y^2), {y, -1, 1}] -> \[Pi]^2/(
      3 Sqrt[3]) - 0

N[\[Pi]^2/(3 Sqrt[3])]

```

1.89941

[improper-integral.nb](https://community.wolfram.com/uploads/short-url/x1ThudcNqGVHnAUI1mUiZhKrRXl.nb) (6.97 KB)

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [April 2, 2025, 1:08pm UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/2 "2025-04-02T13:08:01Z")

</div>

Let us try a workaround. The primitive given by Mathematica is discontinuous:

```
f[x_] = Integrate[ArcTan[x]/(x^2 - x + 1), x]
Plot[f[x], {x, 0, Infinity}]

```

This is where the discontinuity occurs:

```
FunctionDiscontinuities[f[x], x, Complexes];
FullSimplify[%, Element[x, Reals]]

```

The full integral can be calculated this way:

```
disc = 2 + Sqrt[3];
f0 = f[0];
fdisc0 = Limit[f[x], x -> disc, Direction -> "FromBelow"];
fdisc1 = Limit[f[x], x -> disc, Direction -> "FromAbove"];
finfinity = Limit[f[x], x -> Infinity];
finfinity - fdisc1 + fdisc0 - f0 // FullSimplify
% // N

```

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [April 2, 2025, 5:31pm UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/3 "2025-04-02T17:31:45Z")

</div>

This appears to be a bug in `Integrate`.

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [April 2, 2025, 6:31pm UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/4 "2025-04-02T18:31:39Z")

</div>

This comment can be deleted.

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [April 2, 2025, 6:52pm UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/5 "2025-04-02T18:52:05Z")

</div>

Another way:

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/b3dad58b-8eb4-4ce9-b5a9-c2d12e72caa5)

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [April 3, 2025, 10:08am UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/6 "2025-04-03T10:08:25Z")

</div>

It seems that `FullSimplify` changes the numerical value of an expression a lot:

```
In[69]:= a = finfinity - fdisc1 + fdisc0 - f0;
a // N
FullSimplify[a] // N

Out[70]= -0.474852 - 1.19435 I

Out[71]= 1.89941 + 0. I

```

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [April 3, 2025, 3:48pm UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/7 "2025-04-03T15:48:01Z")

</div>

`FullSimplify` might not have changed the numeric value at all. What might instead have changed is their numerical conditioning. This can be checked by using e.g. `N[...,50]`.

---

<div class="post-metadata">

**Author:** ![juniotor2023](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@juniotor2023](https://community.wolfram.com/u/juniotor2023)\
**Post date:** [April 4, 2025, 4:45am UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/8 "2025-04-04T04:45:28Z")

</div>

In[21]:=  
Integrate[ArcTan/(x^2 - x + 1), {x, 0, Infinity}] // FullSimplify

```
Out[21]= 1/(
 288 Sqrt[
  3]) (121 \[Pi]^2 - 
   36 (ArcCos[2]^2 - 4 Log[2] Log[28 - 16 Sqrt[3]] + 
      2 Log[8 - 4 Sqrt[3]]^2 + 
      4 (PolyLog[2, 1 - (-1)^(1/6)] + 
         PolyLog[2, 1/2 ((2 + I) - Sqrt[3])] + 
         PolyLog[2, 2/((2 - I) + Sqrt[3])] + 
         PolyLog[2, 2/((2 + I) + Sqrt[3])])))

In[22]:= N[%]

Out[22]= 1.89941 - 3.20494*10^-17 I

```

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [April 4, 2025, 11:14am UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/9 "2025-04-04T11:14:35Z")

</div>

Is it `Accuracy` that does a poor job here?

```
int = Integrate[ArcTan[x]/(x^2 - x + 1), {x, 0, Infinity}];
int // N
% // Accuracy

```

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [April 4, 2025, 2:10pm UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/10 "2025-04-04T14:10:05Z")

</div>

When you used `N` without a second argument, it works with machine numbers and `Accuracy/Precision` are not really meaningful since they are not tracked.

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [April 4, 2025, 2:18pm UTC](https://community.wolfram.com/t/possible-error-in-solving-improper-integral/25329/11 "2025-04-04T14:18:06Z")

</div>

Jose,

What you show using `FullSimplify` is fine of course. I believe there may be a version- or timing-dependent bug wherein it can give an inequivalent result. Yours is correct and the use of simplification also makes it numerically “nice” (as in well-conditioned).

I may need to file a report about this, if I find that it is incorrect in our development version.

— edit —  
I have filed a report.  
— end edit —
