# Solve Set of Linear Equations (Analytic)

I have at a hand a set of linear equations of the form

M*x=y (matrix form) M_ij * x_j = y_i where i = 1,...,N (in components)

where M is symmetric, and all its elements are positive. Further, all of y's elements equal 1.

I need the solution vector x as a function of M in the general case where N is some integer. I was hoping that calculating the inverse of M is avoidable due to the properties of M and y.

Is there a function in Mathematica to which I can explain this problem? Or does somebody here even see the solution?

• see LinearSolve in the docs.
– kglr
Commented May 21, 2019 at 11:13
• This seems more an algebra problem than a Mathematica problem. Try the book of Lay
– JJBK
Commented May 21, 2019 at 11:17
• e.g., m = {{a, b, c}, {b, d, e}, {c, e, f}}; LinearSolve[m, ConstantArray[1, Length@m]]?
– kglr
Commented May 21, 2019 at 11:27
• You're right, of course. I realize this is an algebra problem, and was hoping that Mathematica might help solve it. I'm not aware of Mathematica functions to which I can explain a "general" symmetric matrix M of arbitrary size though. Is anyone? Commented May 21, 2019 at 11:43
• Thanks! Now, I don't need the solution for a particular size or entries of the matrix, but for a general symmetric NxN-matrix. Can this be fed to LinearSolve? Commented May 21, 2019 at 11:51

an $$n\times n$$ symmetric matrix $$M$$:

M[n_Integer?Positive] := Array[m @@ Sort[{##}] &, {n, n}]


an $$\vec{y}$$-vector with only 1-elements:

y[n_Integer?Positive] := ConstantArray[1, n]


find the solution for any $$n$$:

x[n_Integer?Positive] := LinearSolve[M[n], y[n]]


test:

x[1]


{1/m[1, 1]}

x[2]


{(-m[1, 2] + m[2, 2])/(-m[1, 2]^2 + m[1, 1] m[2, 2]), ( m[1, 1] - m[1, 2])/(-m[1, 2]^2 + m[1, 1] m[2, 2])}

x[3]


{( m[1, 3] m[2, 2] - m[1, 2] m[2, 3] - m[1, 3] m[2, 3] + m[2, 3]^2 + m[1, 2] m[3, 3] - m[2, 2] m[3, 3])/( m[1, 3]^2 m[2, 2] - 2 m[1, 2] m[1, 3] m[2, 3] + m[1, 1] m[2, 3]^2 + m[1, 2]^2 m[3, 3] - m[1, 1] m[2, 2] m[3, 3]), ( m[1, 2] m[1, 3] - m[1, 3]^2 - m[1, 1] m[2, 3] + m[1, 3] m[2, 3] + m[1, 1] m[3, 3] - m[1, 2] m[3, 3])/(-m[1, 3]^2 m[2, 2] + 2 m[1, 2] m[1, 3] m[2, 3] - m[1, 1] m[2, 3]^2 - m[1, 2]^2 m[3, 3] + m[1, 1] m[2, 2] m[3, 3]), ( m[1, 2]^2 - m[1, 2] m[1, 3] - m[1, 1] m[2, 2] + m[1, 3] m[2, 2] + m[1, 1] m[2, 3] - m[1, 2] m[2, 3])/( m[1, 3]^2 m[2, 2] - 2 m[1, 2] m[1, 3] m[2, 3] + m[1, 1] m[2, 3]^2 + m[1, 2]^2 m[3, 3] - m[1, 1] m[2, 2] m[3, 3])}

Notice that all the elements of the solution have the common denominator Det[M[n]]: we can simplify the solutions to, for example,

x[3]*Det[M[3]] // FullSimplify


{(m[1, 2] - m[2, 3]) m[2, 3] + m[1, 3] (-m[2, 2] + m[2, 3]) + (-m[1, 2] + m[2, 2]) m[3, 3], m[1, 3] (m[1, 2] - m[1, 3] + m[2, 3]) - m[1, 2] m[3, 3] + m[1, 1] (-m[2, 3] + m[3, 3]), -m[1, 2]^2 - m[1, 3] m[2, 2] + m[1, 1] (m[2, 2] - m[2, 3]) + m[1, 2] (m[1, 3] + m[2, 3])}