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?
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:49supand then callsub? Did you try actually executing this code? – Ghoster Mar 16 '24 at 22:17$Assumptionsthat the matrix elements are three-component vectors isn’t going to let youCrossthem component-wise with $\vec B$. Have you experimented with howCrossworks? – Ghoster Mar 17 '24 at 03:10Subscript, you should use it for formatting, not in calculations. See point 3 here and the links therein. – Ghoster Mar 17 '24 at 03:23Map[Cross[#, B]&, vel, {2}]. – Ghoster Mar 18 '24 at 00:55