×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Norm of the Vector | Linear Algebra using Python

Linear Algebra using Python | Norm of the Vector: Here, we are going to learn about the norm of the vector and its implementation in Python.
Submitted by Anuj Singh, on June 09, 2020

Prerequisite:

Here, we are going to learn how to find the norm of a vector using an inbuilt function in numpy library?

Python code for norm of the vector

# Linear Algebra Learning Sequence
# Outer Product Property I

import numpy as np

a = np.array([2, 4, 8, 7, 7, 9, -6])
b = np.array([2, 3, 1, 7, 8])

#outer product in both order
ma = np.linalg.norm(a)
mb = np.linalg.norm(b)

print('A : ', a)
print('B : ', b)
print('\n\nNorm of A : ', ma)
print('\n\nNorm of B : ', mb)

Output:

A :  [ 2  4  8  7  7  9 -6]
B :  [2 3 1 7 8]


Norm of A :  17.291616465790582


Norm of B :  11.269427669584644
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.