-
Notifications
You must be signed in to change notification settings - Fork 1
/
maths_functions.py
44 lines (38 loc) · 1.14 KB
/
maths_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
##
## EPITECH PROJECT, 2018
## 108trigo_2017
## File description:
## Maths file
##
from matrix import *
def my_exp(tab):
tmp = identity_mat(len(tab))
for i in range(1, 50):
tmp = add_mat(tmp, div_mat(pow_mat(tab, i), factorial(i)))
return tmp
def my_cos(tab):
tmp = identity_mat(len(tab))
for i in range(1, 40):
if i % 2 == 0:
tmp = add_mat(tmp, div_mat(pow_mat(tab, 2 * i), factorial(2 * i)))
else:
tmp = sub_mat(tmp, div_mat(pow_mat(tab, 2 * i), factorial(2 * i)))
return tmp
def my_sin(tab):
tmp = tab
for i in range(1, 40):
if i % 2 == 0:
tmp = add_mat(tmp, div_mat(pow_mat(tab, 2 * i + 1), factorial(2 * i + 1)))
else:
tmp = sub_mat(tmp, div_mat(pow_mat(tab, 2 * i + 1), factorial(2 * i + 1)))
return tmp
def my_cosh(tab):
tmp = identity_mat(len(tab))
for i in range(1, 40):
tmp = add_mat(tmp, div_mat(pow_mat(tab, 2 * i), factorial(2 * i)))
return tmp
def my_sinh(tab):
tmp = tab
for i in range(1, 40):
tmp = add_mat(tmp, div_mat(pow_mat(tab, 2 * i + 1), factorial(2 * i + 1)))
return tmp