Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168738
Image: ubuntu2004
import numpy as np A=np.array([[11.,2.,3.,4.],[5.,6.,7.,108.],[10.,11.,12.,13.],[34.,45.,46.,57.]]) b=np.array([2.,3.,4.,5.]) def system_linear(A,b): N=A.shape[0] #defini la taille de la matrice(condition sur N) for j in range(0,N-1): pivot=A[j,j] for i in range(j+1,N): b[i]=b[i]-(A[i,j]/pivot)*b[j] #modification de l'element de b A[i,:]=A[i,:]-(A[i,j]/pivot)*A[j,:] #modification d'une ligne de matrice sol=b/A.diagonal() return sol system_linear(A,b)
array([ 0.18181818, 0.41071429, 1.78 , -0.01176471])
A
array([[ 11. , 2. , 3. , 4. ], [ 0. , 5.09090909, 5.63636364, 106.18181818], [ 0. , 0. , -0.89285714, -182.14285714], [ 0. , 0. , 0. , 510. ]])