def calculate_f(a, t, q): # Fi(t) formulas: I + (A^q)/q! # A is matrix f = np.eye(3) q = int(q) val = a * t for i in range(1, q + 1): f += np.linalg.matrix_power(val, i) / m.fact(i) return f
def product_exp(x): ide = create_ide(x) res = create_empty_matrix(x) i = 0 for i in range(100): temp = scalaire_product(ide, 1 / fact(i)) for k in range(len(res)): for j in range(len(res[0])): res[k][j] += temp[k][j] ide = matrix_product(ide, x) return res
def product_sin(x): ide = create_ide(x) res = create_empty_matrix(x) k = 1 ide = matrix_product(ide, x) for i in range(0, 100): if (i != 0): ide = matrix_product(ide, x) ide = matrix_product(ide, x) k = ((-1)**i) / fact(2 * i + 1) temp = scalaire_product(ide, k) for k in range(len(res)): for j in range(len(res[0])): res[k][j] += temp[k][j] return res
def test_fact_1(self): self.assertEqual(my_math.fact(1), 1)
def test_fact_0(self): self.assertEqual(my_math.fact(0), 1)
def test_float_numbers(self): with self.assertRaises(TypeError): my_math.fact(1.66)
def test_negative_vals(self): with self.assertRaises(ValueError): my_math.fact(-1)