0
$\begingroup$

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

Mathematica result

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]

this works

Why is this?

$\endgroup$
6
  • $\begingroup$ I noticed it works when you say int/. n->-1. This suggests that it is a maths problem to me? $\endgroup$
    – user27119
    Jul 8, 2016 at 17:40
  • $\begingroup$ 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 $\endgroup$
    – Feyre
    Jul 8, 2016 at 17:41
  • 1
    $\begingroup$ 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. $\endgroup$
    – Greg Hurst
    Jul 8, 2016 at 19:43
  • $\begingroup$ @ChipHurst Limits don't seem to work with this 2F1. Any other suggestions? $\endgroup$
    – Michael E2
    Jul 8, 2016 at 19:59
  • $\begingroup$ 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). $\endgroup$
    – Bob Hanlon
    Jul 8, 2016 at 21:20

2 Answers 2

5
$\begingroup$

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.

$\endgroup$
3
$\begingroup$

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[0] == (2 ArcTan[(b + 2 t)/Sqrt[4 - b^2]])/Sqrt[4 - b^2], int[1] == -((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[0] == (2 ArcTan[(b + 2 t)/Sqrt[4 - b^2]])/Sqrt[4 - b^2], int[1] == -((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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.