Commit 44dc0ab4 authored by irada chinnachat's avatar irada chinnachat

งานในห้อง

parent 14855896
def Ab2Uc (A, b)
import numpy as np
A = np.array([
[ 4, -2, 1],
[-2, 4, -2]
[1, -2, 4]
],float)
b = np.array([ 11, -16, 17],float)
n = len(b)
for k in range (0,n-1):
for i range(k+1, n):
lam = A[i,k]/A[k,k]
A[i,k] = 0
A[i, k+1:n] = A[i, k+1:n]-lam*[k, k+1:n]
b[i] -= lam*b[k]
U = A.copy()
c = b.copy()
print("U = ")
print(U)
print()
print("c = ",c)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment