0
$\begingroup$

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?

Thanks for your help! Steffen

$\endgroup$
8
  • 2
    $\begingroup$ see LinearSolve in the docs. $\endgroup$
    – kglr
    May 21, 2019 at 11:13
  • $\begingroup$ This seems more an algebra problem than a Mathematica problem. Try the book of Lay $\endgroup$
    – JJBK
    May 21, 2019 at 11:17
  • $\begingroup$ e.g., m = {{a, b, c}, {b, d, e}, {c, e, f}}; LinearSolve[m, ConstantArray[1, Length@m]]? $\endgroup$
    – kglr
    May 21, 2019 at 11:27
  • $\begingroup$ 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? $\endgroup$
    – Steffen
    May 21, 2019 at 11:43
  • $\begingroup$ 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? $\endgroup$
    – Steffen
    May 21, 2019 at 11:51

1 Answer 1

1
$\begingroup$

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])}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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