# Factor vector out of a matrix

I am wondering how to factor a[1],a[2],...,a[4] out of sim so that I can write sim as the form of a matrix times column vector a. (a[1],a[2],...,a[4] are the component of vector a) ?

My ultimate goal is to compute the Omega when the determinant of the matrix is zero.

Nmax = 4;
x[0][t] = 0;
x[Nmax + 1][t] = 0;

T = 1/2 Sum[m[i] x[i]'[t]^2, {i, 1, Nmax}];
U = 1/2 Sum[k[i] (x[i][t] - x[i - 1][t])^2, {i, 1, Nmax + 1}];

L = T - U;

EL[q_] := D[L, q] - D[D[L, D[q, t]], t]

eigen = Table[EL[x[i][t]], {i, 1, Nmax}] // MatrixForm;

x[i_][t_] = a[i] E^(I \[Omega] t);

sim = eigen /. t -> 0


-
@b.gatessucks And then? –  Lawerance May 17 '14 at 7:49

## 1 Answer

Because of the linear relationship, you can simply get the desired matrix by calculating the Jacobian, as follows:

matrix = D[sim, {Array[a, Nmax]}];


The Jacobi matrix is by definition the linear approximation to a (differentiable) multivariate function. Here, the variables a[1]...a[4] are therefore used as the independent variables. It's important to have these variables as a list of the form {{a[1]... a[4]}} (two List levels) to get the derivatives arranged in the form of a matrix the way it has to be for the Jacobian. See also the question How to make Jacobian automatically in Mathematica.

What follows is just the verification that the result is correct:

Simplify[matrix.Array[a, Nmax] == sim]

(* ==> True *)

MatrixForm[matrix]


-
Thanks! It works! But I'm still confused about the math behind the method you used here. Can you tell me which exactly part of knowledge it is or just direct me to a math page that illustrate this method? –  Lawerance May 17 '14 at 18:40
And it seems unnecessary for the second line code Simplify[matrix.Array[a, Nmax] == sim] to be here, because I take it out and I can still get the desired matrix. What's the point of putting it here? –  Lawerance May 17 '14 at 18:49
@Lawerance I added a link for you. The Simplify line is there to prove to you that the task has been accomplished. Only the first line is needed. –  Jens May 17 '14 at 18:52
Thanks so much! –  Lawerance May 17 '14 at 19:02