Presentation is loading. Please wait.

Presentation is loading. Please wait.

ERASMUS+ Zintegrowane nauczanie przedmiotów ścisłych z perspektywą obliczeniową The program was financed by the EU - ESF.

Similar presentations


Presentation on theme: "ERASMUS+ Zintegrowane nauczanie przedmiotów ścisłych z perspektywą obliczeniową The program was financed by the EU - ESF."— Presentation transcript:

1 ERASMUS+ Zintegrowane nauczanie przedmiotów ścisłych z perspektywą obliczeniową The program was financed by the EU - ESF

2 Workshops 2 SAGE

3 Linear Algebra Sage provides standard constructions from linear algebra, e.g., the characteristic polynomial, echelon form, trace, decomposition, matrix operatiing. Creation of matrices and matrix multiplication is easy and natural: Projekt finansowany ze środków EFS

4 Examples sage: A = Matrix([[1,2,3],[3,2,1],[1,1,1]]) sage: w = vector([1,1,-4]) sage: w*A(0, 0, 0) sage: A*w(-9, 1, -2) sage: kernel(A) Free module of degree 3 and rank 1 over Integer RingEchelon basis matrix:[ 1 1 -4] Projekt finansowany ze środków EFS

5 Examples Solving matrix equations is easy, using the method solve_right. Evaluating A.solve_right(Y) returns a matrix (or vector) X so that AX=Y: sage: Y = vector([0, -4, -1]) sage: X = A. solve_right(Y) sage: X(-2, 1, 0) sage: A * X # checking our answer...(0, -4, -1) Projekt finansowany ze środków EFS

6 Linear Algebra A backslash \ can be used in the place of solve_right; use A \ Y instead of A.solve_right(Y). sage: A \ Y(-2, 1, 0) If there is no solution, Sage returns an error: sage: A.solve_right(w) Traceback (most recent call last):...ValueError: matrix equation has no solutions Projekt finansowany ze środków EFS

7 Linear Algebra Similarly, use A.solve_left(Y) to solve for X in XA=Y. Sage can also compute eigenvalues and eigenvectors: sage: A = matrix([[0, 4], [-1, 0]]) sage: A.eigenvalues ()[-2*I, 2*I] sage: B = matrix([[1, 3], [3, 1]]) sage: B.eigenvectors_left() [(4, [(1, 1)], 1), (-2, [(1, -1)], 1)] Projekt finansowany ze środków EFS

8 Exercises for students Please verify that the system is a Cramer. If so, solve it using determinants. Projekt finansowany ze środków EFS

9

10


Download ppt "ERASMUS+ Zintegrowane nauczanie przedmiotów ścisłych z perspektywą obliczeniową The program was financed by the EU - ESF."

Similar presentations


Ads by Google