-3

Code:

import numpy as np
import math as m 
a=np.array([[1,6,2],[4,5,0],[3,7,8]])

b=np.array([[4,1],[2,5]])
print(a*a*b,'\n') 

Error:

Operands could not be broadcast together with shapes (3,3) (2,2)

How can I solve this problem, plus I'm new in python.

Any suggestion.

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • you can't multiple a 3x3 matrix with a 2x2 matrix. If the second one was 1x3, 3x1, or scalar you can define multiplication (broadcasting), but not if the dimensions don't match. – karakfa Aug 28 '20 at 01:54

1 Answers1

0

This problem can sadly not be solved, as mathematically you can not multiply a 2x2 matrix and a 3x3 matrix together.