前言
嗨,这本课本没答案,有些计算题都不知道对不对,只能靠计算机辅助一下啦。
chapter1
q_6
import numpy as np
def question_c():
a = np.mat([[1, 2], [4, -3]])
result = 2 * np.dot(np.dot(a, a), a) - 4 * a + 5
print(result)
"""
[[ -13 57]
[ 109 -117]]
"""
def question_d():
a = np.mat([[1, 2], [4, -3]])
result = np.dot(a, a) + 2 * a + 11
print(result)
"""
[[22 11]
[11 22]]
"""
if __name__=="__main__":
# question_c()
question_d()
q_22
需要引入这篇博客 python输出高斯消元法求解行列式的过程的代码,并把那个文件命名为 echelon_form.py
from echelon_form import *
if __name__ == "__main__":
a = [[1, 0, 2, 1, 0, 0], [2, -1, 3, 0, 1, 0], [4, 1, 8, 0, 0, 1]]
a = make_matrix(a)
cofficient_cols_num = 3
echelon_form(a, cofficient_cols_num, reduce_echelon_form=True)
输出:
prc_row, prc_col: 0 0
process 0. simplify row 1
------------------------------------------------------------
1 0 2 1 0 0
0 -1 -1 -2 1 0
0 1 0 -4 0 1
prc_row, prc_col: 1 1
process 1. simplify row 1
------------------------------------------------------------
1 0 2 1 0 0
0 1 1 2 -1 0
0 0 -1 -6 1 1
prc_row, prc_col: 2 2
process 2. simplify row 1
------------------------------------------------------------
1 0 0 -11 2 2
0 1 0 -4 0 1
0 0 1 6 -1 -1