Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #Exercice 1
  2.  
  3.  
  4.  
  5. M=matrix(ZZ,[[2,2,3],[4,-1,7],[3,-2,5]])
  6. M
  7.  
  8. M.nrows()
  9. M.ncols()
  10.  
  11.  
  12. N1=M;
  13. N1.swap_rows(1,2);
  14. M
  15.  
  16. N2=copy(M)
  17. N2.swap_rows(1,2);
  18. M
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. #Exercice 2
  26.  
  27.  
  28. A=matrix(ZZ,[[3,6,9,9,15],[15,20,25,-10,10],[11,32,43,-10,22],[-6,0,1,-1,-1]])
  29. A
  30.  
  31.  
  32. A_H,u=A.hermite_form(transformation=True)
  33. A_H
  34. u
  35. u*A
  36.  
  37. At=A.transpose()
  38. AtH,v=At.hermite_form(transformation=True)
  39.  
  40. show(AtH.transpose(),v.transpose())
  41.  
  42. A*v.transpose()
  43.  
  44.  
  45.  
  46.  
  47. # rg Imf=3 engendré par les vecteurs (3,0,0,-1),(0,5,1,-3),(0,0,2,1)
  48.  
  49. #Ker f est engendré par les deux dernières colonnes de v (18,0,98,131,-141),(0,1,0,1,-1)
  50. A.right_kernel()
  51.  
  52.  
  53.  
  54. Y=vector([6,-5,-1,1])
  55. A\Y
  56. X=vector([4/5,-81/10,29/5,0,0])
  57. A*X
  58.  
  59. I=matrix(ZZ,[[1,0],[0,1]])
  60. w=vector([7,3])
  61.  
  62.  
  63. w_second=w_prime
  64. w_second
  65. w_second[0],w_second[1]=w_second[1],w_second[0]
  66. w_second
  67.  
  68. #Exercice 3
  69. def matricedetransvection(q):
  70. return(matrix(ZZ,[[1,-q],[0,1]]))
  71.  
  72.  
  73.  
  74.  
  75.  
  76. def ReductionColonne2mieux(v):
  77. I=matrix(ZZ,[[1,0],[0,1]])
  78. J=matrix(ZZ,[[0,1],[1,0]])
  79. if v[1]==0:
  80. return(v,I)
  81. if v[0]==0:
  82. v[0],v[1]=v[1],v[0]
  83. return(v,J)
  84. if v[0]<0:
  85. v[0]=-v[0]
  86. I=I*matrix(ZZ,[[-1,0],[0,1]])
  87. if v[1]<0:
  88. v[1]=-v[1]
  89. I=I*matrix(ZZ,[[1,0],[0,-1]])
  90. if v[0]==v[1]:
  91. L=matrix(ZZ,[[1,0],[-1,1]])
  92. res=L*v
  93. return(L*I,res)
  94. if v[0]<v[1]:
  95. v[0],v[1]=v[1],v[0]
  96. t=v.coefficients()
  97. q=t[0]//t[1]
  98. r=t[0]%t[1]
  99. while r!=0:
  100. L=matricedetransvection(q)
  101. I=L*I
  102. v=L*v
  103. v[0],v[1]=v[1],v[0]
  104. I=J*I
  105. t=v.coefficients()
  106. q=t[0]//t[1]
  107. r=t[0]%t[1]
  108. L=matricedetransvection(q)
  109. v=L*v
  110. I=L*I
  111. v[0],v[1]=v[1],v[0]
  112. I=J*I
  113. return(v,I)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement