# Computing a limit with assumptions

This program solves the recurrence for the expected time to extinction of a linear birth and death process with arrival rate A and death rate q A, and then attempts to simplify.

t = a[n] /.
RSolve[{A n  a[n + 1] - A (1 + q) n  a[n] + q A  n  a[n - 1] + 1 == 0,
a[0] == 0, a[K] == 0}, a[n], n] // FullSimplify


But, Mathematica refuses to simplify, the answer contains -(1/q)^K q^K. Then, I want to compute a limit with Assumptions.

Limit[t, K -> Infinity, Assumptions -> {K > 0, A>0, 0 < q < 1}]


But Mathematica refuses, and cannot compute the limit

Limit::alimv: Warning: Assumptions that involve the limit variable are ignored.


Is it possible to do better?

The answer is yes! as shown by the repliers, who proved the infinite limit which is a consequence of the fact that one of my assumptions was wrong (or not capable of producing finite limits). The following code incorporates now the suggestions and resolves the case q>1 (death rate bigger than birth rate), when the limit is finite

t = a[n] /.
RSolve[{A n  a[n + 1] - A (1 + q) n  a[n] + q A  n  a[n - 1] + 1 == 0,
a[0] == 0, a[K] == 0}, a[n], n][[1]] // FullSimplify[#, {K > 0, A > 0, 0 < q }] &


Then, I want to compute a limit with Assumptions. The case when it should be finite is the opposite of what I had asked, ie q>1

Limit[t, K -> Infinity, Assumptions -> {K > 0, A>0,  q > 1,n \[Element] PositiveIntegers}]


But, this is still too hard, so we break into pieces. The middle term

a2=Limit[(-1 + q^K) LerchPhi[1/q, 1, 1 + n]/(A (-1 + q) q (-1 + q^K)),
K -> Infinity,
Assumptions -> {A > 0, q > 1, n \[Element] PositiveIntegers}]


yields finite

a2=LerchPhi[1/q, 1, 1 + n]/(A (-1 + q) q)


The last term

a3 = Limit[
q ((1 - q^n) HarmonicNumber[K] + (-1 + q^K) HarmonicNumber[
n] + (q^K - q^n) Log[(-1 + q)/q])/(A (-1 + q) q (-1 + q^K)),
K -> Infinity,
Assumptions -> {A > 0, q > 1, n \[Element] PositiveIntegers}]


also is finite

(HarmonicNumber[n] + Log[(-1 + q)/q])/(A (-1 + q))


The first term is too hard on my computer, but

a1 = DiscreteLimit[-((-1 + q^n) LerchPhi[1/q, 1, 1 + K])/(A (-1 +
q) q (-1 + q^K)), K -> Infinity,
Assumptions -> {A > 0, q > 1, n \[Element] PositiveIntegers}] //
FullSimplify


yields 0. When n=1, the sum a2 + a3 simplifies to Log[q/(q-1)])/A, a result of Whittle 1955. Magic!

• Limit[-(1/q)^k*q^k, k -> Infinity, Assumptions -> {0 < q < 1}] works fine so this is not the problem.
– Alan
Sep 18, 2023 at 13:55
• If we simplify your expression: A = 1/2; q = 1/2; R = (RSolveValue[{A n a[n + 1] - A (1 + q) n a[n] + q A n a[n - 1] + 1 == 0, a[0] == 0, a[k] == 0}, a[n], n] /. n -> 1 // FullSimplify); Plot[R // Re, {k, 0, 10000}] plot looks like a log function then if k->Infinty then : a[n]->Infinity. Sep 18, 2023 at 14:01

The Mariusz Iwaniuk's guess can be grounded in such a way.

First, somewhat improving your t (Limit works better with an expression than a list.), we put

t = Expand[a[n] /. RSolve[{A n a[n + 1] - A (1 + q) n a[n] + q A n a[n - 1] +
1 == 0, a[0] == 0, a[K] == 0}, a[n], n][[1]]]


(EulerGamma q^K)/(A (-1 + q) (-1 + q^K)) - (EulerGamma q^n)/( A (-1 + q) (-1 + q^K)) + ((1/q)^K q^(-1 + K) LerchPhi[1/q, 1, 1 + K])/( A (-1 + q) (-1 + q^K)) - ((1/q)^K q^(-1 + K + n) LerchPhi[1/q, 1, 1 + K])/( A (-1 + q) (-1 + q^K)) - ((1/q)^n q^(-1 + n) LerchPhi[1/q, 1, 1 + n])/( A (-1 + q) (-1 + q^K)) + ((1/q)^n q^(-1 + K + n) LerchPhi[1/q, 1, 1 + n])/(A (-1 + q) (-1 + q^K)) + ( q^K Log[1 - 1/q])/(A (-1 + q) (-1 + q^K)) - (q^n Log[1 - 1/q])/( A (-1 + q) (-1 + q^K)) + PolyGamma[0, 1 + K]/( A (-1 + q) (-1 + q^K)) - (q^n PolyGamma[0, 1 + K])/( A (-1 + q) (-1 + q^K)) - PolyGamma[0, 1 + n]/( A (-1 + q) (-1 + q^K)) + (q^K PolyGamma[0, 1 + n])/( A (-1 + q) (-1 + q^K))

I think (pay your attention to the assumption on n)

Limit[t, K -> Infinity, Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}]


is too hard for Limit so we do it step by step (Two small steps are better than one big step.)

Limit[(EulerGamma q^K)/(A (-1 + q) (-1 + q^K)), K -> Infinity,
Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}]


0

Limit[-((EulerGamma q^n)/(A (-1 + q) (-1 + q^K))), K -> Infinity,
Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}]


(EulerGamma q^n)/(A (-1 + q))

Now we face a difficulty.

Limit[((1/q)^k q^(-1 + K) LerchPhi[1/q, 1, 1 + K])/(A (-1 + q) (-1 + q^K)), K -> Infinity,  Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}]


returns the input. Fortunately,

FullSimplify[DiscreteLimit[((1/q)^k q^(-1 + K) LerchPhi[1/q, 1, 1 + K])/
(A (-1 + q) (-1 + q^K)), K -> Infinity,
Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}],
Assumptions -> { 0 < q < 1]


0

The same issue with

DiscreteLimit[-(((1/q)^K q^(-1+K+n) LerchPhi[1/q,1,1+K])/(A (-1+q) (-1+q^K))),K->Infinity,Assumptions->{A>0,0<q<1,n\[Element]PositiveIntegers}]


(q^(-1 + n) LerchPhi[1/q, 1, \[Infinity]])/(A (-1 + q))

No problem with the next items.

Limit[-(((1/q)^n q^(-1 + n) LerchPhi[1/q, 1, 1 + n])/
(A (-1 + q) (-1 + q^K))), K -> Infinity,
Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}]


LerchPhi[1/q, 1, 1 + n]/(A (-1 + q) q)

Limit[((1/q)^n q^(-1 + K + n) LerchPhi[1/q, 1, 1 + n])/
(A (-1 + q) (-1 + q^K)), K -> Infinity,
Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}


0

Limit[(q^k Log[1 - 1/q])/(A (-1 + q) (-1 + q^k)) -
( q^n Log[1 - 1/q])/(A (-1 + q) (-1 + q^k)), k -> Infinity,
Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}]


(q^n (I \[Pi] + Log[-1 + 1/q]))/(A (-1 + q))

The infinite limit is caused by

Limit[PolyGamma[0, 1 + K]/(A (-1 + q) (-1 + q^K)) -
(q^n PolyGamma[0, 1 + K])/(A (-1 + q) (-1 + q^K)) -
PolyGamma[0, 1 + n]/(A (-1 + q) (-1 + q^K)) +
(q^K PolyGamma[0, 1 + n])/(A (-1 + q) (-1 + q^K)), K -> Infinity,
Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}]


(-1+q^n) (-\[Infinity])

Therefore, summarizing the above, we conclude that

DiscreteLimit[t, K -> Infinity, Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}]


is infinite. This implies

Limit[t, K -> Infinity, Assumptions -> {A > 0, 0 < q < 1, n \[Element] PositiveIntegers}]


is infinite or indeterminate.

\$Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" )

Clear["Global*"]


Include the assumptions in the initial FullSimplify

t = a[n] /.
RSolve[{A n a[n + 1] - A (1 + q) n a[n] + q A n a[n - 1] + 1 == 0,
a[0] == 0, a[K] == 0}, a[n], n][[1]] //
FullSimplify[#, {K > 0, A > 0, 0 < q < 1}] &

(* (-((-1 + q^n) LerchPhi[1/q, 1, 1 + K]) + (-1 + q^K) LerchPhi[1/q, 1, 1 + n] +
q ((1 - q^n) HarmonicNumber[K] + (-1 + q^K) HarmonicNumber[
n] + (q^K - q^n) Log[(-1 + q)/q]))/(A (-1 + q) q (-1 + q^K)) *)


Use Asymptotic (introduced in v12.1, updated in v13.2) for the behavior as K -> Infinity

largeK = Asymptotic[t, K -> Infinity] //
FullSimplify[#, {K > 0, A > 0, 0 < q < 1}] &

(* (-((1 + 2 EulerGamma K) q (-1 + q^n)) + 2 K q (-1 + q^K) HarmonicNumber[n] -
2 K (-1 + q^n) LerchPhi[1/q, 1, 1 + K] +
2 K ((-1 + q^K) LerchPhi[1/q, 1, 1 + n] +
q (Log[K] + q^K Log[(-1 + q)/q] -
q^n Log[(K (-1 + q))/q])))/(2 A K (-1 + q) q (-1 + q^K)) *)

• Your latest result (-((1 + 2 EulerGamma K) q (-1 + q^n)) + 2 K q (-1 + q^K) HarmonicNumber[n] - 2 K (-1 + q^n) LerchPhi[1/q, 1, 1 + K] + 2 K ((-1 + q^K) LerchPhi[1/q, 1, 1 + n] + q (Log[K] + q^K Log[(-1 + q)/q] - q^n Log[(K (-1 + q))/q])))/(2 A K (-1 + q) q (-1 + q^K)) mostly or completely repeats t, is not so? Sep 18, 2023 at 17:44
• Indeed, Simplify[t - largeK] results in (1/(2 A K (-1 + q) (-1 + q^K)))(-1 - 2 EulerGamma K + q^n + 2 EulerGamma K q^n - 2 K (-1 + q^n) HarmonicNumber[K] - 2 K Log[K] - 2 K q^n Log[(-1 + q)/q] + 2 K q^n Log[(K (-1 + q))/q])`. Sep 18, 2023 at 18:06