Created
July 7, 2023 12:13
-
-
Save guissalustiano/af173e7620cf7dc1820e01af6e9b81e7 to your computer and use it in GitHub Desktop.
criterio de routh
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 | |
from math import ceil | |
from sympy import Symbol | |
from prettytable import PrettyTable | |
# [a0, a1, a2, ...] | |
k = Symbol('k') | |
# coef = [1, 2, 3, 4, 5] | |
coef = [1, 8, 32, k] | |
base = [[0] * len(coef) for _ in range(len(coef))] | |
for i, a in enumerate(coef): | |
base[i%2][i//2] = a/1 | |
for i in range(2, len(coef)): | |
for j in range(len(coef)-1): | |
# print(f"i={i}, j={j}, {base[i-1][0]}*{base[0][j+1]} - {base[i-2][0]}*{base[i-1][j+1]}/{base[i-1][0]}") | |
base[i][j] = (base[i-1][0]*base[i-2][j+1] - base[i-2][0]*base[i-1][j+1])/base[i-1][0] | |
p = PrettyTable() | |
for row in base: | |
p.add_row(row) | |
print(p.get_string(header=False, border=False)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment