# Integral of rational function is indeterminate

I need to integrate the rational function

$$\frac{t^n}{bt+t^2+1}$$

where $n$ is a integer. Of course, it's no problem for Mathematica to do this.

int = Integrate[t^n/(t^2 + b*t + 1), t] // FullSimplify But if I try to set $n$ after the integration, the result is Indeterminate.

int /. n -> 1

Indeterminate


Setting $n$ before the integration, however, leads to a nice expression.

Integrate[t^1/(t^2 + b*t + 1), t] Why is this?

• I noticed it works when you say int/. n->-1. This suggests that it is a maths problem to me? Jul 8, 2016 at 17:40
• Curiously, taking the D of the function again brings back the original function. Plotting Plot3D[int /. {b -> 1}, {t, 0, 3}, {n, -4, 4}] reveals weird things going on when n>-1 Jul 8, 2016 at 17:41
• Take a limit instead. A simpler example is Integrate[x^a, x] gives x^(a+1)/(a+1) which clearly isn't valid for a == -1. Jul 8, 2016 at 19:43
• @ChipHurst Limits don't seem to work with this 2F1. Any other suggestions? Jul 8, 2016 at 19:59
• Use SetDelayed:int[n_, b_, t_] := Integrate[t^n/(t^2 + b*t + 1), t] //FullSimplify then int[#, b, t] & /@ Range[-2, 2] (change Range to fit your needs). Jul 8, 2016 at 21:20

The problem is that the two Hypergeometric2F1 terms each take the value of ComplexInfinity when n=1. The resulting difference is necessarily undefined. If Mathematica substitutes n->1 before evaluating the integral, it is able to use a more specific integration technique.

This sort of behaviour occurs frequently: Mathematica results that are generically true may fail for specific values - unfortunate if these are the values you want.

To expand on my comment: in Gradshteyn and Ryzhik (the seventh edition, at least), they list formula 2.174, which I think is more practical for computational purposes than the direct output of Mathematica. Translated into Mathematica syntax for the OP's specific case, if we have

int[n_] := Integrate[t^n/(t^2 + b t + 1), t]


then there is the useful (inhomogeneous) difference equation

int[n] == t^(n - 1)/(n - 1) - b int[n - 1] - int[n - 2]


This can in fact be fed into either of RSolve[] or DifferenceRoot[] to yield a useful solution if desired; RSolve[{int[n] == t^(n - 1)/(n - 1) - b int[n - 1] - int[n - 2], int == (2 ArcTan[(b + 2 t)/Sqrt[4 - b^2]])/Sqrt[4 - b^2], int == -((b ArcTan[(b + 2 t)/Sqrt[4 - b^2]])/Sqrt[4 - b^2]) + 1/2 Log[1 + b t + t^2]}, int[n], n] will in fact yield a (complicated!) expression involving ${}_2 F_1$ that works for nonnegative integer n, and DifferenceRoot[Function[{int, n}, {int[n] == t^(n - 1)/(n - 1) - b int[n - 1] - int[n - 2], int == (2 ArcTan[(b + 2 t)/Sqrt[4 - b^2]])/Sqrt[4 - b^2], int == -((b ArcTan[(b + 2 t)/Sqrt[4 - b^2]])/Sqrt[4 - b^2]) + 1/2 Log[1 + b t + t^2]}]] shows that int[n] satisfies a four-term homogeneous difference equation, and is already directly useful besides.