Numerically dividing two sequences that diverge each, but whose ratio remains finite

36 Views Asked by At

I am working on a numerical problem that involves the two sequences:

$$\begin{align} &A_{n+1} = A_{n}+f(n)A_{n-1}\qquad\text{with n={1,2,...}}\\ &B_{n+1} = B_{n}+f(n)B_{n-1} \end{align}$$

(where f(n) is some function, and $A_{0}=0$, $A_{1}=const$, $B_{0}=B_{1}=1$.)

f(n) and $A_{1}=const$ are chosen such that $|A_{n}|$ and $|B_{n}|$ diverge for $n\rightarrow\infty$, but the fraction

$$C_n=\frac{A_{n}}{B_{n}}$$

converges to some value for $n\rightarrow\infty$. Numerically, I would simply define a cutoff N at which this value will be accepted. The issue here is that both $A_{n}$ and $B_{n}$ each become so big that they cannot be handled by my compiler anymore (they each approach values of the order of $10^{300}$ and beyond), which analytically would not a problem since these big numbers cancel out in the fraction.

In order to solve this issue, I thought about doing the following:

  1. Rewriting the algebraic expression such that $C_n$ is directly determined at each step n, and that $A_n$ and $B_n$ are never computed individually. After all, I am not interested in $A_{n}$ and $B_{n}$, but only in their ratio $C_{n}$.
  2. Introducing a dampening factor for $A_{n}$ and $B_{n}$ at each step n to prevent both sequences from diverging. This factor would then cancel out as it occurs in the numerator and denominator.

I was not very successful with either of these two ideas. Can anybody help me solve this issue, by either implementing one of my two suggestions or coming up with an alternative?

1

There are 1 best solutions below

0
On BEST ANSWER

As kingW3 said in his comment, you could consider the fractions of consecutive $A_n$ and $B_n$. However, since you don't want to divide by $0$, I would suggest you define $P_n:=\frac{A_{n}}{A_{n+1}}$ and $Q_n:=\frac{B_n}{B_{n+1}}$. Then it follows that $P_n=\frac{1}{1+f(n)P_{n-1}}$ and $Q_{n}=\frac{1}{1+f(n)Q_{n-1}}$ for all $n\geq1$. Hopefully, the $P_n$ and $Q_n$ do not become very large, so that you can calculate the first values of $P_n$ and $Q_n$. Then, use that $$C_n=\frac{A_n}{B_n}=\frac{A_1}{B_1}\prod_{i=1}^{n-1}\frac{Q_i}{P_i}$$ to calculate the value of $C_n$.