4
$\begingroup$

I have five matrices and I want to represent one in the basis of other four. So how do I find the value of coefficients?

For example, if the matrices are I1, I2, I3, I4, T and the relation between them is

T = (a*I1) + (b*I2) + (c*I3) + (d*I4)

Now to determine the value of coefficients a, b, c, d, what do I have to do in Mathematica?

I have tried this

Solve[{T - a*I1 - b*I2 - c*I3 - d*I4 == 0}, {a, b, c, d}]

but it is showing this error:

Solve::svars: Equations may not give solutions for all "solve" variables.

$\endgroup$
  • $\begingroup$ Do you have a space between variable names? Anothe thing: dependent on the dimensions of your matrices you may have an overdetermined system. $\endgroup$ – Sjoerd C. de Vries Oct 3 '14 at 5:45
  • $\begingroup$ Not knowing anything about your matricies, what happens if you try this on your matricies: NMinimize[ Norm[Flatten[T] - (aFlatten[I1] + bFlatten[I2] + cFlatten[I3] + dFlatten[I4])], {a, b, c, d}, MaxIterations -> 10^4] When I try that on random Real 3x3 matricies I rapidly get very good approximations of the scalars I used to construct T from I1, I2, I3, I4. If this works for you then you can enhance this with additional precision if needed. $\endgroup$ – Bill Oct 3 '14 at 7:30
  • 1
    $\begingroup$ Please, reopen the question, I have an answer. It is a common task to decompose a matrix as a linear combination of basis matrices (e.g. the Pauli matrices). It can be a duplicate, not an unclear question. $\endgroup$ – ybeltukov Oct 3 '14 at 12:19
  • $\begingroup$ @ybeltukov I was thinking the same thing. Voting to re-open. $\endgroup$ – rcollyer Oct 3 '14 at 14:41
  • $\begingroup$ @ybeltukov Reopened on request. In the future you are welcome to flag a post ("other") if you have a good answer ready for a closed question. $\endgroup$ – Mr.Wizard Oct 3 '14 at 15:47
5
$\begingroup$

LinearSolve

If you have a proper dimensions I recommend you to use LinearSolve here. Let us take 4 random matrices as a basis (complex matrices for generality)

basis = RandomComplex[1 + I, {4, 2, 2}];
MatrixForm /@ basis

enter image description here

The target matrix

T = RandomReal[1, {2, 2}];
T // MatrixForm

enter image description here

We can treat 2x2 matrices as vectors with 4 elements, Flatten them and apply LinearSolve to find the coefficients

v = LinearSolve[Flatten[basis, {{2, 3}}], Flatten[T]]

enter image description here

Validation:

Norm[v.basis - T]

1.26609*10^-16

Dot

If your matrices are orthogonal to each other (as flattened vectors) you can simply use the matrix multiplication. An example with the Pauli matrices:

basis = PauliMatrix@Range[0, 3];
MatrixForm /@ basis

enter image description here

The flattened basis

fb = Flatten[basis, {{1}, {2, 3}}]

enter image description here

The basis is orthogonal (but not normalized)

fb.ConjugateTranspose[fb] // MatrixForm
nrm = Diagonal[fb.ConjugateTranspose[fb]];

enter image description here

Coefficients

v = Flatten[T].ConjugateTranspose[fb]/nrm

enter image description here

Validation

Norm[v.basis - T]

0.

$\endgroup$
0
$\begingroup$

You can also solve this for symbolic matrices.

If you want to decompose the matrix m={{a,b},{c,d}} into a sum over the Pauli Matrices you just need to define:

approx = Total@Table[v[i] PauliMatrix[i], {i, 0, 3}];
vars = Table[v[i], {i, 0, 3}];
m = {{a, b}, {c, d}};

The first line gives the sum of the basis matrices with the variable weights.

The seconde line is a fancy way to get all the variables together. Not really necessary in this small example, but useful for larger ones.

The last definition is the target matrix itself.

Now execute:

Solve[m - approx == 0, vars]

and you will get the values for all the 'v's.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.