1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to change the expression of the result of function `LinearSolve`

Discussion in 'Mathematics' started by Ordinary users68, Aug 1, 2020 at 8:03 PM.

  1. I want to solve the following linear equations:

    $$\left\{\begin{aligned} x_{1}+3 x_{2}+x_{3} &=0 \\ 2 x_{1}+6 x_{2}+3 x_{3}-2 x_{4} &=0 \\ -2 x_{1}-6 x_{2}-4 x_{4} &=0 \end{aligned}\right.$$

    The form of the solution given in the textbook is as follows:

    $$\boldsymbol{X}=\left(\begin{array}{c} x_{1} \\ x_{2} \\ x_{3} \\ x_{4} \end{array}\right)=\left(\begin{array}{rr} -3 k_{1}-2 k_{2} \\ k_{1} & 2 k_{2} \\ k_{2} \end{array}\right)=k_{1}\left(\begin{array}{r} -3 \\ 1 \\ 0 \\ 0 \end{array}\right)+k_{2}\left(\begin{array}{r} -2 \\ 0 \\ 2 \\ 1 \end{array}\right), \quad k_{1}, k_{2} \text { are arbitrary constants }$$

    Solve[{x1 + 3 x2 + x3 == 0,
    2 x1 + 6 x2 + 3 x3 - 2 x4 == 0, -2 x1 - 6 x2 - 4 x4 == 0}, {x1, x2,
    x3, x4}]
    LinearSolve[{{1, 3, 1, 0}, {2, 6, 3, -2}, {-2, -6, 0, -4}}, {0, 0, 0}]
    NullSpace[{{1, 3, 1, 0}, {2, 6, 3, -2}, {-2, -6, 0, -4}}]


    $$\left\{\begin{aligned} x_{1}+x_{2}-2 x_{3}-x_{4}=& 4 \\ 3 x_{1}-2 x_{2}-x_{3}+2 x_{4}=& 2 \\ 5 x_{2}+7 x_{3}+3 x_{4}=-2 \\ 2 x_{1}-3 x_{2}-5 x_{3}-x_{4}=& 4 \end{aligned}\right.$$

    The form of the solution given in the textbook is as follows:

    $$\boldsymbol{X}=\left(\begin{array}{c} x_{1} \\ x_{2} \\ x_{3} \\ x_{4} \end{array}\right)=\left(\begin{array}{r} 1 \\ 1 \\ -1 \\ 0 \end{array}\right)+k\left(\begin{array}{r} -\frac{2}{3} \\ \frac{1}{3} \\ -\frac{2}{3} \\ 1 \end{array}\right)=\left(\begin{array}{r} 1 \\ 1 \\ -1 \\ 0 \end{array}\right)+k_{1}\left(\begin{array}{r} -2 \\ 1 \\ -2 \\ 3 \end{array}\right), \quad k, k_{1} \text { are arbitrary constants }$$

    Solve[{{1, 1, -2, -1}, {3, -2, -1, 2}, {0, 5, 7,
    3}, {2, -3, -5, -1}}.{x1, x2, x3, x4} == {4, 2, -2, 4}, {x1, x2,
    x3, x4}]
    LinearSolve[{{1, 1, -2, -1}, {3, -2, -1, 2}, {0, 5, 7,
    3}, {2, -3, -5, -1}}, {4, 2, -2, 4}]
    NullSpace[{{1, 1, -2, -1}, {3, -2, -1, 2}, {0, 5, 7,
    3}, {2, -3, -5, -1}}]


    But the solution form of the above code output is not the style of the textbook. How can we make the LinearSolve function output consistent with the result form of the textbook (arbitrary constant can be replaced by c)?

    In addition, I have another problem. To prove that two linear equations have the same solution, we need the row vectors of their augmented matrices to be equivalent to each other.

    For example, to prove that the linear equations represented by the following two matrices have the same system of solutions, I need to remove the meaningless zero row vector at the end:

    RowReduce[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}]
    RowReduce[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {2, 4, 6}}]


    I wonder if there's any more clever way to get rid of the meaningless zero row vector at the end of a matrix:

    Select[RowReduce[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {2, 4,
    6}}], # 0 != # &]


    [​IMG]

    By the way, it's inconvenient to customize the display size of the inserted images.

    Login To add answer/comment
     

Share This Page