Dot Product of Vectors | Linear Algebra using Python

Linear Algebra using Python | Dot Product of Vectors: Here, we are going to learn how to find dot product of vectors in Python?
Submitted by Anuj Singh, on May 21, 2020

Prerequisite: Linear Algebra | Defining a Vector

Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. In other words, a vector is a matrix in n-dimensional space with only one column.

In this tutorial, we are going to learn the Dot product of two vectors. The dot product of two vectors is only possible when both have the same dimensions.

Syntax:

    dot_product = Vecotr_1.dot(Vector_2)

This is an inbuilt function for dot product of two vectors.

Python code to find the dot product of vectors

# Linear Algebra Learning Sequence
# Dot Product of Vectors

import numpy as np

# Use of np.array() to define an Vector
V = np.array([323,623,823])
print("The Vector A : ",V)

VV = np.array([3,63,78])
print("\nThe Vector B : ",VV)

pro = V.dot(VV)

print("Product of two vectors : ", pro)

Output:

The Vector A :  [323 623 823]

The Vector B :  [ 3 63 78]
Product of two vectors :  104412






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.