Fix algorithm

This commit is contained in:
Manuel Thalmann 2023-03-29 13:03:17 +02:00
parent 2537f32208
commit 0d8f8ef6cc

View file

@ -27,10 +27,12 @@ def Miguel_S5_Aufg2(x, y, xx):
A[i][1] = h[1]
z[i] = 3 * (((y[2] - y[1]) / h[1]) - ((y[1] - y[0]) / h[0]))
else:
A[i][i - 1] = h[i - 1]
A[i][i] = 2 * (h[i - 1] + h[i])
A[i][i + 1] = h[i]
z[i] = 3 * (((y[i + 1] - y[i]) / h[i]) - ((y[i] - y[i - 1]) / h[i - 1]))
A[i][i - 1] = h[i]
A[i][i] = 2 * (h[i] + h[i + 1])
z[i] = 3 * (((y[i + 2] - y[i + 1]) / h[i + 1]) - ((y[i + 1] - y[i]) / h[i]))
if i < n - 3:
A[i][i + 1] = h[i + 1]
c[1:n - 1,:] = linalg.solve(A, z)