Vector projection is used for determining the component of a vector along with a specific direction. There are many real-life examples of vector projection. For example, you can use it for finding the emotions of a human being or the character of the person. In this entire tutorial, you will know how to calculate * Projection of Vector a on b in Numpy* using the various methods.

## Method to Find Projection of Vector a on b in Numpy

Numpy is a great python package for creating an array and computing complex mathematical calculations. There are many inbuilt functions for that. You will use all the methods for finding Projection of Vector a on b using Numpy.

### Method 1: Find Projection using formulae

The first method you will know is the use of Vector Projection formulae. If you know the formulae then it’s good. But if you don’t know then below is the formulae.

Now let’s find the Projection of Vector a on b in Numpy. Use the below lines of code to calculate vector projection in python.

```
import numpy as np
a = np.array([10,-20,30])
b = np.array([30,15,-40])
vp = (np.dot(a, b) / np.dot(b, b)) * b
print(vp)
```

**Output**

**Explanation of the code**

Here I have to use the projection formulae as the above. But to find the dot product of a and b I have used np.dot() method provided by the NumPy package. I have divided the dot product of a and b by the dot product of b with b itself. After that multiply the result with the b vector for specifying the direction.

### Method 2: Finding the Projection using the normalization

The other method to f* ind the projection of a on b in NumPy *is using the normalization of the second vector. You can find the normalization of the vector you will use the inbuilt np.linalg.norm() method.

Execute the below lines of code.

```
import numpy as np
a = np.array([10,-20,30])
b = np.array([30,15,-40])
vp = (np.dot(a, b) / np.linalg.norm(b)**2 ) * b
print(vp)
```

**Output**

The answer will be the same if you will compare the results for both methods.

## Conclusion

There are many useful vector projections in real-life. These are the methods for finding the projection of a vector with another vector. You can use any one of them.

I hope you have liked this tutorial. If you have any query regarding this then you can contact us for more help.

#### Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.