Calculate Dot Product of Two Vectors in Numpy for Beginners – Numpy Tutorial

By | September 15, 2019

Dot product of two vectors is defined as:

dot product

In this tutorial, we will write an example to show how to compute dot product of two vectors in numpy.


import numpy as np

Create two vectors

v1 = np.array([1, 2, 3, 4])
v2 = np.array([2, 3, 4, 5])

Calculate the dot product of this two vector

d =, v2)

The output is:


We shoud use function to calculate, however, we can not use * operation

d2 = v1 * v2

The output is:

array([ 2,  6, 12, 20])

which is Hadamard Product of this two vector.

Leave a Reply

Your email address will not be published. Required fields are marked *