Multiply matrices of complex numbers using NumPy in Python Last Updated : 23 Feb, 2023 Comments Improve Suggest changes Like Article Like Report 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 - (a+ib) \times (x+iy)=ax+i^2by+i(bx+ay)=ax-by+i(bx+ay) 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). Syntax: numpy.vdot(vector_a, vector_b) Example 1: Python3 # importing numpy as library import numpy as np # creating matrix of complex number x = np.array([2+3j, 4+5j]) print("Printing First matrix:") print(x) y = np.array([8+7j, 5+6j]) print("Printing Second matrix:") print(y) # vector dot product of two matrices z = np.vdot(x, y) print("Product of first and second matrices are:") print(z) Output: 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) Time complexity: O(1)Auxiliary space: O(1) Example 2: Now suppose we have 2D matrix: Python3 # importing numpy as library import numpy as np # creating matrix of complex number x = np.array([[2+3j, 4+5j], [4+5j, 6+7j]]) print("Printing First matrix:") print(x) y = np.array([[8+7j, 5+6j], [9+10j, 1+2j]]) print("Printing Second matrix:") print(y) # vector dot product of two matrices z = np.vdot(x, y) print("Product of first and second matrices are:") print(z) Output: 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) Time complexity: O(n^2), where n is the dimension of the matrices.Auxiliary space: O(1), as the matrices and their product are stored in memory and no additional space is used. Comment More infoAdvertise with us Next Article Multiply matrices of complex numbers using NumPy in Python H hupphurr Follow Improve Article Tags : Python Python-numpy Python numpy-Matrix Function Practice Tags : python Similar Reads How to plot a complex number in Python using Matplotlib ? In this article we will learn how to plot complex number in Python using Matplotlib. Let's discuss some concepts : Matplotlib : Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designe 3 min read Multiplication of two Matrices in Single line using Numpy in Python Matrix multiplication is an operation that takes two matrices as input and produces single matrix by multiplying rows of the first matrix to the column of the second matrix.In matrix multiplication make sure that the number of columns of the first matrix should be equal to the number of rows of the 3 min read Compute the condition number of a given matrix using NumPy In this article, we will use the cond() function of the NumPy package to calculate the condition number of a given matrix. cond() is a function of linear algebra module in NumPy package. Syntax:Â numpy.linalg.cond(x, p=None) Example 1: Condition Number of 2X2 matrix Python3 # Importing library impor 2 min read Python program for multiplication and division of complex number Given two complex numbers. The task is to multiply and divide them. Multiplication of complex number: In Python complex numbers can be multiplied using * operator Examples: Input: 2+3i, 4+5i Output: Multiplication is : (-7+22j) Input: 2+3i, 1+2i Output: Multiplication is : (-4+7j) Python3 # Python p 3 min read Compute the determinant of a given square array using NumPy in Python In Python, the determinant of a square array can be easily calculated using the NumPy package. This package is used to perform mathematical calculations on single and multi-dimensional arrays. numpy.linalg is an important module of NumPy package which is used for linear algebra. We can use det() fun 2 min read Like