Hot answers tagged

10

mat = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]/Sqrt[2]}; FixedPoint[ArrayFlatten, mat] // MatrixForm $\left( \begin{array}{cccccccc} 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & \...


8

mat = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]/ Sqrt[2]}; ArrayFlatten[ArrayFlatten /@ mat] // MatrixForm $\left( \begin{array}{cccccccc} 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 &...


8

First we run the original with an example (which should have been in the post). Mmax = 400; W = 1024; deltaX = .1; SeedRandom[1111]; lambdaMatrix = RandomReal[1, {W, W}]; lPoly = Developer`ToPackedArray[RandomReal[{-10, 10}, {Mmax + 1, W}]]; AbsoluteTiming[ res = MomentComputing[Mmax, 5, lambdaMatrix, lPoly, lPoly];] (* Out[52]= {12.1522, Null} *) What I ...


7

How to find the eigenvalue of this abstract matrix (reference answer: -2,-2,1). I am assuming $A^2$ means $A*A$? If so, then may be e = IdentityMatrix[3]; a = {{a11, a21, a31}, {a21, a22, a32}, {a31, a32, a33}}(*abstract symmetric matrix*) eqs = Thread[Flatten[a.a + a] == Flatten[2*e]]; sol = FindInstance[eqs, Flatten[a]]; Eigenvalues[a /. sol]


7

X = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]/Sqrt[2]}; Flatten[X, {{1, 3, 5}, {2, 4, 6}}] (* {{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1/Sqrt[2], 0, 0, 0, 0}} *)


6

This suggests minimal polynomial of $A$ is $x^2+x-2$. This has roots -2,1 (the eigenvalues not counting multiplicities). Note $m(A)$ divides $p(A)$ (the characteristic polynomial, which by Cayley-Hamilton $p(A)=0$) (-2,-2,1) or (-2,1,1) could be eigenvalues of $A$: e.g. using diagonal matrices. This also case when examine other instances from @Nasser code. ...


5

Your specific example can be solve with a general $P$, see code below. (*Data*) A = {{-2, -2, 1}, {2, x, -2}, {0, 0, -2}}; B = {{2, 1, 0}, {0, -1, 0}, {0, 0, y}}; (*Search for x and y based on characteristic polynomial*) n = Length@A; Id = IdentityMatrix@n; solxy = SolveAlways[Det[A - l*Id] == Det[B - l*Id], l] (*Update data*) A = A /. solxy[[1]]; B = B /. ...


5

One of many ways: mat = Normal@ SparseArray[{Band[{1, 1}] -> 1, Band[{1, 2}] -> -1/2, Band[{2, 1}] -> -1/2}, {10, 10}]; mat // MatrixForm The Normal@ is not really necessary.


5

Recommend that you look at Array Clear["Global`*"] genMat[n_Integer?Positive, f_] := Array[f, {n, n}] genMat[4, f] (* {{f[1, 1], f[1, 2], f[1, 3], f[1, 4]}, {f[2, 1], f[2, 2], f[2, 3], f[2, 4]}, {f[3, 1], f[3, 2], f[3, 3], f[3, 4]}, {f[4, 1], f[4, 2], f[4, 3], f[4, 4]}} *) genMat[4, Times] (* {{1, 2, 3, 4}, {2, 4, 6, 8}, {3, 6, 9, 12}, {...


5

Another option (m = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]}/Sqrt[2]) // MatrixForm And now m1 = ArrayFlatten[m[[1, 1]], 2] m2 = ArrayFlatten[m[[1, 2]], 2] Join[m1, m2, 2] // MatrixForm


4

After a second thought I notice it's not that hard to implement: ClearAll[myD, δ] myD[x_[k_, l_], x_[β_, α_]] := δ[k, β] δ[l, α] - δ[k, α] δ[l, β] myD[a_ b_, c_] := a myD[b, c] + b myD[a, c] SetAttributes[δ, Orderless] δ /: δ[a_, b_] h_[former___, b_, latter___] := h[former, a, latter] δ[a_, a_] = \[FormalCapitalD]; The following rule isn't necessary but ...


4

Clear["Global`*"] A[n_Integer?Positive] := DiagonalMatrix[Table[1, n]] + DiagonalMatrix[Table[-1/2, n - 1], 1, n] + DiagonalMatrix[Table[-1/2, n - 1], -1, n]; A[5] // MatrixForm


4

There are only seven (six unique) solutions up to row/column sums of $10^8$ (of course there are 1152 equivalent squares by permutation/transposition for each one): $$ \left( \begin{array}{cccc} 2 & 16 & 108 & 180 \\ 24 & 192 & 9 & 15 \\ 144 & 18 & 150 & 90 \\ 160 & 20 & 135 & 81 \\ \end{array} \right),\...


3

Assuming you have definitions already for n, single argument t[x], and two-argument t[x,y], then this is fairly straightforward: g[i_, n_] := Table[(t[i + 1] - t[j, i])/h[i] KroneckerDelta[k, i] + (t[j, i] - t[i])/h[i] KroneckerDelta[k, i + 1] - 1/6 (t[j, i] - t[i]) (t[i + 1] - t[j, i]) (1 + (t[i + 1] - t[j, i])/h[i]) KroneckerDelta[k, ...


3

It looks like RowReduce and MatrixRank implicitly assume that a does not have a particular value that reduces the rank of the matrix. They can detect that matrix A is degenerate for any value of a, but not that B is degenerate for a == 2. I think you might be able to get around this with SingularValueList, which seems to handle the problem better: Assuming[a ...


3

The simplest way to do that is to use: EV = FullSimplify[Table[Eigenvalues[J /. f], {f, FP}]]


3

This will do it: Reverse /@ Partition[Range[0, 999], 10, 1] {{9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, ... {999, 998, 997, 996, 995, 994, 993, 992, 991, 990}} Replace Range[0, 999] by your x.


2

First, don't use N as symbol, it's predfined in Mathematica Try Reduce to solve the problem expr = (n* k*(\[Beta]1*(1 - q) + \[Beta]2* q)) - ((k + \[Mu])*(\[Gamma]1 + \[Mu])*(\[Gamma]2 + \[Mu]) -\[Beta]2*n*k*q*(\[Gamma]1 + \[Mu]) - \[Beta]1*n*k*(1 - q)*(\[Gamma]2 + \[Mu])) ; var = Variables[expr]; Reduce[Join[{expr > 0}, Map[# > 0 &, var]]] //...


2

You do not need to iterate manually. First use ReplaceAll to substitute all eight solutions contained in FP, which will give you a list of 8 J expressions. Then Map the Eigenvalues function over the list: this will apply Eigenvalues to each element of the list of Js in turn, to give you the eight results, one for each solution from FP: Eigenvalues /@ (J /. ...


2

All credit to @Roman who deserves the accept for discovering 7095816 was the target number. With this number pinned down I tried to solve this myself with Mathematica, but it was still too slow: variables = Array[x, 16]; matrix = ArrayReshape[variables, {4, 4}]; target = 7095816; uniqueConstraint = (And @@ (Unequal @@@ Subsets[variables, {2}])); ...


2

Is this a formula with the Einstein sum convention. If so then the summation over two same indices has to be carried through. g[i_, j_, k_, n_] := Sum[(t[i + 1] - t[j, i])/h[ii] KroneckerDelta[k, ii] + (t[j, i] - t[ii])/h[ii] KroneckerDelta[k, ii + 1] - 1/6 (t[j, i] - t[ii]) (t[ii + 1] - t[j, i]) (1 + (t[ii + 1] - t[j, i])/h[ii]) ...


2

This seems to be a hasty start into Mathematica. Your inputs are right but used without insight. Use B = {{k1 + h, -k1, 0}, {-k1,h + k1´ + k2, -k2´}, {0, -k2, h + k2´}}; C0 = {{CA0}, {CB0}, {CC0}}; C1[t_] = h.(IdentityMatrix - Exp[-Bt])(B^-1)*C0; C2[t_] = {CA2[t], CB2[t], CC2[t]}; B// MatrixForm C0 // MatrixForm C1[t] // MatrixForm C2[t] // MatrixForm This ...


2

Works fine for me: a = {{1, -1, 0, 0}, {-1, 1, -1, 0}, {0, -1, 1, -1}, {0, 0, -1, -1}}; {Da, Sa} = Eigensystem[a]; Inverse[Transpose[Sa]].a.Transpose[Sa] == DiagonalMatrix[Da] // FullSimplify (* True *) Transpose[Sa].DiagonalMatrix[Da].Inverse[Transpose[Sa]] == a // FullSimplify (* True *)


1

I am not sure if I have got your attention properly, but you can see if code below works for you or not, matM = Module[{block, n = 4, jup = 10}, block[i_, j_] := Which[i == j, Cos[i], Abs[i - j] == 1, Sin[Min[i, j]], True, 0 ] IdentityMatrix[n]; SparseArray @ ArrayFlatten[Table[block[i, j], {i, 0, jup}, {j, 0, jup}]] ]


1

The special linear group is defined by In words: SL(2,ℤ) is the group of 2 × 2 real matrices with determinant one. SL(2,ℤ) = {A ∈ Z2×2 : Det(A) = 1} In representation theory: SL(2,ℤ) is a real, non-compact simple Lie group, with the Lie-Algebra of the Tr-free {\displaystyle 2\times 2}2\times 2-Matrices. A vector space bass of this 3-dimensional vector is ...


1

Not too hard to do, if you recall that one can use a rotation matrix to perform the required orthogonal similarity transformation: {{{a, 2}, {2, b}}, TrigExpand[RotationMatrix[2 ArcTan[u]]]} /. Solve[With[{rot = TrigExpand[RotationMatrix[2 ArcTan[u]]]}, Flatten[Thread /@ Thread[rot.{{a, 2}, {2, b}}.Transpose[rot] == ...


1

This script can be applied when the same elements are in the same row. A = {{1, 2, 3, 5}, {4, 5, 6, 8}, {7, 8, 9, 3}, {3, 56, 8, 2}, {4, 5, 6, 8}}; B = {{6, 7, 9, 1}, {2, 5, 0, 8}, {1, 2, 3, 7}, {34, 56, 78, 56}}; l = Length /@ {A, B} // Min (* 4 *) truefalse = MapThread[Equal, {A[[;; l, 2]], B[[;; l, 2]]}] (* {False, True, False, True} *) index = Pick[...


1

Another possibility using FeynCalc 9.3 or above (could be interesting for particle physicists) CLC[i, j, k] CSI[j].CSI[k] // PauliSimplify[#, PauliReduce -> True] & // FCE 2 I CSI[i] CSI[i].CSI[i] // PauliSimplify // FCE 3 CSI is a shortcut for a Cartesian Pauli sigma matrix, while CLC denotes a Cartesian Levi-Civita tensor. PauliSimplify handles ...


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