Created
June 22, 2020 01:00
-
-
Save DiegoAscanio/f25330b0c81adfe207d33252df703cdd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def fatorial(x): | |
fat = 1 | |
for i in range(1, x + 1): | |
fat *= i | |
return fat | |
def pow(X, power): | |
pow = np.eye(X.shape[0]) | |
for i in range(power): | |
pow = pow.dot(X) | |
return pow | |
# Exemplo de matriz A onde A x A = I | |
A = np.array([[np.sqrt(10), 3], [-3, -np.sqrt(10)]]) | |
exponencial_A_positiva = np.array(sum([pow(A, k) / fatorial(k) for k in range(0, 100)]), dtype=float) | |
exponencial_A_negativa = np.array(sum([pow(-A, k) / fatorial(k) for k in range(0, 100)]), dtype=float) | |
print('e^A * e^-A == I: {}'.format(np.allclose(np.eye(2), exponencial_A_positiva.dot(exponencial_A_negativa)))) | |
print('e^-A * e^A == I: {}'.format(np.allclose(np.eye(2), exponencial_A_negativa.dot(exponencial_A_positiva)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment