Hot answers tagged

7

Three possibilities: With[{n = 4}, ArrayFlatten[{{NestList[RotateRight, Array[B, n], n - 1], 1}, {{Array[A, n]}, 1}}]] With[{n = 4}, ArrayFlatten[{{ToeplitzMatrix[RotateRight[Reverse[Array[B, n]]], Array[B, n]], 1}, {{Array[A, n]}, 1}}]] With[{n = 4}, PadRight[Append[NestList[RotateRight, Array[B, n], ...


5

Here's one way: ap = ConstantArray[0.001, {5, 10}]; b = {0.001, 0.005, 0.009, 0.01, 0.03, 0.05, 0.082, 0.1, 0.5, 1}; z = {{1, 3}, {2, 2}, {5, 7}}; f[ap_, {z1_, z2_}] := ReplacePart[ap, {z1, i_ /; i >= z2} :> b[[i]]] Fold[f, ap, z] (* {{0.001, 0.001, 0.009, 0.01, 0.03, 0.05, 0.082, 0.1, 0.5, 1}, {0.001, 0.005, 0.009, 0.01, 0.03, 0.05, 0.082, 0.1,...


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

Your example can be achieved using Map with a level specification, Partition to generate the sub-matrices and Tr to calculate the traces. ClearAll[a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] r = {{a, b, c, d}, {e, f, g, h}, {i, j, k, l}, {m, n, o, p}}; Map[Tr, Partition[r, {2, 2}], {2}] {{a + f, c + h}, {i + n, k + p}}


2

Table[Table[ap[[z[[i, 1]], j]] = b[[j]], {j, z[[i, 2]], 10}], {i, 3}]; ap {{0.001, 0.001, 0.009, 0.01, 0.03, 0.05, 0.082, 0.1, 0.5, 1}, {0.001, 0.005, 0.009, 0.01, 0.03, 0.05, 0.082, 0.1, 0.5, 1}, {0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001}, {0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0....


2

a = Table[j^2, {j, 1, 25}]; b = Table[Log@j, {j, 1, 25}]; ListPlot[Transpose[{a, b}]]


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

You can use Array in this case: A = Array[a,{n,n}] Here is an example of an input and output: A = Array[a,{10,10}] // MatrixForm Caution: At first, I tried above command for an 100-by-100 matrix, then It took a few seconds to show the result and my computer became a little slow for a while. Please be careful. Note that you cannot use the capital "N" ...



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