Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
6 views5 pages

DSE - 1.ipynb - Colab

Uploaded by

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

DSE - 1.ipynb - Colab

Uploaded by

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

keyboard_arrow_down Practical_1

Aim: Develop a program to basic mathematical ,algebric,geometric operation

Name: Rushikesh Raghatate

Sec: A

Roll No.: 44

keyboard_arrow_down Addition of the two matrix


1 import numpy as np
2
3 # Matrix Addition
4 matrix1 = np.array([[1, 2, 3],
5 [4, 5, 6],
6 [7, 8, 9]])
7 print("matrix1: ")
8 print(matrix1)
9
10 matrix2 = np.array([[9, 8, 7],
11 [6, 5, 4],
12 [3, 2, 1]])
13
14 print("matrix2: ")
15 print(matrix2)
16
17 addition_result = matrix1 + matrix2
18 print("Addition_result: ")
19 print( addition_result)

matrix1:
[[1 2 3]
[4 5 6]
[7 8 9]]
matrix2:
[[9 8 7]
[6 5 4]
[3 2 1]]
Addition_result:
[[10 10 10]
[10 10 10]
[10 10 10]]

1 matrix1 = np.array([[11, 24],


2 [46, 56]])
3 print("matrix1: ")
4 print(matrix1)
5 matrix2 = np.array([[9, 8],
6 [6, 5]])
7
8 print("matrix2: ")
9 print(matrix2)
10 addition_result = matrix1 + matrix2
11 print("Addition_result: ")
12 print( addition_result)
13

matrix1:
[[11 24]
[46 56]]
matrix2:
[[9 8]
[6 5]]
Addition_result:
[[20 32]
[52 61]]

keyboard_arrow_down Substraction of the two Matrix


1 matrix1 = np.array([[1, 2, 3],
2 [4, 5, 6],
3 [7, 8, 9]])
4 print("matrix1: ")
5 print(matrix1)
6
7 matrix2 = np.array([[10,12,0],
8 [11,0,2],
9 [4,55,4]])
10 print("matrix2: ")
11 print(matrix2)
12
13 substraction_result = matrix1 - matrix2
14 print("substraction_result: ")
15 print(substraction_result)

matrix1:
[[1 2 3]
[4 5 6]
[7 8 9]]
matrix2:
[[10 12 0]
[11 0 2]
[ 4 55 4]]
substraction_result:
[[ -9 -10 3]
[ -7 5 4]
[ 3 -47 5]]

1 matrix1 = np.array([[11, 24],


2 [46, 56]])
3 print("matrix1: ")
4 print(matrix1)
5 matrix2 = np.array([[9, 8],
6 [6, 5]])
7
8 print("matrix2: ")
9 print(matrix2)
10 substraction_result = matrix1 - matrix2
11 print("substraction_result: ")
12 print(substraction_result)

matrix1:
[[11 24]
[46 56]]
matrix2:
[[9 8]
[6 5]]
substraction_result:
[[ 2 16]
[40 51]]

keyboard_arrow_down Multiplication of the two Matrix


1 matrix1 = np.array([[1, 2, 3],
2 [4, 5, 6],
3 [7, 8, 9]])
4 print("matrix1: ")
5 print(matrix1)
6
7 matrix2 = np.array([[9, 8, 7],
8 [6, 5, 4],
9 [3, 2, 1]])
10 print("matrix2: ")
11
12
13 print(matrix2)
14
15 multiplication_result = np.dot(matrix1, matrix2)
16 print("Multiplication_result: ")
17 print(multiplication_result)

matrix1:
[[1 2 3]
[4 5 6]
[7 8 9]]
matrix2:
[[9 8 7]
[6 5 4]
[3 2 1]]
Multiplication_result:
[[ 30 24 18]
[ 84 69 54]
[138 114 90]]

1 matrix1 = np.array([[11, 24],


2 [46, 56]])
3 print("matrix1: ")
4 print(matrix1)
5 matrix2 = np.array([[9, 8],
6 [6, 5]])
7
8 print("matrix2: ")
9 print(matrix2)
10 multiplication_result = np.dot(matrix1, matrix2)
11 print("Multiplication_result: ")
12 print(multiplication_result)

matrix1:
[[11 24]
[46 56]]
matrix2:
[[9 8]
[6 5]]
Multiplication_result:
[[243 208]
[750 648]]

keyboard_arrow_down Division of the two Matrix


1 matrix1 = np.array([[1, 2, 3],
2 [4, 5, 6],
3 [7, 8, 9]])
4 print("matrix1: ")
5 print(matrix1)
6
7 matrix2 = np.array([[9, 8, 7],
8 [6, 5, 4],
9 [3, 2, 1]])
10 print("matrix2: ")
11 print(matrix2)
12
13 division_result = np.divide(matrix1, matrix2)
14 print("Division_result: ")
15 print(division_result)

matrix1:
[[1 2 3]
[4 5 6]
[7 8 9]]
matrix2:
[[9 8 7]
[6 5 4]
[3 2 1]]
Division_result:
[[0.11111111 0.25 0.42857143]
[0.66666667 1. 1.5 ]
[2.33333333 4. 9. ]]

1 matrix1 = np.array([[11, 24],


2 [46, 56]])
3 print("matrix1: ")
4 print(matrix1)
5 matrix2 = np.array([[9, 8],
6 [6, 5]])
7
8 print("matrix2: ")
9 print(matrix2)
10 division_result = np.divide(matrix1, matrix2)
11 print("Division_result: ")
12 print(division_result)

matrix1:
[[11 24]
[46 56]]
matrix2:
[[9 8]
[6 5]]
Division_result:
[[ 1.22222222 3. ]
[ 7.66666667 11.2 ]]

keyboard_arrow_down Determinant of the matrix


1 matrix1 = np.array([[11, 24, 36],
2 [46, 56, 6],
3 [0, 8, 19]])
4 print("matrix1: ")
5 print(matrix1)
6
7 determinant_result = np.linalg.det(matrix1)
8 print(f"The Detrminant of the matrix is: {determinant_result}")

matrix1:
[[11 24 36]
[46 56 6]
[ 0 8 19]]
The Detrminant of the matrix is: 3447.9999999999964
1 matrix1 = np.array([[11, 24],
2 [46, 56]])
3 print("matrix1: ")
4 print(matrix1)
5
6 determinant_result = np.linalg.det(matrix1)
7 print(f"The Detrminant of the matrix is: {determinant_result}")

matrix1:
[[11 24]
[46 56]]
The Detrminant of the matrix is: -487.9999999999998

keyboard_arrow_down Inverse of the Matrix


1 matrix1 = np.array([[11, 24, 36],
2 [46, 56, 6],
3 [0, 8, 19]])
4 print(matrix1)
5
6 determinant_result = np.linalg.det(matrix1)
7 print(f"The Detrminant of the matrix is: {determinant_result}")
8
9
10
11 inverse_result = np.linalg.inv(matrix1)
12 print(inverse_result)
13

[[11 24 36]
[46 56 6]
[ 0 8 19]]
The Detrminant of the matrix is: 3447.9999999999964
[[ 0.29466357 -0.0487239 -0.54292343]
[-0.25348028 0.06061485 0.46113689]
[ 0.10672854 -0.02552204 -0.14153132]]

1 matrix1 = np.array([[11, 24],


2 [46, 56]])
3 print(matrix1)
4 determinant_result = np.linalg.det(matrix1)
5 print(f"The Detrminant of the matrix is: {determinant_result}")
6
7 inverse_result = np.linalg.inv(matrix1)
8 print(inverse_result)
9

[[11 24]
[46 56]]
The Detrminant of the matrix is: -487.9999999999998
[[-0.1147541 0.04918033]
[ 0.0942623 -0.02254098]]

keyboard_arrow_down Rank of the matrix


1 import numpy as np
2
3 matrix = np.array([[1, 2, 3],
4 [2, 1, 4],
5 [3, 0, 5]])
6
7
8 rank = np.linalg.matrix_rank(matrix)
9
10
11 print("The matrix is:")
12 print(matrix)
13 print(f"The rank of the matrix is: {rank}")

The matrix is:


[[1 2 3]
[2 1 4]
[3 0 5]]
The rank of the matrix is: 2

1 matrix1 = np.array([[11, 24],


2 [44, 96]])
3
4
5 rank = np.linalg.matrix_rank(matrix1)
6
7
8 print("The matrix is:")
9 print(matrix1)

The matrix is:


[[11 24]
[44 96]]
The rank of the matrix is: 1

keyboard_arrow_down Eigen Valuse And Eigen Vector of the Matrix


1 matrix = np.array([[1, 2, 3],
2 [4, 5, 6],
3 [7, 8, 9]])
4
5 eigenvalues, eigenvectors = np.linalg.eig(matrix)
6
7 print("The matrix is:")
8 print(matrix)
9 print("Eigenvalues:")
10 print(eigenvalues)
11 print("Eigenvectors:")
12 print(eigenvectors)
13
14

The matrix is:


[[1 2 3]
[4 5 6]
[7 8 9]]
Eigenvalues:
[ 1.61168440e+01 -1.11684397e+00 -9.75918483e-16]
Eigenvectors:
[[-0.23197069 -0.78583024 0.40824829]
[-0.52532209 -0.08675134 -0.81649658]
[-0.8186735 0.61232756 0.40824829]]
The matrix is:
[[11 24]
[46 56]]
Eigenvalues:
[-6.62792045 73.62792045]
Eigenvectors:
[[-0.80595764 -0.35784021]
[ 0.59197321 -0.93378284]]

1 matrix1 = np.array([[11, 24],


2 [46, 56]])
3
4 eigenvalues, eigenvectors = np.linalg.eig(matrix1)
5
6 print("The matrix is:")
7 print(matrix1)
8 print("Eigenvalues:")
9 print(eigenvalues)
10 print("Eigenvectors:")
11 print(eigenvectors)

The matrix is:


[[11 24]
[46 56]]
Eigenvalues:
[-6.62792045 73.62792045]
Eigenvectors:
[[-0.80595764 -0.35784021]
[ 0.59197321 -0.93378284]]

1 Start coding or generate with AI.

You might also like