In [8]:
import numpy as np
import sympy as sy
from sympy import init_printing
init_printing()
import control.matlab as cm

The Fibonacci sequence

\begin{equation} y(k+2) - y(k+1) - y(k) = 0 \end{equation}

In [20]:
z = sy.symbols('z')
y0, y1 = sy.symbols('y0, y1', real=True)

In [21]:
den = z*z - z -1
num = z*z
Y = num/sy.factor(den)
sy.factor(den)


Out[21]:
$$z^{2} - z - 1$$

In [22]:
sy.factor(Y)


Out[22]:
$$\frac{z^{2}}{z^{2} - z - 1}$$

In [23]:
sy.apart(Y)


Out[23]:
$$\frac{z + 1}{z^{2} - z - 1} + 1$$

In [24]:
sy.apart( z/den)


Out[24]:
$$\frac{z}{z^{2} - z - 1}$$

In [25]:
p1 = (1 + sy.sqrt(5))/2
p2 = (1 - sy.sqrt(5))/2
sy.expand((z-p1)*(z-p2))


Out[25]:
$$z^{2} - z - 1$$

In [28]:
Y = z/( (z-p1)*(z-p2))
Y


Out[28]:
$$\frac{z}{\left(z - \frac{1}{2} + \frac{\sqrt{5}}{2}\right) \left(z - \frac{\sqrt{5}}{2} - \frac{1}{2}\right)}$$

In [29]:
sy.apart(Y)


Out[29]:
$$\frac{z}{z^{2} - z - 1}$$

In [ ]: