lec19_linear_algebra - A.I*A#NxN Identity matrix given by...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
from numpy import * from scipy import linalg #2D numpy arrays can represent matrices Aa=array([[1,3,5],[2,5,1],[2,3,8]]) #Numpy also has a 'matrix' object that is very similar to 2D arrays, #but has a more userfriendly interface A=mat('[1 3 5; 2 5 1; 2 3 8]') #Returns the diagonal elements of the matrix A.diagonal() #Returns the trace (sum of diag. elements) A.trace() #Takes inverse of the matrix A.I # Matrix multiply using simple * operator # Should return identity matrix (matrix equivalent of 1)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: A.I*A #NxN Identity matrix given by eye(N) eye(3) # Solutions to systems of equations # System #x + 3y + 5z = 10 #2x + 5y + z = 8 #2x + 3y + 8z = 3 # #Form is A*X = b b=mat('[10; 8; 3]') # Solution can be found by 1/A * b A.I * b #Better to use the solve function in linalg X=linalg.solve(A,b) print X #Exercise 1: Fixed points for a system of ODEs A=mat('[-10 10 0; -10 -1 -2; 2 -10 -8]') b=mat('[2;4;-3]') X=linalg.solve(A,b) print X...
View Full Document

This note was uploaded on 10/05/2010 for the course PHYS phy503 taught by Professor Gladden during the Spring '09 term at Ole Miss.

Ask a homework question - tutors are online