1

I defined a symbolic matrix with vector elements as:

sub[index__] := Subscript[index];
generatematrix[m_, n_, b_] := 
  Table[sub[b, i, j], {i, m}, {j, n}];
matrix := generatematrix[4, 4, #] &;

$Assumptions = sub[v, _] [Element] Vectors[3]; vel = matrix@v;

giving the symbolic velocity matrix $vel$ as

{{Subscript[v, 1, 1], Subscript[v, 1, 2], Subscript[v, 1, 3], Subscript[v, 1, 4]}
{Subscript[v, 2, 1], Subscript[v, 2, 2], Subscript[v, 2, 3], Subscript[v, 2, 4]},
  {Subscript[v, 3, 1], Subscript[v, 3, 2], Subscript[v, 3, 3], Subscript[v, 3, 4]}, 
{Subscript[v, 4, 1], Subscript[v, 4, 2], Subscript[v, 4, 3], Subscript[v, 4, 4]}}

I want to now cross this with the magnetic field, as a symbolic vector, to obtain the Lorentz force, $\mathbb{v}\times B$,

{{Cross[Subscript[v, 1, 1], B], Cross[Subscript[v, 1, 2], B], Cross[Subscript[v, 1, 3], B], Cross[Subscript[v, 1, 4], B]},{Cross[Subscript[v, 2, 1], B], Cross[Subscript[v, 2, 2], B],Cross[Subscript[v, 2, 3], B], Cross[Subscript[v, 2, 4], B]},{Cross[Subscript[v, 3, 1], B], Cross[Subscript[v, 3, 2], B],Cross[Subscript[v, 3, 3], B], Cross[Subscript[v, 3, 4], B]},{Cross[Subscript[v, 4, 1], B], Cross[Subscript[v, 4, 2], B],Cross[Subscript[v, 4, 3], B], Cross[Subscript[v, 4, 4], B]}} //MatrixForm

How to do this?

Harken
  • 105
  • 6
  • 2
    To minimize the chance of anyone misunderstanding, please edit your post into the form: v=...contents of your velocity matrix...;B=...exactly whatever it is;iden=...exactly the identity matrix you are using; followed by "And I want" exactly the desired result. Your posting blocks of code is great, so much better than spending all the time to try to desktop publish the format which would then mean everyone reading would have to spend all the time undoing it to be able to get code to put into MMA. – Bill Mar 16 '24 at 21:49
  • Why did you define sup and then call sub? Did you try actually executing this code? – Ghoster Mar 16 '24 at 22:17
  • 3
    Why is velocity a matrix instead of a vector? What does that mean? What is a cross product of two matrices supposed to mean? What is the point of the identity matrix? The Lorentz force involves a cross product between a magnetic field 3-vector $\vec B$ and a velocity 3-vector $\vec v$. The Lorentz force does not involve matrices. – Ghoster Mar 16 '24 at 22:22
  • Here the velocity is a matrix in an abstract space, which is very often the case in physics, whose elements are themselves vectors as $v_{ij}$. So I have a matrix with vector entities. Now I want to be able to define the Lorentz force for every element of this matrix as $v_{ij}\times B$. Here $B$ is just the magnetic field vector. – Harken Mar 16 '24 at 22:49
  • Here the velocity is a matrix in an abstract space, which is very often the case in physics, whose elements are themselves vectors. I’m a physicist and I don’t know what you’re talking about. Velocity of what? – Ghoster Mar 17 '24 at 00:43
  • 1
    If $B$ is a vector, why is the title of your question “Cross product of two matrices? – Ghoster Mar 17 '24 at 00:44
  • If you have a matrix of velocity vectors $\vec v_{ij}$ and you want to take the cross product of each of them with $\vec B$ to get another matrix then you can use Map and Cross. But a matrix of velocities is not a velocity. – Ghoster Mar 17 '24 at 00:48
  • @Ghoster In quantum mechanics the velocity operator is defined as the commutator of the Hamiltonian and position operators, $v = i [H , r]$. These operators have elements in the space of the particles' energy eigenstates. Clearly, for the physicists out there, the elements for just four energy bands is the matrix I defined above, whose diagonal elements give the electron velocity in each energy band and the off-diagonal elements are the influence of the neighboring bands. – Harken Mar 17 '24 at 01:28
  • OK, I get now that the $\vec v_{ij}$ are matrix elements of the quantum velocity operator. You’ve written $\vec B$ as a three-component vector, so why have you not written each $\vec v_{ij}$ as a three-component vector? If you’re going to take a cross product, you need to either compute it component-wise, in which case both vectors need three components, or you need to do it symbolically, in which case neither needs components. Also, the title remains misleading by referring to two matrices. – Ghoster Mar 17 '24 at 03:04
  • Specifying in $Assumptions that the matrix elements are three-component vectors isn’t going to let you Cross them component-wise with $\vec B$. Have you experimented with how Cross works? – Ghoster Mar 17 '24 at 03:10
  • Since you haven’t specified what your desired result is, the question remains too unclear for someone to write code for you. – Ghoster Mar 17 '24 at 03:14
  • 1
    Regarding the use of Subscript, you should use it for formatting, not in calculations. See point 3 here and the links therein. – Ghoster Mar 17 '24 at 03:23
  • I specified my desired result now. I mentioned that $B$ as well as $v_{ij}$ are symbolic vectors. I do not wish, nor do I know how at the moment, to specify the components of these vectors. – Harken Mar 17 '24 at 18:27
  • 1
    Try Map[Cross[#, B]&, vel, {2}]. – Ghoster Mar 18 '24 at 00:55
  • Yes, it works. Exactly what I needed. Besides, how can I specify that $v_{ij}$ and $B$ are symbolic vectors? Or in general, how can I define a symbolic vector? – Harken Mar 18 '24 at 08:49
  • If you want to consider them symbolic vectors, you’re free to do that. What do you want Mathematica to do with them that it’s not doing? Draw an arrow above them? BTW, you have to put @Ghoster in your comments if you want me to be notified of them. – Ghoster Mar 18 '24 at 21:57

0 Answers0