Hot answers tagged

6

Everything you want in the question can be done by defining the derivative of the Norm: Derivative[1][Norm][z_] := z/Norm[z] D[Norm[x - y], {x}] (* ==> (x - y)/Norm[x - y] *) Simplify[D[Norm[x - y], {y}]] (* ==> (-x + y)/Norm[x - y] *) Here, the syntax I used for the derivatives is such that it would remain valid if x or y were replaced by vectors ...


5

mat[x_?NumberQ] := {{x^2, 1, 0}, {1, x^2, -1}, {0, -1, x}} ei[x_] := Eigensystem[mat[x], 1, Method -> {"Arnoldi", "Criteria" -> "RealPart"}][[1, 1]] NIntegrate[ei[x], {x, 0, 4}] (* 8. *)


5

You need PseudoInverse: mat = {{0, 1, 1}, {0, 2, 4}, {0, 3, 9}}; PseudoInverse[mat].{{45}, {130}, {255}} {{0}, {25}, {20}} or, LeastSquares (thanks: J.M.) LeastSquares[mat, {{45}, {130}, {255}}] {{0}, {25}, {20}}


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] // ...


2

To some extent (and with some care) this can be done with FeynCalc. At least I used it several times when I needed to compute gradients and divergences of Cartesian vectors. The trick is to work with D-dimensional 4-vectors and take the limit $D \to 3$ at the end. Since FeynCalc doesn't distinguish between upper and lower indices, the results are the same as ...


2

The most I've managed to improve the speed is about a factor of 2, but I thought I would share my attempt anyhow. First, let's just compute the identity matrix once, instead of once each iteration step: id = SparseArray[IdentityMatrix[2n]]; Second, since we are going to need all the powers of both A1 and A2, we can gain some speed by simply bumping the ...


2

ClearAll[a, b, c] data = {0.647888, 0.522495, 0.454224, 0.417054, 0.396816, 0.385798, 0.379799, 0.376532, 0.374754, 0.373786, 0.373259, 0.372972}; nlm = NonlinearModelFit[data, a + b/ c^x, {a, b, c}, x]; Normal@nlm $0.372629\, +0.505569 \,\, 1.8367^{-x}$ Limit[Normal[nlm], x -> Infinity] 0.372629


2

For reference, here is how to generate a modular $\mathbf L\mathbf D\mathbf U$ decomposition, as suggested by Daniel in the comments: mat = {{1, 0, 2}, {2, 1, 3}, {2, 1, 2}}; m = 5; {lu, piv, cond} = LUDecomposition[mat, Modulus -> m]; l = LowerTriangularize[lu, -1] + IdentityMatrix[Length[lu]]; d = DiagonalMatrix[Diagonal[lu]]; u = Mod[DiagonalMatrix[...


2

For completeness, here is a way with the LieART` package. (By the way, I usually write $DefaultOutputForm=StandardForm; before loading the package, as it otherwise messes up with my preferred output form.) << LieART` Irrep[SU[3]][10] Irrep[SU[3]][27] This gives the (TraditionalForm) output $\boldsymbol{8+10+\overline{10}+27+35+\overline{35}+64+81}$....


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

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