In this article, we will discuss how to multiply two matrices containing complex numbers using NumPy but first, let’s know what is a complex number. A Complex Number is any number that can be represented in the form of x+yj where x is the real part and y is the imaginary part. Multiplication of two complex numbers can be done using the below formula –
NumPy provides the vdot() method that returns the dot product of vectors a and b. This function handles complex numbers differently than dot(a, b).
Printing First matrix: [2.+3.j 4.+5.j] Printing Second matrix: [8.+7.j 5.+6.j] Product of first and second matrices are: (87-11j)
Example 2: Now suppose we have 2D matrix:
Printing First matrix: [[2.+3.j 4.+5.j] [4.+5.j 6.+7.j]] Printing Second matrix: [[8. +7.j 5. +6.j] [9.+10.j 1. +2.j]] Product of first and second matrices are: (193-11j)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python program to multiply two matrices
- Multiplication of two Matrices in Single line using Numpy in Python
- How to multiply a polynomial to another using NumPy in Python?
- Extracting the real and imaginary parts of an NumPy array of complex numbers
- Calculate inner, outer, and cross products of matrices and vectors using NumPy
- numpy.defchararray.multiply() in Python
- numpy.multiply() in Python
- Python | Multiply 2d numpy array corresponding to 1d array
- numpy.char.multiply() function in Python
- Complex Numbers in Python | Set 1 (Introduction)
- Complex Numbers in Python | Set 2 (Important Functions and Constants)
- Complex Numbers in Python | Set 3 (Trigonometric and Hyperbolic Functions)
- Python program for addition and subtraction of complex numbers
- Python Program to convert complex numbers to Polar coordinates
- Python | Multiply Integer in Mixed List of string and numbers
- Python | Multiply all numbers in the list (4 different ways)
- Selecting with complex criteria using query method in Pandas
- Python program to add two Matrices
- Python program to add two matrices
- Python List Equality | Program to check if two given matrices are identical