Let's say I have a 2x2 matrix (with symbols) called 'A'. Now, if do

B = sympy.tensorproduct(A,A)

I get,


which is a 4 rank tensor.

However, what I want back is a 2 rank 4x4 matrix. How can I do that?

I tried reading documentations for sympy and found out about reshape. But it didn't work for me. The one difference I could note was that in the examples the matrices were very simple or only had numbers. While the matrix I am trying has some exponentials of time (a variable/symbol).

  • $\begingroup$ Your question does not say what kind of operation you actually want! $\endgroup$ Jan 16, 2022 at 19:01
  • $\begingroup$ My question is right above the long paragraph part. I can see how people can fail to notice it though. I'll put the main part of the question in bold in a separate line. Maybe that will help. $\endgroup$ Jan 16, 2022 at 19:22
  • $\begingroup$ What I was asking is this: There are many 4x4 matrices one could construct. You are asking what function to call, but you are not saying what mathematical operation you are trying to attempt, and so it is unclear which function would be useful. $\endgroup$ Jan 18, 2022 at 0:20

1 Answer 1


If I understand correctly, you want numpy.kron.

  • 2
    $\begingroup$ Wow. It never occured to me that numpy would work just fine with symbols. I knew about kron but kept looking in sympy. Thanx a lot $\endgroup$ Jan 16, 2022 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.