Multiply matrices of complex numbers using NumPy in Python
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)