I'm doing some quantum mechanics homework that I'm going to eventually generalize to higher spin states, so the solutions are going to need to be decently independent of the dimensions of the table and constants that I'm using.
I'm trying to solve the eigenvalue problem for a generalized spin matrix (defined by angles in spherical coordinates) as shown below (currently spin-1/2, but will be generalized to higher dimensions soon). S
is a column vector in complex 3-space for now. The components are going to be the b
by b
square spin matrices (x, y, and z) for whatever spin we are in. They'll be Pauli matrices times a constant- obviously for larger spin particles, I'm going to have to calculate them separately. n
will always be a column vector, b
long, that defines our basis for the eigenvalue problem. It will always be a unit vector and will always be in terms of sines and cosines of ungodly angles- like spherical coordinates. Sn is the dot product of these, but of course you can't calculate it like a dot product because the components of S
are matrices. :(
b = 3
S = h/2*Table[PauliMatrix[k], {k, b}]
n = {Sin[\[Theta]]*Cos[\[Phi]], Sin[\[Theta]]*Sin[\[Phi]], Cos[theta]}
Sn = Sum[S[[k]]*n[[k]], {k, b}] // MatrixForm
To progress in this (pretty fundamental) problem, especially in more tedious higher dimensional matrices, I need to make the resulting matrix a lot prettier by factoring out constants and applying Euler's identity.
So Sn
is what I'm trying to solve for. I get a 2x2 matrix with ugly terms, and every term has a factor of h/2 in it. I'd like to factor this out here, but with higher spin states, I'm going to have different weird multiples of h. These will always be integers times the constant at the beginning of S
's definition. Not really sure how to do this- Hold
would screw up the intermediate matrix multiplication and table lookups, right?
Also, in the off-diagonal slots for this specific matrix, you can see that there are factors of Cos[phi]+iSin[phi] in both slots. I need to apply Euler's identity, ie, turn each factor of that into e^(i*phi). The issue, again, is that when I generalize into higher dimensions, there definitely will be angles that aren't phi that need euler's identity applied, and I have no idea how ugly the factoring will get. Replace won't work here, unless I'm confused about how to get it to replace with unspecified variables.
If anyone has ideas about how I can get Mathematica to do the leg work of factoring in those nasty higher spin states, I would really appreciate it.
Tl;dr? I need to have Mathematica RIGOROUSLY pull constants out of an n*n matrix and apply Euler's identity wherever it possibly can. Everything will be awfully symbolic and stuck in tables upon tables. Good luck, wizards.
TrigToExp[]
? $\endgroup$TrigToExp[]
"over-converts", and what you were expecting instead. $\endgroup$MapIndexed[]
for that purpose:MapIndexed[If[Equal @@ #2, #1, TrigToExp[#1]] &, Sn, {2}]
. $\endgroup$