Home »
Python »
Linear Algebra using Python
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