 SumTools[IndefiniteSum] - Maple Programming Help

Home : Support : Online Help : Mathematics : Discrete Mathematics : Summation and Difference Equations : SumTools : IndefiniteSum Subpackage : SumTools/IndefiniteSum/Indefinite

SumTools[IndefiniteSum]

 Indefinite
 compute closed forms of indefinite sums

 Calling Sequence Indefinite(f, k, opt)

Parameters

 f - expression depending on k k - name opt - (optional) equation of the form failpoints=true or failpoints=false

Description

 • The Indefinite(f, k) command computes a closed form of the indefinite sum of $f$ with respect to $k$.
 • The command uses a combination of algorithms handling various classes of summands. They include the classes of polynomials, rational functions, and hypergeometric terms and j-fold hypergeometric terms, functions for which their minimal annihilators can be constructed, for example, d'Alembertian terms. For more information, see LinearOperators.
 A library extension mechanism is also used to include sums for which an algorithmic approach to finding closed forms does not yet exist. Currently the computable summands include expressions containing the harmonic function, logarithmic function, digamma and polygamma functions, and sin, cos, and the exponential functions.
 • If the option failpoints=true (or just failpoints for short) is specified, then the command returns a pair $s,\left[p,q\right]$, where
 – $s$ is a closed form of the indefinite sum of $f$ w.r.t. $k$, as above,
 – $p$ is a list of intervals $\left[{a}_{1}..{b}_{1},{a}_{2}..{b}_{2},\mathrm{...},{a}_{m}..{b}_{m}\right]$ where $f$ does not exist, and
 – $q$ is a list of points ${k}_{i}$ where the computed sum $s$ does not satisfy the telescoping equation $s\left({k}_{i}+1\right)-s\left({k}_{i}\right)=f\left({k}_{i}\right)$ or does not exist.
 If such points appear in the summation interval, the discrete Newton-Leibniz formula may fail.
 • If the command is unable to compute one of the lists $p,q$, it returns $s,\mathrm{FAIL}$.

Examples

 > $\mathrm{with}\left(\mathrm{SumTools}\left[\mathrm{IndefiniteSum}\right]\right):$

An example of a rationally summable expression:

 > $f≔\frac{1}{{n}^{2}+\mathrm{sqrt}\left(5\right)n-1}$
 ${f}{≔}\frac{{1}}{{{n}}^{{2}}{+}\sqrt{{5}}{}{n}{-}{1}}$ (1)
 > $s≔\mathrm{Indefinite}\left(f,n\right)$
 ${s}{≔}{-}\frac{{1}}{{3}{}\left({n}{-}\frac{{3}}{{2}}{+}\frac{\sqrt{{5}}}{{2}}\right)}{-}\frac{{1}}{{3}{}\left({n}{-}\frac{{1}}{{2}}{+}\frac{\sqrt{{5}}}{{2}}\right)}{-}\frac{{1}}{{3}{}\left({n}{+}\frac{{1}}{{2}}{+}\frac{\sqrt{{5}}}{{2}}\right)}$ (2)

Check the telescoping equation:

 > $\mathrm{evala}\left(\mathrm{Normal}\left(\mathrm{eval}\left(s,n=n+1\right)-s\right),\mathrm{expanded}\right)$
 $\frac{{1}}{{{n}}^{{2}}{+}\sqrt{{5}}{}{n}{-}{1}}$ (3)

A hypergeometrically summable term:

 > $f≔\frac{{2}^{2n-1}}{n\left(2n+1\right)\mathrm{binomial}\left(2n,n\right)}$
 ${f}{≔}\frac{{{2}}^{{2}{}{n}{-}{1}}}{{n}{}\left({2}{}{n}{+}{1}\right){}\left(\genfrac{}{}{0}{}{{2}{}{n}}{{n}}\right)}$ (4)
 > $s≔\mathrm{Indefinite}\left(f,n\right)$
 ${s}{≔}{-}\frac{{{2}}^{{2}{}{n}{-}{1}}}{\left(\genfrac{}{}{0}{}{{2}{}{n}}{{n}}\right){}{n}}$ (5)
 > $\mathrm{normal}\left(\mathrm{expand}\left(\mathrm{eval}\left(s,n=n+1\right)-s\right)\right)$
 $\frac{{\left({{2}}^{{n}}\right)}^{{2}}}{{2}{}{n}{}\left({2}{}{n}{+}{1}\right){}\left(\genfrac{}{}{0}{}{{2}{}{n}}{{n}}\right)}$ (6)

The method of accurate summation:

 > $f≔\frac{1}{5}{\left({\left(\frac{1}{2}+\frac{1}{2}{5}^{\frac{1}{2}}\right)}^{n}-{\left(\frac{1}{2}-\frac{1}{2}{5}^{\frac{1}{2}}\right)}^{n}\right)}^{2}$
 ${f}{≔}\frac{{\left({\left(\frac{{1}}{{2}}{+}\frac{\sqrt{{5}}}{{2}}\right)}^{{n}}{-}{\left(\frac{{1}}{{2}}{-}\frac{\sqrt{{5}}}{{2}}\right)}^{{n}}\right)}^{{2}}}{{5}}$ (7)
 > $\mathrm{Indefinite}\left(f,n\right)$
 ${-}\frac{{3}{}{\left({\left(\frac{{1}}{{2}}{+}\frac{\sqrt{{5}}}{{2}}\right)}^{{n}}{-}{\left(\frac{{1}}{{2}}{-}\frac{\sqrt{{5}}}{{2}}\right)}^{{n}}\right)}^{{2}}}{{10}}{-}\frac{{\left({\left(\frac{{1}}{{2}}{+}\frac{\sqrt{{5}}}{{2}}\right)}^{{n}{+}{1}}{-}{\left(\frac{{1}}{{2}}{-}\frac{\sqrt{{5}}}{{2}}\right)}^{{n}{+}{1}}\right)}^{{2}}}{{10}}{+}\frac{{\left({\left(\frac{{1}}{{2}}{+}\frac{\sqrt{{5}}}{{2}}\right)}^{{n}{+}{2}}{-}{\left(\frac{{1}}{{2}}{-}\frac{\sqrt{{5}}}{{2}}\right)}^{{n}{+}{2}}\right)}^{{2}}}{{10}}$ (8)

Sum of a logarithm of a rational function (provided the argument of the logarithm has constant sign):

 > $\mathrm{sum}\left(\mathrm{ln}\left(2n+1\right),n\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{assuming}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}0\le n$
 ${n}{}{\mathrm{ln}}{}\left({2}\right){+}{\mathrm{ln}}{}\left({\mathrm{\Gamma }}{}\left(\frac{{1}}{{2}}{+}{n}\right)\right)$ (9)
 > $\mathrm{sum}\left(\mathrm{ln}\left(2n+1\right),n\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{assuming}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}n\le -1$
 ${n}{}{\mathrm{ln}}{}\left({2}\right){-}{\mathrm{ln}}{}\left({\mathrm{\Gamma }}{}\left(\frac{{1}}{{2}}{-}{n}\right)\right){+}{I}{}{\mathrm{\pi }}{}{n}$ (10)

Example for the library extension mechanism:

 > $f≔\mathrm{sin}\left(n\right)\mathrm{cos}\left(n+1\right)-\mathrm{\Psi }\left(n\right)$
 ${f}{≔}{\mathrm{sin}}{}\left({n}\right){}{\mathrm{cos}}{}\left({n}{+}{1}\right){-}{\mathrm{\Psi }}{}\left({n}\right)$ (11)
 > $\mathrm{Indefinite}\left(f,n\right)$
 ${-}\frac{{{\mathrm{sin}}{}\left({1}\right)}^{{2}}{}{n}{+}{2}{}{\mathrm{\Psi }}{}\left({n}{+}{1}\right){}{n}{}{\mathrm{sin}}{}\left({1}\right){+}{{\mathrm{cos}}{}\left({n}\right)}^{{2}}{-}{2}{}{\mathrm{\gamma }}{}{\mathrm{sin}}{}\left({1}\right){-}{2}{}{\mathrm{\Psi }}{}\left({n}\right){}{\mathrm{sin}}{}\left({1}\right){-}{2}{}{\mathrm{sin}}{}\left({1}\right){}{n}}{{2}{}{\mathrm{sin}}{}\left({1}\right)}$ (12)

Compute the fail points:

 > $f≔nn!$
 ${f}{≔}{n}{}{n}{!}$ (13)
 > $\mathrm{Indefinite}\left(f,n,'\mathrm{failpoints}'\right)$
 ${n}{!}{,}\left[\left[{-}{\mathrm{\infty }}{..}{-1}\right]{,}\left[\right]\right]$ (14)

Indeed, $f$ is not defined for any negative integer:

 > $\mathrm{eval}\left(f,n=-3\right)$

and limits do not exist:

 > $\mathrm{limit}\left(f,n=-3\right)$
 ${\mathrm{undefined}}$ (15)

A rational example. $f$ and its limit are not defined at $n=0,1,5$, and the correspondent sum $s$ and its limit are not defined at $n=2,3,4$:

 > $f≔\frac{1}{n}+\frac{1}{n-1}-\frac{2}{n-5}$
 ${f}{≔}\frac{{1}}{{n}}{+}\frac{{1}}{{n}{-}{1}}{-}\frac{{2}}{{n}{-}{5}}$ (16)
 > $s,\mathrm{fp}≔\mathrm{Indefinite}\left(f,n,'\mathrm{failpoints}'\right)$
 ${s}{,}{\mathrm{fp}}{≔}\frac{{2}}{{n}{-}{5}}{+}\frac{{2}}{{n}{-}{4}}{+}\frac{{2}}{{n}{-}{3}}{+}\frac{{2}}{{n}{-}{2}}{+}\frac{{1}}{{n}{-}{1}}{,}\left[\left[{0}{..}{1}{,}{5}{..}{5}\right]{,}\left[{2}{,}{3}{,}{4}\right]\right]$ (17)
 > $\mathrm{limit}\left(s,n=2\right)$
 ${\mathrm{undefined}}$ (18)

In the next example, $f$ is hypergeometric term defined for all integers $n$:

 > $f≔\frac{\mathrm{binomial}\left(2n-3,n\right)}{{4}^{n}}$
 ${f}{≔}\frac{\left(\genfrac{}{}{0}{}{{2}{}{n}{-}{3}}{{n}}\right)}{{{4}}^{{n}}}$ (19)
 > $s,\mathrm{fp}≔\mathrm{Indefinite}\left(f,n,'\mathrm{failpoints}'\right)$
 ${s}{,}{\mathrm{fp}}{≔}\frac{{2}{}{n}{}\left({n}{+}{1}\right){}\left(\genfrac{}{}{0}{}{{2}{}{n}{-}{3}}{{n}}\right)}{\left({n}{-}{2}\right){}{{4}}^{{n}}}{,}\left[\left[\right]{,}\left[{2}\right]\right]$ (20)

The sum $s$ is not defined at $n=2$:

 > $\mathrm{eval}\left(s,n=2\right)$

Note that in this example, however, the limit exists:

 > $\mathrm{limit}\left(s,n=2\right)$
 $\frac{{3}}{{8}}$ (21)

but the telescoping equation does not hold at $n=1$:

 > $\left(\mathrm{limit}\left(s,n=2\right)\right)-\mathrm{eval}\left(s,n=1\right)=\mathrm{eval}\left(f,n=1\right)$
 ${-}\frac{{5}}{{8}}{=}{-}\frac{{1}}{{4}}$ (22)

Consequently, if $n=1$ is between summation bounds, the Newton-Leibniz formula is wrong:

 > $\mathrm{sum}\left(f,n=0..10\right)=\mathrm{eval}\left(s,n=11\right)-\mathrm{eval}\left(s,n=0\right)$
 $\frac{{236871}}{{262144}}{=}\frac{{138567}}{{262144}}$ (23)

Rewriting $f$ in terms of GAMMA functions introduces additional singularities at negative integers. These singularities are removable:

 > $\mathrm{f1}≔\mathrm{convert}\left(f,\mathrm{\Gamma }\right)$
 ${\mathrm{f1}}{≔}\frac{{\mathrm{\Gamma }}{}\left({2}{}{n}{-}{2}\right)}{{\mathrm{\Gamma }}{}\left({n}{+}{1}\right){}{\mathrm{\Gamma }}{}\left({n}{-}{2}\right){}{{4}}^{{n}}}$ (24)
 > $s,\mathrm{fp}≔\mathrm{Indefinite}\left(\mathrm{f1},n,'\mathrm{failpoints}'\right)$
 ${s}{,}{\mathrm{fp}}{≔}\frac{{2}{}{n}{}\left({n}{+}{1}\right){}{\mathrm{\Gamma }}{}\left({2}{}{n}{-}{2}\right)}{\left({n}{-}{2}\right){}{\mathrm{\Gamma }}{}\left({n}{+}{1}\right){}{\mathrm{\Gamma }}{}\left({n}{-}{2}\right){}{{4}}^{{n}}}{,}\left[\left[\right]{,}\left[\right]\right]$ (25)

The telescoping equation is valid for all integers $n$ (in the limit):

 > $\mathrm{sum}\left(\mathrm{f1},n=0..10\right)=\mathrm{eval}\left(s,n=11\right)-\left(\mathrm{limit}\left(s,n=0\right)\right)$
 $\frac{{138567}}{{262144}}{=}\frac{{138567}}{{262144}}$ (26)

The singularities of $\mathrm{f1}$ are detected if _EnvFormal (see sum,details) is set to $\mathrm{false}$:

 > $\mathrm{_EnvFormal}≔\mathrm{false}:$
 > $s,\mathrm{fp}≔\mathrm{Indefinite}\left(\mathrm{f1},n,'\mathrm{failpoints}'\right)$
 ${s}{,}{\mathrm{fp}}{≔}\frac{{2}{}{n}{}\left({n}{+}{1}\right){}{\mathrm{\Gamma }}{}\left({2}{}{n}{-}{2}\right)}{\left({n}{-}{2}\right){}{\mathrm{\Gamma }}{}\left({n}{+}{1}\right){}{\mathrm{\Gamma }}{}\left({n}{-}{2}\right){}{{4}}^{{n}}}{,}\left[\left[{-}{\mathrm{\infty }}{..}{2}\right]{,}\left[\right]\right]$ (27)
 > $\mathrm{sum}\left(\mathrm{f1},n=0..10\right)$
 > $\mathrm{_EnvFormal}≔'\mathrm{_EnvFormal}':$