- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Return the multiple vector cross product of two (arrays of) vectors in Python

To compute the cross product of two vectors, use the numpy.cross() method in Python Numpy. The method returns c, the Vector cross product(s). The 1st parameter is a, the components of the first vector(s). The 2nd parameter is b, the components of the second vector(s). The 3rd parameter is axisa, the axis of a that defines the vector(s). By default, the last axis. The 4th parameter is axisb, the axis of b that defines the vector(s). By default, the last axis.

The 5th parameter is axisc, the axis of c containing the cross product vector(s). Ignored if both input vectors have dimension 2, as the return is scalar. By default, the last axis. The 6th parameter is the axis, if defined, the axis of a, b and c that defines the vector(s) and cross product(s). Overrides axisa, axisb and axisc.

## Steps

At first, import the required libraries −

import numpy as np

Creating two vectors. We have inserted elements of int type −

arr1 = np.array([[5,10,15], [30,35,40]]) arr2 = np.array([[30,35,40], [5,10,15]])

Display the vectors −

print("Vector 1...

", arr1) print("

Vector 2...

", arr2)

To compute the cross product of two vectors, use the numpy.cross() method in Python Numpy −

print("

Result...

",np.cross(arr1, arr2))

## Example

import numpy as np # Creating two vectors # We have inserted elements of int type arr1 = np.array([[5,10,15], [30,35,40]]) arr2 = np.array([[30,35,40], [5,10,15]]) # Display the vectors print("Vector 1...

", arr1) print("

Vector 2...

", arr2) # To compute the cross product of two vectors, use the numpy.cross() method in Python Numpy print("

Result...

",np.cross(arr1, arr2))

## Output

Vector 1... [[ 5 10 15] [30 35 40]] Vector 2... [[30 35 40] [ 5 10 15]] Result... [[-125 250 -125] [ 125 -250 125]]

- Related Articles
- Return the cross product of two (arrays of) vectors in Python
- Return the multiple vector cross product of two vectors and change the orientation of the result in Python
- Return the cross product of two (arrays of) vectors with different dimensions in Python
- Return the dot product of two vectors in Python
- Return the dot product of two multidimensional vectors in Python
- C++ Program for dot product and cross product of two vectors
- C++ Program to Compute Cross Product of Two Vectors
- Return the dot product of One-Dimensional vectors in Python
- How to find the cross product of two vectors in R by adding the elements?
- Return the inner product of two masked arrays in Numpy
- Return the outer product of two masked arrays in Numpy
- Return the dot product of two masked arrays in Numpy
- Return the inner product of two masked One-Dimensional arrays in Numpy
- Return the inner product of two masked Three Dimensional arrays in Numpy
- Get the Kronecker product of two arrays in Python