fork download
  1. import numpy as np
  2. from scipy import linalg as la
  3.  
  4. A=np.array([[5,6,-4],
  5. [2,1,-2],
  6. [7,9,2]], dtype=np.float64)
  7. b = np.array([10,14,-11], dtype=np.float64)
  8. x = la.solve(A,b)
  9. print(x)
  10. print(A @ x)
  11. L,U=la.lu(A,permute_l=True)
  12. d=la.solve(L,b)
  13. x=la.solve(U,d)
  14. print(x)
  15. print(A @ x)
Success #stdin #stdout 1.14s 51416KB
stdin
Standard input is empty
stdout
[ 7.38461538 -6.34615385 -2.78846154]
[ 10.  14. -11.]
[ 7.38461538 -6.34615385 -2.78846154]
[ 10.  14. -11.]