Rational functions are functions of the form , where
and
are polynomials. Their sums often yield curious results and are very commonly used in mathematics. Today, I will be explaining what was essentially a product of my curiosity turning into a very elegant solution for evaluating them.
Warmup ⎇
We know that for an infinite sum of a rational function to be convergent, must hold. This is trivially proven using a combination of the p-test and the comparison test. For example, the sum
is clearly convergent, since . On the other hand,
is divergent, since .
Consider the sum
where is a constant. The following equalities hold:
To attempt at understanding why is this happening, recall the following identity due to Euler (1770) for :
A concise proof using Mittag-Leffler's theorem follows. Given as the residues:
Using the contour integral where is a circle enclosing first
poles of
:
Using the residue theorem we find:
Consider to remove a singularity.
is found using the residue theorem as follows:
Hence:
Substitute and rearrange:
Knowing where the first part of the equality comes from, the next logical step is reasoning about the second equality:
Use the recurrence relation of the digamma function once:
Now it is possible to apply the digamma reflection formula given as follows:
The problem reduces to:
Which concludes the proof.
Conjecture ⎇
I state the following conjecture:
Every infinite sum of a rational function, the denominator of which does not contain roots of multiplicity
2, can be meaningfully expressed as a finite sum of the terms in form
where
and
are functions of
.
The following part of the post focuses on sheding light on this theorem from multiple angles and using it to derive a method for efficiently evaluating infinite sums of rational functions. While it is possible to special-case the general result for certain functions (cubic and quadratic), it will not be done in the example code for the sake of simplicity.
The algorithm for convergent series is as follows. Denote the roots of the polynomial as
. The following equality holds if
:
If (i.e. the rational function is not an inverse of some polynomial), the formula is as follows:
Demonstration ⎇
Consider the following sum:
Compute the derivative of :
The approximate roots of are found using numerical methods as follows:
Recall the formula:
Computing the partial sums yields the sum , and this value negated is the approximate value of the sum when computed by iteration until convergence.
Implementation ⎇
A KamilaLisp implementation follows. Define a few helper methods: one to substitute into some polynomial
, compute
and evaluate a polynomial at a given point.
; Utility functions.
(def polyevl
[(inner-product cmplx64:+ cmplx64:*) #0 ^cmplx64:**&[#0 range@tally]])
(def polyderv cdr@[* #0 range@tally])
(defun poly+1 (c)
(let-seq
(def bin-mat (:[:^binomial #0 \range $(+ 1)]@range@tally c))
(def coeff-mat (:$(take (tally c)) (* c bin-mat)))
(:$(foldl1 +)@transpose coeff-mat)))Further, the direct implementation of the algorithm is given as follows:
(defun rsum (p q)
(let-seq
(def q+1 (poly+1 q))
(def p+1 $(polyevl (poly+1 p)))
(def q+1p $(polyevl (polyderv q+1)))
(def R (cmplx64:solve q+1))
(def V [/ [* p+1 cmplx64:digamma@-] q+1p])
(cmplx64:neg (foldl + 0 (:V R)))))
