So I need to calculate a 3x3 rotation operator (basically a matrix). I have an index-notation expression, and I was wondering if with pre-calculated theta, K1, K2, and K3, could Mathematica compute each cell of this matrix for me?
The rotation operator M is defined as such, for i, j, and k from 1 to 3.
M(i,j) = K(i) * K(j) + cos(theta) * (kronecker_delta(i,j) - K(i)*K(j)) +
sin(theta) * (levi_civita_tensor(i,k,j) * K(k))
I tried something new:
n = {0, 0, 1}
mat = Table[
n[[i]]*n[[j]] +
Cos[Theta] * (KroneckerDelta[i, j] - n[[i]]*n[[j]]) +
Sin[Theta] * LeviCivitaTensor[3][[i, k, j]] * n[[k]],
{i, 3}, {j, 3}, {k, 3}] (*//MatrixForm*)
The following output is pretty distinctly not a 3 * 3 matrix:
{{{Cos[Theta], Cos[Theta], Cos[Theta]}, {0, 0, -Sin[Theta]}, {0, 0,
0}}, {{0, 0, Sin[Theta]}, {Cos[Theta], Cos[Theta], Cos[Theta]}, {0,
0, 0}}, {{0, 0, 0}, {0, 0, 0}, {1, 1, 1}}}
How do I fix this? I think it's iterating through k as if k were indices in the matrix.
Edit to the edit:
I tried summing k over the dimensions i needed, for some reason it's still being taken as a 3d matrix.
dimensions = 3
n = {0, 0, 1}
mat = Table[
n[[i]]*n[[j]] +
Cos[Theta] * (KroneckerDelta[i, j] - n[[i]]*n[[j]]) +
Sum[Sin[Theta] * LeviCivitaTensor[3][[i, k, j]] * n[[k]], {k, 1, dimensions}],
{i, dimensions}, {j, dimensions}, {k, dimensions}] // MatrixForm
mat
, theTable
has three indicesi,j,k
resulting in a 3 by 3 by 3 table. It should have only two indices. $\endgroup$k
, as if it was adding a sum over k of that third term. $\endgroup$