Instagram
youtube
Facebook
Twitter

Compute the Cross Product of Two NumPy Arrays

     Compute the Cross Product of Two NumPy Arrays
      
       Short Description of the Program:

      This program calculates the cross product of two NumPy arrays using the np.cross() function.
      
       Explanation:

  • np.array()
    Creates two 1D arrays, each representing a 3D vector.

     
  • np.cross(array1, array2)
    Computes the cross product, which results in a vector that is perpendicular to both input vectors.

     
  • print()
    Outputs both original arrays and the resulting cross product vector.

Program:

import numpy as np

array1 = np.array([1, 2, 3])

array2 = np.array([4, 5, 6])

cross_product = np.cross(array1, array2)

print("Array 1:", array1)

print("Array 2:", array2)

print("\nCross Product Result:", cross_product)