111
This commit is contained in:
12
89-3.py
12
89-3.py
@@ -1,7 +1,4 @@
|
||||
|
||||
x = [19,25,31,38,44]
|
||||
y = [19.0,32.3,49.0,73.3,97.8]
|
||||
|
||||
# 列主元高斯消元法
|
||||
def SovleRowMain(A,b):
|
||||
ks = 0.00000001
|
||||
@@ -61,8 +58,15 @@ def LeastSquares(list_x,list_y,n):
|
||||
for j in range(n+1):
|
||||
tmp.append(x_n[i+j])
|
||||
A.append(tmp)
|
||||
return SovleRowMain(A,b)
|
||||
print("A:", A)
|
||||
print("b:", b)
|
||||
result = SovleRowMain(A, b)
|
||||
print("result:", result)
|
||||
return result
|
||||
|
||||
#把x和y换成题干的数值###################
|
||||
x = [19,25,31,38,44]
|
||||
y = [19.0,32.3,49.0,73.3,97.8]
|
||||
if __name__ == "__main__":
|
||||
x_square = [i**2 for i in x]
|
||||
coeff = LeastSquares(x_square, y, 1)
|
||||
|
||||
Reference in New Issue
Block a user