0% found this document useful (0 votes)
12 views18 pages

Linear Algebra

Linear algebra is the study of vectors and rules for manipulating vectors. It involves geometric vectors, which are usually denoted with arrows above letters. Key concepts include vectors, matrices, systems of linear equations, and matrix operations in Python using the NumPy library.

Uploaded by

Sanchit Chopra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views18 pages

Linear Algebra

Linear algebra is the study of vectors and rules for manipulating vectors. It involves geometric vectors, which are usually denoted with arrows above letters. Key concepts include vectors, matrices, systems of linear equations, and matrix operations in Python using the NumPy library.

Uploaded by

Sanchit Chopra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

Linear Algebra


When formalizing intuitive concepts, a common approach is to construct a set of
objects (symbols) and a set of rules to manipulate these objects. This is known as
an algebra.

Linear algebra is the study of vectors and certain algebra rules to manipulate
vectors.
 Geometric Vectors: The vectors many of us know from school are called “geometric
vectors”, which are usually denoted by a small arrow above the letter, e.g., −→x and
−→y .
Linear Algebra
Vector
System of Linear Equations
System of Linear Equations
System of Linear Equations
Python programming on Matrix
operations
A = [[1, 4, 5, 12],

[-5, 8, 9, 0],

[-6, 7, 11, 19]]

print("A =", A)

print("A[1] =", A[1]) # 2nd row

print("A[1][2] =", A[1][2]) # 3rd element of 2nd row

print("A[0][-1] =", A[0][-1]) # Last element of 1st Row

column = []; # empty list

for row in A:

column.append(row[2])

print("3rd column =", column)


import numpy as np

a = np.array([1, 2, 3])

print(a) # Output: [1, 2, 3]

print(type(a)) # Output: <class 'numpy.ndarray'>

import numpy as np

A = np.array([[1, 2, 3], [3, 4, 5]])

print(A)

A = np.array([[1.1, 2, 3], [3, 4, 5]]) # Array of floats

print(A)

A = np.array([[1, 2, 3], [3, 4, 5]], dtype = complex) # Array of complex numbers

print(A)
import numpy as np

zeors_array = np.zeros( (2, 3) )

print(zeors_array)

'''

Output:

[[0. 0. 0.]

[0. 0. 0.]]

'''

ones_array = np.ones( (1, 5), dtype=np.int32 ) // specifying dtype

print(ones_array) # Output: [[1 1 1 1 1]]


import numpy as np

A = np.arange(4)

print('A =', A)

B = np.arange(12).reshape(2, 6)

print('B =', B)

'''

Output:

A = [0 1 2 3]

B = [[ 0 1 2 3 4 5]

[ 6 7 8 9 10 11]]

'''
import numpy as np

A = np.array([[2, 4], [5, -6]])

B = np.array([[9, -3], [3, 6]])

C=A+B # element wise addition

print(C)

'''

Output:

[[11 1]

[ 8 0]]

'''
import numpy as np

A = np.array([[3, 6, 7], [5, -3, 0]])

B = np.array([[1, 1], [2, 1], [3, -3]])

C = A.dot(B)

print(C)

'''

Output:

[[ 36 -12]

[ -1 2]]

'''
import numpy as np

A = np.array([[1, 1], [2, 1], [3, -3]])

print(A.transpose())

'''

Output:

[[ 1 2 3]

[ 1 1 -3]]

'''
import numpy as np
A = np.array([2, 4, 6, 8, 10])

print("A[0] =", A[0]) # First element


print("A[2] =", A[2]) # Third element
print("A[-1] =", A[-1]) # Last element
import numpy as np

A = np.array([[1, 4, 5, 12],

[-5, 8, 9, 0],

[-6, 7, 11, 19]])

# First element of first row

print("A[0][0] =", A[0][0])

# Third element of second row

print("A[1][2] =", A[1][2])

# Last element of last row

print("A[-1][-1] =", A[-1][-1])


import numpy as np

A = np.array([[1, 4, 5, 12],

[-5, 8, 9, 0],

[-6, 7, 11, 19]])

print("A[0] =", A[0]) # First Row

print("A[2] =", A[2]) # Third Row

print("A[-1] =", A[-1]) # Last Row (3rd row in this case)


import numpy as np

A = np.array([[1, 4, 5, 12],

[-5, 8, 9, 0],

[-6, 7, 11, 19]])

print("A[:,0] =",A[:,0]) # First Column

print("A[:,3] =", A[:,3]) # Fourth Column

print("A[:,-1] =", A[:,-1]) # Last Column (4th column in this case)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy