diff --git a/02-numpy/fib-solve.py b/02-numpy/fib-solve.py new file mode 100755 index 0000000000000000000000000000000000000000..5a4caa9a7033d3cd6cb78fc3c1eddbdf10e2f659 --- /dev/null +++ b/02-numpy/fib-solve.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 + +import numpy as np + +n = 10 + +a = -np.eye(n)/2 - np.eye(n, k=1)/2 + np.eye(n, k=2) +a[-2:, -2:] = np.eye(2) + +b = np.zeros(n) +b[-2] = 426 +b[-1] = 427 + +x = np.linalg.solve(a, b) +print(x[:2]) diff --git a/02-numpy/fib-test.py b/02-numpy/fib-test.py new file mode 100755 index 0000000000000000000000000000000000000000..7f3de4251cde420d1194f007fe5dc235f0bb5214 --- /dev/null +++ b/02-numpy/fib-test.py @@ -0,0 +1,6 @@ +#!/usr/bin/python3 + +a = [256, 512] +for i in range(2, 10): + a.append((a[-1] + a[-2]) / 2) +print(a)