Hot answers tagged

9

How about this furious[a_, b_] := Module[{a1, a2, a3, b1, b2, b3, c}, {a1, a2, a3} = Transpose[a, {2, 3, 4, 1}]; {b1, b2, b3} = Transpose[b, {2, 3, 4, 1}]; c = {-a3 b2 + a2 b3, a3 b1 - a1 b3, -a2 b1 + a1 b2}; Transpose[c, {4, 1, 2, 3}]] Timing results (from march's answer) for version 10.4.1 list1 = RandomReal[{-1, 1}, {32, 32, 32, 3}]; list2 = ...


7

Interestingly enough, MapThreading Cross works but is much slower: Using sample lists: list1 = Array[c, {20, 20, 20, 3}]; list2 = Array[d, {20, 20, 20, 3}]; We can perform this operation in the following two ways, using MapThread: listCrossMarch1[list1_, list2_] := MapThread[Cross, {list1, list2}, 3] listCrossMarch2[list1_, list2_] := MapThread[{#1[[2]] ...


5

One thing you might want to do is write the vector $\vec{a}$ as some magnitude $\theta$ times a unit vector {a1, a2, a3}. Then calculate $\exp(i \theta \,a\cdot\sigma)$. This will allow you to get rid of those factors of $\sqrt{a_1^2+a_2^2+a_3^2}$, which are just some $\theta$ anyway. Here it is in Mathematica:a = \[Theta] {a1, a2, a3}; b = a.Array[...


3

For the first part, you can use MatrixExp. Since you are interested in trigonometric form, I would suggest using polar coordinates from the beginning. p0 = PauliMatrix[0]; p1 = PauliMatrix[1]; p2 = PauliMatrix[2]; p3 = PauliMatrix[3]; a1 = a Sin[q1] Cos[q2]; a2 = a Sin[q1] Sin[q2]; a3 = a Cos[q1]; m = a1 p1 + a2 p2 + a3 p3; m1 = MatrixExp[I m] // ...


3

To verify that the rotations happen the way they're supposed to according to the documentation for EulerMatrix, you could use the following Manipulate: Clear[arrowAxes]; arrowAxes[arrowLength_: 1] := Map[{Apply[RGBColor, #], Arrow[Tube[{-#, #}]]} &, arrowLength IdentityMatrix[3]] Manipulate[ Graphics3D[{GeometricTransformation[arrowAxes[.7], ...


2

You can directly use the function pauliReduce that I defined in this answer: a = {a1, a2, a3} (* ==> {a1, a2, a3} *) a.{σ[1], σ[2], σ[3]} (* ==> a1 σ[1] + a2 σ[2] + a3 σ[3] *) pauliReduce[ MatrixExp[I a.{σ[1], σ[2], σ[3]}]] $$\frac{1} {\sqrt{\text{a1}^2+\text{a2}^2+\text{a3}^2}}\left(\hat{1} \sqrt{\text{a1}^2+\text{a2}^2+\text{a3}^2} \cos ...


1

The answer depends on how you characterise the matrix. Let say you can define it in terms of sum of absolute values of the element. norm1[m_List] := Total@Flatten@Abs[m] Or you can define it as Norm of diagonal elements norm2[m_List] := Norm@Diagonal[m] Given a matrix m m = RandomReal[{-5, 5}, {3, 3}] {{-2.72364, 2.26668, 4.07867}, {-1.8835, 0....


1

We can put a wrapper q around the numeric values in our matrices. multcount = 0; addcount = 0; q[a_] q[b_] ^:= (multcount++; q[a b]) q[a_] + q[b_] ^:= (addcount++; q[a + b]) a_ q[b_] ^:= (multcount++; q[a b]) Defining A = RandomReal[9, {10, 10}]; qA = Map[q, A, {2}]; We can evaluate adjqA = Transpose[Table[Cofactor[qA, {i, j}], {i, 1, 10}, {j, 1, 10}]]...



Only top voted, non community-wiki answers of a minimum length are eligible