# Series with ArcTan gives wrong symbolic answer in Wolfram Language

Bug introduced after 9, persisting through 12.2.

Recently, I have found a very bad problem with Wolfram Language. It gives the wrong answer for a quite simple expression!

When calculating

Series[ArcTan[A + 1/x], {x, 0, 2},  Assumptions -> A > 0 && x > 0]


I get the wrong answer (tested in wolfram cloud and in Mathematica 12.1.1.0)

I am absolutely sure that the correct answer should be

There is a plot of these functions to demonstrate the issue

How to get rid of the problem?

UPD More obvious issue (thank to @MichaelE2):

UPD#2 Working around.

The result in v10.3 is correct.

The result in v11.3 is incorrect.

The corresponding post is in Wolfram Community.

• Not a particularly satisfying workaround: For n=2, Series[Series[ArcTan[A + 1/x], {x, 0, 2 n}, Assumptions -> A > 0 && x > 0], {x, 0, n}]. Seems to work and be necessary for higher n. -- I'd say it's a bug and you should report it to WRI. – Michael E2 Mar 4 at 19:35
• When you calculate the series, you assume A constant and x variable. However, in your plot, x is constant and A variable. You can not this purely graphically, the slope for A==0 should be negative not positive. When you plot x as a variable, the plot looks much better. – Daniel Huber Mar 4 at 19:46
• This does look to be a bug. Compare to In[291]:= Series[ArcTan[aa + x], {x, Infinity, 2}, Assumptions -> aa > 0 && x > 1000] Out[291]= SeriesData[x, DirectedInfinity[1], {Rational[1, 2] Pi, -1, aa}, 0, 3, 1] – Daniel Lichtblau Mar 4 at 20:00
• @DanielHuber When you plot vs. x, you should try to show the series is O[x]^3. It's clearly not, but the OP's "correct answer" is: Block[{ A = 2, f = (ArcTan[ A + 1/x] - {Normal@ Series[ArcTan[A + 1/x], {x, 0, 2}, Assumptions -> A > 0 && x > 0], \[Pi]/2 - x + A x^2})/x^3}, Plot[f, {x, 0, 1}, WorkingPrecision -> 16] ] – Michael E2 Mar 4 at 23:35
• Reported as a bug. – Daniel Lichtblau Mar 5 at 0:31