Lab 1, problem 1 for MW: Solving and exploring a system with Sage

edited August 2019 in Assignments

(10 pts)

This is where we'll report our answers to problem 1 of lab 1. The question itself deals with a randomly generated system of equations (personalized for each student) and you are asked to do the following:

  • Describe the the problem with prose and your initial typeset system.
  • Include the code you used to solve the problem as a code block.
  • Include the output of your command, also as a code block.
  • Describe your interpretation of the output.
  • Repeat the process for a modified, undetermined system obtained by removing two of the equations.

Comments

  • edited August 2019

    This system includes 5 rows/equations with 5 variables. I was asked to put the system into Sage solve and then remove 2 equations to see how the variables change.
    $$\begin{align}6x_{1} - 7x_{2} - 2x_{3} - 9x_{4} - 8x_{5} &= -1\\
    -5x_{1} + 9x_{2} - 4x_{3} + 5x_{4} + 6x_{5} &= 4\\
    -2x_{1} - 3x_{2} - 7x_{3} - 5x_{5} &= 8\\
    8x_{1} - 2x_{2} + x_{3} + 2x_{4} - 4x_{5} &= -6\\
    -6x_{1} - 2x_{2} - x_{3} - 5x_{5} &= -1\end{align}$$

    The initial code described the system:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        6*x1-7*x2-2*x3-9*x4-8*x5 == -1,
        -5*x1+9*x2-4*x3+5*x4+6*x5 == 9,
        -2*x1-3*x2-7*x3-5*x5 == 8,
        8*x1-2*x2+x3+2*x4-4*x5 == -6,
        -6*x1-2*x2-x3-5*x5 == -1
    ], [x1,x2,x3,x4,x5])
    

    Solution:

    [[x1 == (-520/3199), x2 == (-4825/22393), x3 == (-35212/22393), x4 == (-600/3199), x5 == (17819/22393)]]
    

    This system has a unique solution.

    Two rows deleted:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        -2*x1-3*x2-7*x3-5*x5 == 8,
        8*x1-2*x2+x3+2*x4-4*x5 == -6,
        -6*x1-2*x2-x3-5*x5 == -1
    ], [x1,x2,x3,x4,x5])
    

    Solution:

    [[x1 == -3/26*r1 - 11/91*r2 - 17/182, x2 == -30/13*r1 + 40/91*r2 + 155/91, x3 == 4/13*r1 - 2/13*r2 - 24/13, x4 == r2, x5 == r1]]
    

    With two rows deleted, the system cannot be described by one solution as it could with 5 rows. Instead, it is described in terms of a variables r1 and r2 equaling x4 and x5, respectively. This is due to the fact that there are more variables than there are equations in the system. This system would then have an infinite amount of solutions.

    mark
  • edited August 2019

    My problem has 5 variables: x1, x2, x3, x4 and x5. There are 5 equations. In this case (5 equations, 5 unknowns), there is a unique solution. My problem looked like this:
    $$
    \begin{align}-4x_{1} - 9x_{2} - 2x_{3} + 2x_{4} - 7x_{5} &= 1\\
    3x_{1} - 3x_{2} + 6x_{3} + 5x_{4} + x_{5} &= 8\\
    -2x_{1} + 3x_{2} + x_{3} - 7x_{4} &= -8\\
    -7x_{1} + 3x_{2} + 4x_{3} - 5x_{4} + 4x_{5} &= -6\\
    -7x_{1} + 6x_{2} - 9x_{3} + x_{4} - 6x_{5} &= 1\end{align}
    $$
    I used Sage to find this solution. My code looked like this:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        -4*x1-9*x2-2*x3+2*x4-7*x5 == 1,
        3*x1-3*x2+6*x3+5*x4+x5 == 8,
        -2*x1+3*x2+x3-7*x4 == -8,
        -7*x1+3*x2+4*x3-5*x4+4*x5 == -6,
        -7*x1+6*x2-9*x3+x4-6*x5 == 1
    ], [x1,x2,x3,x4,x5])
    

    Then I hit the "evaluate" button:

    [[x1 == (328/3579), x2 == (3455/10737), x3 == (492/1193), x4 == (1567/1193), x5 == 
    (-1258/3579)]]
    

    Thus my unique solution is (328/3579, 3455/10737, 492/1193, 1567/1193, -1258/3579).

    Then I removed the 2nd and 3rd equation in the system to obtain:
    $$
    \begin{align}-4x_{1} - 9x_{2} - 2x_{3} + 2x_{4} - 7x_{5} &= 1\\
    -7x_{1} + 3x_{2} + 4x_{3} - 5x_{4} + 4x_{5} &= -6\\
    -7x_{1} + 6x_{2} - 9x_{3} + x_{4} - 6x_{5} &= 1\end{align}
    $$
    My new code in Sage looked like this:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        -4*x1-9*x2-2*x3+2*x4-7*x5 == 1,
        -7*x1+3*x2+4*x3-5*x4+4*x5 == -6,
        -7*x1+6*x2-9*x3+x4-6*x5 == 1
    ], [x1,x2,x3,x4,x5])
    

    Then I hit the "evaluate" button:

    [[x1 == -11/71*r1 - 111/355*r2 + 159/355, x2 == -109/213*r1 + 262/1065*r2 - 193/1065, x3 == 
    -63/71*r1 + 184/355*r2 - 206/355, x4 == r2, x5 == r1]]
    

    The variables are written in terms of 2 other variables r1 and r2, so I suppose this means my new system has infinitely many solutions: ((-11/71)(r1) - (111/355)(r2) + (159/355), (-109/213)(r1) + (262/1065)(r2) - (193/1065), (-63/71)(r1) + (184/355)(r2) - (206/355), r2, r1). Since x4 and x5 are declared to be r2 and r1 respectively... and the solution is written in terms of these 2 new variables r2 and r1... x4 and x5 are free variables.

    mark
  • edited August 2019

    This system has 5 equations and 5 different variables. I was asked to solve this system after 2 equations had been removed so see how the variables were affected. The system is:

    $$
    \begin{align}-7x_{1} + 9x_{2} + 9x_{4} + 3x_{5} &= 4\\
    -6x_{1} + 5x_{2} + 7x_{4} - 8x_{5} &= 5\\
    8x_{1} - 5x_{2} + 5x_{3} - x_{4} + 6x_{5} &= 7\\
    -4x_{1} - 9x_{3} - 2x_{4} - 6x_{5} &= -9\\
    -2x_{1} - 2x_{2} + x_{3} + 6x_{4} + 9x_{5} &= 8\end{align}
    $$

    The code typed into sage to solve the system was:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
    -7*x1+9*x2+9*x4+3*x5 == 4,
    6*x1+5*x2+7*x4-8*x5 == 5,
    8*x1-5*x2+5*x3-x4+6*x5 == 7,
    -4*x1-9*x3-2*x4-6*x5 == -9,
    -2*x1-2*x2+x3+6*x4+9*x5 ==8
    ], [x1,x2,x3,x4,x5])
    

    The solution sage outputted was:

    [[x1 == (365/1153), x2 == (-1385/4612), x3 == (1165/2306), x4 == (4223/4612), x5 
    == (521/2306)]]
    

    This shows us that with 5 equations and 5 variables, we have 1 solution for each variable.
    To create the modified system of equations, I chose to remove the equations:

    $$
    \begin{align}-4x_{1} - 9x_{3} - 2x_{4} - 6x_{5} &= -9\\
    -2x_{1} - 2x_{2} + x_{3} + 6x_{4} + 9x_{5} &= 8\end{align}
    $$
    The code typed into sage to solve the modified system was:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
    -7*x1+9*x2+9*x4+3*x5 == 4,
    6*x1+5*x2+7*x4-8*x5 == 5,
    8*x1-5*x2+5*x3-x4+6*x5 == 7,
    
    ], [x1,x2,x3,x4,x5])
    

    The resulting solution to the equation was:

    [[x1 == 87/89*r1 - 18/89*r2 + 25/89, x2 == 38/89*r1 - 103/89*r2 + 59/89, x3 == 
    -208/89*r1 - 282/445*r2 + 718/445, x4 == r2, x5 == r1]]
    

    This output means that to know the exact values of all the variables, all of the given equations must be used. If any of the equations are left out, then the system will have infinitely many solutions.

    mark
  • edited August 2019

    Given the following problem:

    $$
    \begin{align}
    7x_{1} + 7x_{2} - 6x_{3} + 7x_{4} - 2x_{5} &= -6\\
    3x_{1} + 7x_{3} + 2x_{4} + 3x_{5} &= -4\\
    -9x_{1} + x_{2} + 2x_{4} + 6x_{5} &= -2\\
    7x_{1} + x_{2} - 4x_{3} - 8x_{4} + 5x_{5} &= -1\\
    x_{1} - 7x_{2} + 3x_{3} + 2x_{4} + x_{5} &= -7
    \end{align}
    $$

    My assignment was to use SageMath to calculate the result of this system of linear equations.

    The SageMath code is the following:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        7*x1+7*x2-6*x3+7*x4-2*x5==-6,
        3*x1+7*x3+2*x4+3*x5==-4,
        -9*x1+x2+2*x4+6*x5==-2,
        7*x1+x2-4*x3-8*x4+5*x5==-1,
        x1-7*x2+3*x3+2*x4+x5==-7
    ], [x1,x2,x3,x4,x5])
    

    The result of this execution is:

    $$
    \begin{align}
    x1 &= \frac {-41539} {79409}\\
    x2 &= \frac {51957}{79409}\\
    x3 &= \frac {25232}{79409}\\
    x4 &= \frac {-7030}{7219}\\
    x5 &= \frac {-71661}{79409}
    \end{align}
    $$

    Modifying the original linear equation by changing values on all the RHS of each equation:

    $$
    \begin{align}
    7x_{1} + 7x_{2} - 6x_{3} + 7x_{4} - 2x_{5} &= 100\\
    3x_{1} + 7x_{3} + 2x_{4} + 3x_{5} &= 444\\
    -9x_{1} + x_{2} + 2x_{4} + 6x_{5} &= 20\\
    7x_{1} + x_{2} - 4x_{3} - 8x_{4} + 5x_{5} &=111\\
    x_{1} - 7x_{2} + 3x_{3} + 2x_{4} + x_{5} &= -89
    \end{align}
    $$

    And changing the corresponding SageMath code:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
     solve([
         7*x1+7*x2-6*x3+7*x4-2*x5==100,
         3*x1+7*x3+2*x4+3*x5==444,
         -9*x1+x2+2*x4+6*x5==20,
         7*x1+x2-4*x3-8*x4+5*x5==111,
         x1-7*x2+3*x3+2*x4+x5==-89
    ], [x1,x2,x3,x4,x5])
    

    Yields another unique solution

    $$
    \begin{align}
    x1 &= \frac {1526901} {79409}\\
    x2 &= \frac {3044471}{79409}\\
    x3 &= \frac {3486994}{79409}\\
    x4 &= \frac {11366}{7219}\\
    x5 &= \frac {2005961}{79409}
    \end{align}
    $$

    Because I only changed the RHS and nothing on the LHS of the equations, it follows that the denominator of all results are the same.

    For the final step, I removed the last two equations in the system of linear equations:

    $$
    \begin{align}
    7x_{1} + 7x_{2} - 6x_{3} + 7x_{4} - 2x_{5} &= -6\\
    3x_{1} + 7x_{3} + 2x_{4} + 3x_{5} &= -4\\
    -9x_{1} + x_{2} + 2x_{4} + 6x_{5} &= -2
    \end{align}
    $$

    The SageMath code is as follows:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        7*x1+7*x2-6*x3+7*x4-2*x5==-6,
        3*x1+7*x3+2*x4+3*x5==-4,
        -9*x1+x2+2*x4+6*x5==-2,
    ], [x1,x2,x3,x4,x5])
    

    Because I removed the fifth equation, there is no unique solution to $x_4$ and $x_5$ so the result will have infinite solutions.

    $$
    \begin{align}
    x1 &= \frac {145} {254} * r1 +\frac{37}{508} * r2 + \frac{8}{127}\\
    x2 &= \frac {-219}{254} * r1 - \frac{683}{508} * r2 - \frac{182}{127}\\
    x3 &= \frac {-171}{254} * r1 - \frac{161}{508} * r2-\frac{76}{127}\\
    x4 &= r2\\
    x5 &= r1
    \end{align}
    $$

    Finally, I made the system of equations inconsistent by adding a last row of $0=1$.

    $$
    \begin{align}
    7x_{1} + 7x_{2} - 6x_{3} + 7x_{4} - 2x_{5} &= -6\\
    3x_{1} + 7x_{3} + 2x_{4} + 3x_{5} &= -4\\
    -9x_{1} + x_{2} + 2x_{4} + 6x_{5} &= -2\\
    7x_{1} + x_{2} - 4x_{3} - 8x_{4} + 5x_{5} &= -1\\
    x_{1} - 7x_{2} + 3x_{3} + 2x_{4} + x_{5} &= -7\\
    0&=1
    \end{align}
    $$

    The corresponding SageMath code:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        7*x1+7*x2-6*x3+7*x4-2*x5==-6,
        3*x1+7*x3+2*x4+3*x5==-4,
        -9*x1+x2+2*x4+6*x5==-2,
        7*x1+x2-4*x3-8*x4+5*x5==-1,
        x1-7*x2+3*x3+2*x4+x5==-7,
        0==1
    ], [x1,x2,x3,x4,x5])
    

    Because the system is inconsistent, SageMath shows an empty result:

    $$
    []
    $$

    mark
  • edited August 2019

    Problem 1: Use Sage's solve command to solve the following system.

    \begin{align}-5x_{1} + 5x_{2} + 2x_{3} + 8x_{4} - 8x_{5} &= 8\\
    -6x_{1} - 7x_{3} + 7x_{4} - 9x_{5} &= 0\\
    -4x_{1} - 7x_{2} + 6x_{3} + 8x_{4} - 4x_{5} &= -4\\
    -2x_{1} + 7x_{3} + 9x_{4} &= 3\\
    -5x_{1} + x_{2} - 6x_{3} + 6x_{5} &= 5\end{align}

    My Code:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    
    solve([
    -5*x1+5*x2+2*x3+8*x4-8*x5 == 8,
    -6*x1-7*x3+7*x4-9*x5 == 0,
    -4*x1-7*x2+6*x3+8*x4-4*x5 == -4,
    -2*x1+7*x3+9*x4 == 3,
    -5*x1+x2-6*x3+6*x5 == 5],
    [x1,x2,x3,x4,x5])
    

    Output from Sage:

    [[x1 == (-10477/10994), x2 == (24559/21988), x3 == (16183/43976), x4 == 
    (-7241/43976), x5 == (1215/5497)]]
    

    This output is what I was hoping for, a numerical solution for all five variables given five independent equations.

    Undetermined system code (top two equations removed):

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    
    solve([
    -4*x1-7*x2+6*x3+8*x4-4*x5 == -4,
    -2*x1+7*x3+9*x4 == 3,
    -5*x1+x2-6*x3+6*x5 == 5],
    [x1,x2,x3,x4,x5])
    

    Output from Sage:

    [[x1 == r2, x2 == -3/5*r1 - 11/38*r2 + 37/38, x3 == 9/10*r1 - 67/76*r2 - 51/76, 
    x4 == -7/10*r1 + 69/76*r2 + 65/76, x5 == r1]]
    

    This output includes new unknown variables r1 and r2 since we have a system with 5 unknowns and only three equations.

    mark
  • edited August 2019

    I was given the following system of equations and asked to solve it.

    $$\begin{align} 6x_{1} + 9x_{2} + 6x_{3} + 8x_{4} + 8x_{5} &= -8\\
    2x_{1} + 3x_{2} - 6x_{3} - 8x_{4} - 6x_{5} &= -1\\
    3x_{1} + 9x_{2} - 2x_{3} + 9x_{4} + 6x_{5} &= -1\\
    -7x_{2} - 6x_{3} - 3x_{4} - 7x_{5} &= -5\\
    9x_{1} - 7x_{2} + 6x_{3} + 8x_{4} + x_{5} &= -7\end{align}$$

    First I used the following code:

    x1,x2,x3,x4, x5 = var('x1,x2,x3,x4,x5')
    solve([
        6*x1+9*x2+6*x3+8*x4+8*x5 == -8,
        2*x1+3*x2-6*x3-8*x4-6*x5 == -1,
        3*x1+9*x2-2*x3+9*x4+6*x5 == -1,
        -7*x2-6*x3-3*x4-7*x5 == -5,
        9*x1-7*x2+6*x3+8*x4+x5 == -7,
    ], [x1,x2,x3,x4, x5])
    

    and the following output was produced:

    [[x1 == (499/58), x2 == (-663/58), x3 == (-7717/580), x4 == (-4143/290), x5 == (1721/58)]]
    

    This is the solution to the set of linear equations above, which is in fact a single solution! Easy to determine this, as there are no variables in the solution, only numbers.

    Then I was asked to delete two delete two equations from the problem and evaluate the change!

    So I used the following code:

    x1,x2,x3,x4, x5 = var('x1,x2,x3,x4,x5')
    solve([
        6*x1+9*x2+6*x3+8*x4+8*x5 == -8,
        2*x1+3*x2-6*x3-8*x4-6*x5 == -1,
        3*x1+9*x2-2*x3+9*x4+6*x5 == -1,
    ], [x1,x2,x3,x4, x5])
    

    Which produced this answer set:

    [[x1 == 20/9*r1 + 35/9*r2 - 16/9, x2 == -89/54*r1 - 70/27*r2 + 47/108, 
    x3 == -13/12*r1 - 4/3*r2 - 5/24, x4 == r2, x5 == r1]]
    

    This solution tells me that there are infinitely many solutions to the new system of linear equations of which $x_1$, $x_2$ and $x_3$ are all dependent on the values of the independent variables $x_4$ and $x_5$.

    mark
  • edited August 2019

    I was asked to solve the following system of equations from Lab 1 with Sage's solve command.

    $$\begin{align}3x_{2} + x_{3} - 7x_{4} + x_{5} &= -5\\
    x_{1} + 9x_{3} - 6x_{4} + 3x_{5} &= 3\\
    3x_{1} + 9x_{2} + 4x_{3} + x_{4} - 7x_{5} &= -4\\
    -x_{1} + 5x_{2} + 8x_{3} + 5x_{4} + x_{5} &= 3\\
    -7x_{1} + x_{2} - 8x_{3} - 7x_{4} - x_{5} &= 1\end{align}$$

    This is the code block I input to solve the above system:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        3*x2+x3-7*x4+x5 == -5,
        x1+9*x3-6*x4+3*x5 == 3,
        3*x1+9*x2+4*x3+x4-7*x5 == -4,
        -1*x1+5*x2+8*x3+5*x4+x5 == 3,
         -7*x1+x2-8*x3-7*x4-x5 == 1
    ], [x1,x2,x3,x4,x5])
    

    With an output of:

    [[x1 == (-2571/1768), x2 == (-1007/832), x3 == (6807/7072), x4 ==     (2627/14144), x5 == (-3647/3536)]]
    

    I interpret this as the unique solution set to this system of equations.

    I then made some slight adjustments to the above system by removing a few equations, adding an unknown, and changing some coefficients to create an undetermined system. This can be seen below:

    $$\begin{align}17x_{2} + x_{3} - 7x_{4} &= -1\\
    3x_{1} + 9x_{2} + 4x_{3} + x_{4} - 7x_{5} &= -4\\
    -7x_{1} + x_{2} - 8x_{3} - 7x_{4} - x_{5} + x_{6} &= 1\end{align}$$

    This is the code block I input to solve the above system:

    x1,x2,x3,x4,x5,x6 = var('x1,x2,x3,x4,x5,x6')
    solve([
        17*x2+x3-7*x4 == -1,
        3*x1+9*x2+4*x3+x4-7*x5 == -4,
        -7*x1+x2-8*x3-7*x4-x5+x6 == 1
    ], [x1,x2,x3,x4,x5,x6])
    

    ...And this is the result:

    [[x1 == 59/2*r1 - 509*r2 + 128*r3 + 413/2, x2 == 3/2*r1 - 26*r2 + 7*r3 + 21/2, x3 == -51/2*r1 + 442*r2 - 112*r3 - 359/2, x4 == r3, x5 == r2, x6 == r1]]
    

    Due to the fact that there are more unknowns than equations, the output defines variables as r3, r2, and r1 and solves the system in terms of those variables. This also means there are infinitely many solutions.

    mark
  • edited August 2019

    I was given the arduous task of using Sage to solve the following system of equations:

    $$\begin{align}-4x_{1} - 6x_{2} - 6x_{3} + 4x_{4} + 8x_{5} &= 6\\
    6x_{1} + 6x_{4} - 4x_{5} &= -4\\
    -6x_{1} + 3x_{2} - 5x_{3} - 3x_{4} - 9x_{5} &= 4\\
    -3x_{1} - x_{2} - 3x_{3} + 9x_{4} - x_{5} &= 6\\
    3x_{1} + 6x_{2} - 5x_{3} - 6x_{4} - 8x_{5} &= -2\end{align}$$

    The code to solve the system is as follows:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        -4*x1-6*x2-6*x3+4*x4+8*x5 == 6,
        6*x1+6*x4-4*x5 == -4,
        -6*x1+3*x2-5*x3-3*x4-9*x5 == 4,
        -3*x1-1*x2-3*x3+9*x4-x5 == 6,
        3*x1+6*x2-5*x3-6*x4-8*x5 == -2
    ], [x1,x2,x3,x4,x5])
    

    That code will give the output:

    [[x1 == (-1238/1539), x2 == (349/513), x3 == (-62/171), x4 == (610/1539), x5 == 
    (199/513)]]
    

    Which means the system has a unique solution, as follows:
    $$x_1= -1238/1539\\
    x_2= 349/513\\ x_3= -62/171\\ x_4= 610/1539\\ x_5= 199/513$$

    If you were to remove the last two equations from the original system, the resulting system is:
    $$\begin{align}-4x_{1} - 6x_{2} - 6x_{3} + 4x_{4} + 8x_{5} &= 6\\
    6x_{1} + 6x_{4} - 4x_{5} &= -4\\
    -6x_{1} + 3x_{2} - 5x_{3} - 3x_{4} - 9x_{5} &= 4\end{align}$$

    We can input the following code to solve said system:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        -4*x1-6*x2-6*x3+4*x4+8*x5 == 6,
        6*x1+6*x4-4*x5 == -4,
        -6*x1+3*x2-5*x3-3*x4-9*x5 == 4,
    ], [x1,x2,x3,x4,x5])
    

    The output of which is:

    [[x1 == 2/3*r1 - r2 - 2/3, x2 == 157/72*r1 + 11/24*r2 - 25/72, x3 == -31/24*r1 + 
    7/8*r2 - 5/24, x4 == r2, x5 == r1]]
    

    What this means is there are infinitely many solutions to the system, where the equations have been parameterized.

    mark
  • edited August 2019

    I was asked to find a solution to the system

    \begin{align}2x_{1} - 8x_{2} - 8x_{4} + 2x_{5} &= 0\\
    x_{1} - 6x_{2} - 9x_{3} + 3x_{4} - 9x_{5} &= -4\\
    -6x_{1} + 3x_{2} - 9x_{3} - 8x_{4} - 5x_{5} &= 7\\
    3x_{1} - 3x_{2} - 7x_{3} + 7x_{4} + 6x_{5} &= -5\\
    -x_{1} - 4x_{2} + 9x_{3} + 5x_{4} - 9x_{5} &= -9\end{align}

    The code I input into sage was

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        2*x1-8*x2-8*x4+2*x5 == 0,
        x1-6*x2-9*x3+3*x4-9*x5 == -4,
        -6*x1+3*x2-9*x3-8*x4-5*x5 == 7,
        3*x1-3*x2-7*x3+7*x4+6*x5 == -5,
        -x1-4*x2+9*x3+5*x4-9*x5 == -9
    ], [x1,x2,x3,x4,x5])
    

    which produced the result

    [[x1 == (34597/49388), x2 == (44371/49388), x3 == (-2671/12347), x4 == (-9272/12347), x5 == (-5465/49388)]]
    

    This output indicates that the single unique solution to the given system is

    \begin{align}x_{1} = \frac{34597}{49388}\\
    x_{2} = \frac{44371}{49388}\\
    x_{3} = \frac{-2671}{12347}\\
    x_{4} = \frac{-9272}{12347}\\
    x_{5} = \frac{-5465}{49388}\end{align}

    I was then asked to remove two of the equations and find the solution for the new modified undetermined system

    \begin{align}2x_{1} - 8x_{2} - 8x_{4} + 2x_{5} &= 0\\
    x_{1} - 6x_{2} - 9x_{3} + 3x_{4} - 9x_{5} &= -4\\
    -6x_{1} + 3x_{2} - 9x_{3} - 8x_{4} - 5x_{5} &= 7\end{align}

    The code I input into sage was

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        2*x1-8*x2-8*x4+2*x5 == 0,
        x1-6*x2-9*x3+3*x4-9*x5 == -4,
        -6*x1+3*x2-9*x3-8*x4-5*x5 == 7
    ], [x1,x2,x3,x4,x5])
    

    which produced the result

    [[x1 == 25/19*r1 - 80/19*r2 - 44/19, x2 == 11/19*r1 - 39/19*r2 - 11/19, x3 == -212/171*r1 + 211/171*r2 + 98/171, x4 == r2, x5 == r1]]
    

    This output indicates that the possible solutions to the given system are given by

    \begin{align}x_{1} = \frac{25}{19} * x_{5} - \frac{80}{19} * x_{4} - \frac{44}{19}\\
    x_{2} = \frac{11}{19} * x_{5} - \frac{39}{19} * x_{4} - \frac{11}{19}\\
    x_{3} = \frac{-212}{171} * x_{5} + \frac{211}{171} * x_{4} + \frac{98}{171}\\
    x_{4} = x_{4}\\
    x_{5} = x_{5}\end{align}

    mark
  • edited August 2019

    Given the following system of equations:
    $$
    \begin{align}9x_{1} - 2x_{2} + 8x_{3} + 4x_{4} + 3x_{5} &= 7\\
    6x_{1} + 5x_{2} - 5x_{3} + x_{4} - 9x_{5} &= -9\\
    5x_{1} + 4x_{2} - 8x_{3} + 4x_{4} - 3x_{5} &= -2\\
    -7x_{1} + 2x_{3} - 7x_{4} + 4x_{5} &= -1\\
    -7x_{1} + 2x_{2} + 7x_{3} - 5x_{4} + 6x_{5} &= 6\end{align}
    $$
    There are five equations and five unknowns. The resulting solutions are:

    x1 = -567/1766
    x2 = 3754/9713
    x3 = 4503/9713
    x4 = 21179/19426
    x5 = 16789/19426
    

    My interpretation of this result is that this is the only unique solution.

    My code looked like this

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
    9*x1-2*x2+8*x3+4*x4+3*x5 == 7,
    6*x1+5*x2-5*x3+x4-9*x5 == -9,
    5*x1+4*x2-8*x3+4*x4-3*x5 == -2,
    -7*x1+0*x2+2*x3-7*x4+4*x5 == -1,
    -7*x1+2*x2+7*x3-5*x4+6*x5 == 6
    ], [x1,x2,x3,x4,x5])
    

    Modifying the equation set by eliminating the bottom two equations creates an underdetermined system; 3 equations, 5 unknowns. The new equation set is:
    $$
    \begin{align}9x_{1} - 2x_{2} + 8x_{3} + 4x_{4} + 3x_{5} &= 7\\
    6x_{1} + 5x_{2} - 5x_{3} + x_{4} - 9x_{5} &= -9\\
    5x_{1} + 4x_{2} - 8x_{3} + 4x_{4} - 3x_{5} &= -2\end{align}
    $$

    The solutions to this problem set are as follows:

    x1 = -19/39*r1 - 92/117*r2 + 112/117
    x2 = 133/39*r1 + 176/117*r2 - 983/234
    x3 = 40/39*r1 + 89/117*r2 - 293/234
    x4 = r2
    x5 = r1
    

    My interpretation of this result is that there are infinitely many solutions.
    My code looked like this:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
    9*x1-2*x2+8*x3+4*x4+3*x5 == 7,
    6*x1+5*x2-5*x3+x4-9*x5 == -9,
    5*x1+4*x2-8*x3+4*x4-3*x5 == -2
    ], [x1,x2,x3,x4,x5])
    
    mark
  • edited August 2019

    I was given a system of equations containing five generic $x_{n}$ variables, where $n = 1-5$, and five equations, shown below:

    $$
    \begin{align}9x_{1} + 5x_{2} + x_{3} + 4x_{4} + x_{5} &= 3\\
    -6x_{1} + 6x_{2} + 8x_{3} + 6x_{4} - 9x_{5} &= -8\\
    -6x_{1} + 4x_{3} + 4x_{4} + 7x_{5} &= 3\\
    3x_{1} - 2x_{2} - 5x_{4} + 5x_{5} &= -3\\
    7x_{1} + 5x_{2} - 2x_{3} + 5x_{4} - 6x_{5} &= 7\end{align}
    $$

    I was asked to use Sage to find its solution set, so I input the following code:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        9*x1+5*x2+x3+4*x4+x5 == 3,
        -6*x1+6*x2+8*x3+6*x4-9*x5 == -8,
        -6*x1+4*x3+4*x4+7*x5 == 3,
        3*x1-2*x2-5*x4+5*x5 == -3,
        7*x1+5*x2-2*x3+5*x4-6*x5 == 7
    ], [x1,x2,x3,x4,x5])
    

    I clicked "evaluate" and Sage returned the following output:

    [[x1 == (-5605/1802), x2 == (7944/901), x3 == (-9881/1802), x4 == (-4469/1802), x5 == (2084/901)]]
    

    Thus, the solution set to this system of equations is:

    $$
    (x_{1}, x_{2}, x_{3}, x_{4}, x_{5}) = (\frac{-5605}{1802}, \frac{7944}{901}, \frac{-9881}{1802}, \frac{-4469}{1802}, \frac{2084}{901})
    $$

    Next, I removed the fourth and fifth equations, leaving me with the system of equations shown below:

    $$
    \begin{align}9x_{1} + 5x_{2} + x_{3} + 4x_{4} + x_{5} &= 3\\
    -6x_{1} + 6x_{2} + 8x_{3} + 6x_{4} - 9x_{5} &= -8\\
    -6x_{1} + 4x_{3} + 4x_{4} + 7x_{5} &= 3\end{align}
    $$

    I was asked used Sage to find its solution set, so I input the following code:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        9*x1+5*x2+x3+4*x4+x5 == 3,
        -6*x1+6*x2+8*x3+6*x4-9*x5 == -8,
        -6*x1+4*x3+4*x4+7*x5 == 3
    ], [x1,x2,x3,x4,x5])
    

    I clicked "evaluate" and Sage returned the following output:

    [[x1 == -221/66*r1 - 28/33*r2 + 167/66, x2 == 79/11*r1 + 13/11*r2 - 107/22, x3 == -149/22*r1 - 25/11*r2 + 50/11, x4 == r2, x5 == r1]]
    

    Thus, the solution set to this system of equations is:

    $$
    (x_{1}, x_{2}, x_{3}, x_{4}, x_{5}) = (\frac{-221}{66}x_{5} - \frac{28}{33}x_{4} + \frac{167}{66}, \frac{79}{11}x_{5} + \frac{13}{11}x_{4} - \frac{107}{22}, \frac{-149}{22}x_{5} - \frac{25}{11}x_{4} + \frac{50}{11}, x_{4}, x_{5})
    $$

    Variables $x_{4}$ and $x_{5}$ can be set to equal any real number, meaning that there are infinitely many solution sets for this system of equations.

    mark
  • My assignment was to use Sage to solve the following system:

    $$\begin{align}-x_{1} - 2x_{2} - 9x_{3} + 9x_{4} - 6x_{5} &= 0\\
    -7x_{1} - 3x_{2} - 2x_{3} - 7x_{4} - 7x_{5} &= 3\\
    -8x_{1} - 3x_{2} + 3x_{3} + 6x_{4} + 5x_{5} &= 5\\
    -x_{1} + 6x_{2} + 6x_{3} - 8x_{4} + 4x_{5} &= 5\\
    -6x_{1} + 3x_{4} &= 3\end{align}$$

    The code I typed to solve this system:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        -1*x1-2*x2-9*x3+9*x4-6*x5 == 0,
        -7*x1-3*x2-2*x3-7*x4-7*x5 == 3,
        -8*x1-3*x2+3*x3+6*x4+5*x5 == 5,
        -1*x1+6*x2+6*x3-8*x4+4*x5 == 5,
        -6*x1+3*x4 == 3   
    ], [x1,x2,x3,x4,x5])
    

    The Output:

    [[x1 == (-147/142), x2 == (69/284), x3 == (-361/142), x4 == (-76/71), x5 == 
    (653/284)]]
    

    The output shows that the system has one unique solution set.

    The edited code I typed removing two equations:

     x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
     solve([
        -1*x1-2*x2-9*x3+9*x4-6*x5 == 0,
        -7*x1-3*x2-2*x3-7*x4-7*x5 == 3,
        -8*x1-3*x2+3*x3+6*x4+5*x5 == 5,  
    ], [x1,x2,x3,x4,x5])
    

    The Output:

    [[x1 == -8*r1 - 63/4*r2 + 1/2, x2 == 19*r1 + 153/4*r2 - 5/2, x3 == -4*r1 - 
    23/4*r2 + 1/2, x4 == r2, x5 == r1]]
    

    The output shows that there are infinitely many solutions, and that all the variables are shown with the parameters r1 and r2.

    mark
  • edited August 2019

    I was given a system with 5 rows/equations and 5 variables. I was asked solve using Sage and then remove 2 equations to see what changes.
    My original system:
    $$\begin{align} - 5x_{2} + x_{3} - 4x_{4} + 6x_{5} &= -3\\
    5x_{1} + 6x_{2} + 6x_{3} + 9x_{4} - 5x_{5} &= 9\\
    7x_{1} + 7x_{2} + 6x_{3} - 3x_{5} &= 9\\
    7x_{1} - 7x_{2} + 3x_{3} + 9x_{4} + 4x_{5} &= 7\\
    -3x_{1} + x_{2} + 6x_{3} + x_{4} +7x_{5} &= -8\end{align}$$

    My code:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        -5*x2+x3-4*x4+6*x5 == -3,
        5*x1+6*x2+6*x3+9*x4-5*x5 == 9,
        7*x1+7*x2+6*x3-3*x5 == 9,
        7*x1-7*x2+3*x3+9*x4+4*x5 == 7
        -3*x1+x2+6*x3+x4+7*x5 == -8
    ], [x1,x2,x3,x4,x5])
    

    My results:

    [[x1 == 2066/5855*r1 + 4983/5855, x2 == 4327/5855*r1 + 2436/5855, x3 == 
    -4531/5855*r1 + 127/5855, x4 == 2241/5855*r1 + 1378/5855, x5 == r1]]
    

    This system has infinitely many solutions, given in terms of x5. I am a little skeptical of this result since every other student seems to have a unique solution to their initial system, and infinitely many solutions only when two of the equations are deleted. Or maybe I'm just special.

    I removed two of the equations as per instructions resulting in the following code:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        -5*x2+x3-4*x4+6*x5 == -3,
        5*x1+6*x2+6*x3+9*x4-5*x5 == 9,
        7*x1+7*x2+6*x3-3*x5 == 9,
    ], [x1,x2,x3,x4,x5])
    

    And the result:

    [[x1 == r2, x2 == 101/119*r1 - 37/119*r2 + 81/119, x3 == -25/51*r1 - 41/51*r2 + 
    12/17, x4 == 113/357*r1 + 67/357*r2 + 9/119, x5 == r1]]
    

    Infinitely many solutions again; this time, with two variables.

    mark
  • edited August 2019

    I was asked to solve the following system of linear equations using Sage:

    $$ \begin{align}2x_{1} + x_{2} - 4x_{3} + 3x_{4} - x_{5} &= -1\\
    -4x_{1} - 9x_{2} + 7x_{3} - 4x_{4} + x_{5} &= -5\\
    6x_{1} - 3x_{2} + 8x_{3} + 2x_{4} - 7x_{5} &= -3\\
    7x_{1} - 5x_{2} - 8x_{3} + 9x_{4} - 7x_{5} &= -2\\
    - 3x_{2} - 7x_{3} + 9x_{4} - x_{5} &= -6\end{align} $$

    The solution produced by the solve command in sage is as follows:

    x_{1} = -4297/1153, 
    x_{2} = 3311/2306, 
    x_{3} = -1423/1153, 
    x_{4} = -2001/1153, 
    x_{5} = -12193/2306   
    

    To get to this, I typed in this code:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        2*x1+x2-4*x3+3*x4-x5 == -1,
        -4*x1-9*x2+7*x3-4*x4+x5 == -5,
        6*x1-3*x2+8*x3+2*x4-7*x5 == -3,
        7*x1-5*x2-8*x3+9*x4-7*x5 == -2,
        -3*x2-7*x3+9*x4-1*x5 == -6
    ], [x1,x2,x3,x4,x5])
    

    This tells that there is a unique solution to the system.

    Next, I was asked to delete two equations from the system and solve:

    $$ \begin{align}2x_{1} + x_{2} - 4x_{3} + 3x_{4} - x_{5} &= -1\\
    -4x_{1} - 9x_{2} + 7x_{3} - 4x_{4} + x_{5} &= -5\\
    6x_{1} - 3x_{2} + 8x_{3} + 2x_{4} - 7x_{5} &= -3\end{align} $$

    The solution produced for this system is:

    x1 = 129/146*r1 - 227/292*r2 - 59/146, 
    x2 = -12/73*r1 + 33/146*r2 + 70/73, 
    x3 = 11/73*r1 + 61/146*r2 + 21/73, 
    x4 == r2, 
    x5 == r1
    

    To get to this solution I typed this code:

    x1,x2,x3,x4,x5 = var('x1,x2,x3,x4,x5')
    solve([
        2*x1+x2-4*x3+3*x4-x5 == -1,
        -4*x1-9*x2+7*x3-4*x4+x5 == -5,
        6*x1-3*x2+8*x3+2*x4-7*x5 == -3,
    ], [x1,x2,x3,x4,x5])
    

    This parameterized solution tells us that there are infinitely many solutions to the underdetermined system of equations.

    mark
Sign In or Register to comment.