<jupyter_start><jupyter_text>f_matrix - матрица свободных коэффициентов  A - матрица вида  x1 = α11x1 + α12x2 + . . . + α1nxn + β1,  x2 = α21x1 + α22x2 + . . . + α2nxn + β2,  . . .  xn = αn1x1 + αn2x2 + . . . + αnnxn + βn,<jupyter_code>def new_system(A:list):
    if len(A) == 0 : return -1
    f_matrix = [A[i].pop()/A[i][i] for i in range(len(A))]
    for i in range(len(A)):
        temp = A[i][i]
        for j in range(len(A[i])):
            A[i][j] = (-1) * A[i][j]/temp
        A[i][i] = 0
    return f_matrix
a = get_values_from_matrix(rows)
f = new_system(a)
x_1 = simple_iteration(a, f, .01)
display(Markdown(f"Конечный результат: x<sub>1</sub> = **{x_1[0]}**"
f" x<sub>2</sub> = **{x_1[1]}** x<sub>3</sub> = **{x_1[2]}** x<sub>4</sub> = **{x_1[3]}** "))
#Проверка
import numpy as np
A1 = np.array([])
A1 = np.append(A1, get_values_from_matrix(rows))
A1 = A1.reshape(4,5)
b = A1[:, -1]
A1 = A1[:, :-1]

print(A1.shape, b.shape)
x = np.linalg.solve(A1, b)
display(Markdown(f"#### x<sub>1</sub> = {x[0]};"
f" x<sub>2</sub> = {x[1]}; x<sub>3</sub> = {x[2]}; x<sub>4</sub> = {x[3]} "))
#<NAME>
def method_Seidel(A:list, f:list, eps = .01):
    x_prev = f.copy() #Нулевая итерация
    x = f.copy()
    iter = 1
    print_iteration(x, iter)
    while True:
        for i in range(len(A)):
            temp = 0
            for j in range(len(A[i])):
                temp += A[i][j] * x[j]
            temp += f[i]
            x[i] = temp
        iter += 1
        print_iteration(x, iter)
        if betta(x, x_prev) < eps: return x
        x_prev = x.copy()

a_s = get_values_from_matrix(rows)
f_s = new_system(a_s)
x_2 = method_Seidel(a_s, f_s, .01)
x_2
np.set_printoptions(suppress=True)
x_1 = np.array(x_1)

print(f"Относительная погрешность: {abs(x_1 - x)/abs(x)}")
np.set_printoptions(suppress=True)
x_2 = np.array(x_2)

print(f"Относительная погрешность: {abs(x_2 - x)/abs(x)}")
abs(x_1 - x_2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20992761116856257, 'fraction_numerical': 0.04136504653567735, 'mean_word_length': 2.9814814814814814, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '36757', 'license': 'MIT', 'n_tokens_mistral': 960, 'n_tokens_neox': 953, 'n_words': 175, 'path': 'Labs_3.ipynb', 'repo_name': 'Dotyushka666/Labs_num_methods_6sem', 'size': '1941'}