Computing recurrences

84 Views Asked by At

This is probably a very simple to solve question, but i do not know how to use Pari gp to find the succesive $z(n)$ and $y(n)$ values of , for instance, the recurrence :

(z(0),y(0))=(1,0); z(n+1) =15z(n) +112y(n); y(n+1) = 2z(n) + 15y(n)

What a simple line of code to use ?

2

There are 2 best solutions below

0
On

Ok i found the way to do it, using vectors:

$ a=10;z=vector(a);y=vector(a);z[1]=1;y[1]=0;for(n=2,a,z[n]=15*z[n-1]+112*y[n-1];y[n]=2*z[n-1]+15*y[n-1];print([z[n],y[n]])) [15, 2] [449, 60] [13455, 1798] [403201, 53880] [12082575, 1614602] [362074049, 48384180] [10850138895, 1449910798] [325142092801, 43448939760] [9743412645135, 1302018282002] $

4
On

You have a system of recurrences: $$ y(n + 1) = 15 y(n) + 2 z(n) \\ z(n + 1) = 112 y(n) + 15 z(n) $$ $y(0) = 0$, $z(0) = 1$. Define ordinary generating functions: $$ Y(x) = \sum_{n \ge 0} y(n) x^n \\ Z(x) = \sum_{n \ge 0} z(n) x^n $$ By the properties of ordinary generating functions: $$ \frac{Y(x) - 0}{x} = 15 Y(x) + 2 Z(x) \\ \frac{Z(x) - 1}{x} = 112 Y(x) + 15 Z(x) $$ This gives: $$ Y(x) = \frac{2 x}{1 - 30 x + x^2} \\ Z(x) = \frac{1 - 15 x}{1 - 30 x + x^2} $$ Split this into partial fractions, and you have two geometric series apiece: $$ Y(x) = \frac{1}{4 \sqrt{14}} \cdot \left( \frac{1}{1 - x / (15 - 4 \sqrt{14})} - \frac{1}{1 - x / (15 + \sqrt{14})} \right) \\ Z(x) = \frac{1}{4 \sqrt{14}} \cdot \left( \frac{56 - 15 \sqrt{14}}{15 - 4 \sqrt{14}} \frac{1}{1 - x / (15 - 4 \sqrt{14})} - \frac{56 + 15 \sqrt{14}}{15 + 4 \sqrt{14}} \frac{1}{1 - x / (15 + \sqrt{14})} \right) $$ From here you can read the coefficients: $$ y(n) = \frac{1}{4 \sqrt{14}} \left( (15 - 4 \sqrt{14})^n - (15 + 4 \sqrt{14})^n \right) \\ z(n) = \frac{1}{4 \sqrt{14}} \left( \frac{56 - 15 \sqrt{14}}{15 - 4 \sqrt{14}} (15 - 4 \sqrt{14})^n - \frac{56 + 15 \sqrt{14}}{15 + 4 \sqrt{14}} (15 + 4 \sqrt{14})^n \right) $$