To write a program to find the 1-norm, 2-norm and infinity norm of the matrix and display the result in two decimal places.
- Hardware – PCs
- Anaconda – Python 3.7 Installation / Moodle-Code Runner
1. Get the input matrix using np.array()
2. Find the 2-norm of the matrix using np.linalg.norm()
3. Print the norm of the matrix in two decimal places.
# Register No:23003133
# Developed By:MOHAMED RIDWAN A
# 1-Norm of a Matrix
import numpy as np
a=np.array(eval(input()))
b=np.linalg.norm(a,1)
c='{:.2f}'.format(b)
print(c)
Program to find 2-norm of a matrix.
Developed by: MOHAMED RIDWAN A
RegisterNumber:23003133
import numpy as np
a=np.array(eval(input()))
b=np.linalg.norm(a,2)
c='{:.2f}'.format(b)
print(c)
'''
Program to find infinity-norm of a matrix.
Developed by: MOHAMED RIDWAN A
RegisterNumber: 23003133
'''
import numpy as np
a=np.array(eval(input()))
b=np.linalg.norm(a,np.inf)
c='{:.2f}'.format(b)
print(c)
Thus the program for 1-norm, 2-norm and Infinity norm of a matrix are written and verified.