Definition CS. Consistent System.
A system of linear equations is consistent if it has at least one solution. Otherwise, the system is called inconsistent.
.pivot()
to quickly and easily identify the pivot columns of the reduced row-echelon form of a matrix. Notice that we do not have to row-reduce the matrix first, we just ask which columns of a matrix xxxxxxxxxx
coeff = matrix(QQ, [[ 1, 4, 0, -1, 0, 7, -9],
[ 2, 8,-1, 3, 9, -13, 7],
[ 0, 0, 2, -3, -4, 12, -8],
[-1, -4, 2, 4, 8, -31, 37]])
const = vector(QQ, [3, 9, 1, 4])
aug = coeff.augment(const)
dependent = aug.pivots()
dependent
xxxxxxxxxx
free = [index for index in range(7) if not index in dependent]
free
[,]
) create a new list. The items in the list will be values of the variable index
. range(7)
is another list, integers starting at 0
and stopping just before 7
. (While perhaps a bit odd, this works very well when we consistently start counting at zero.) So range(7)
is the list [0,1,2,3,4,5,6]
. Think of these as candidate values for index
, which are generated by for index in range(7)
. Then we test each candidate, and keep it in the new list if it is not in the list dependent
.free
, index
, and dependent
, and we make the 0/1 counting adjustments. This ability to construct sets in Sage with notation so closely mirroring the mathematics is a powerful feature worth mastering. We will use it repeatedly.xxxxxxxxxx
free_and_easy = coeff.nonpivots()
free_and_easy
consistent()
function we designed above?.pivot()
to easily identify the pivot columns of a matrix. Let us use Archetype E as an example.xxxxxxxxxx
coeff = matrix(QQ, [[ 2, 1, 7, -7],
[-3, 4, -5, -6],
[ 1, 1, 4, -5]])
const = vector(QQ, [2, 3, 2])
aug = coeff.augment(const)
aug.rref()
xxxxxxxxxx
aug.pivots()
aug.pivots()
. Since aug
has 5 columns, the final column is numbered 4
, which is present in the list of pivot columns, as we expect.lambda
is the word that indicates we are making a new function, the input is temporarily named A
(think A
ugmented), and the name of the function is consistent
. Everything following the colon will be evaluated and reported back as the output.xxxxxxxxxx
consistent = lambda A: not(A.ncols()-1 in A.pivots())
consistent
function will be defined and available. Now give it a try (after making sure to have run the code above that defines aug
). Note that the output of consistent()
will be either True
or False
.xxxxxxxxxx
consistent(aug)
consistent()
command works by simply checking to see if the last column of A
is not in the list of pivots. We can now test many different augmented matrices, such as perhaps changing the vector of constants while keeping the coefficient matrix fixed. Again, make sure you execute the code above that defines coeff
and const
.xxxxxxxxxx
consistent(coeff.augment(const))
xxxxxxxxxx
w = vector(QQ, [3,1,2])
consistent(coeff.augment(w))
xxxxxxxxxx
u = vector(QQ, [1,3,1])
consistent(coeff.augment(u))
A.solve_right(b)
will provide information about solutions to the linear system of equations with coefficient matrix A
and vector of constants b
. The reason for the βrightβ (and the corresponding command named with βleftβ) will have to wait for Sage MVP. For now, it is generally correct in this course to use the βrightβ variant of any Sage linear algebra command that has both βleftβ and βrightβ variants..solve_right()
command to a system with no solutions, in particular Archetype E. We have already seen in Sage RCLS that this system is inconsistent.xxxxxxxxxx
coeff = matrix(QQ, [[ 2, 1, 7, -7],
[-3, 4, -5, -6],
[ 1, 1, 4, -5]])
const = vector(QQ, [2, 3, 2])
coeff.solve_right(const)
matrix equation has no solutions
. We can debate whether or not this is really an error, but that is the design decision taken in Sage β we just need to be aware of it, the .solve_right()
is really only valuable when there is a solution.._solve_right_general()
and then .solve_right()
. With time and practice, these mysterious messages will become more and more helpful, so spend some time reading them in tandem with locating the real source of any problems you encounter..solve_right()
do with a system that does have solutions? Let us take a look at Example ISSI again, as we did in Sage FDV.xxxxxxxxxx
coeff = matrix(QQ, [[ 1, 4, 0, -1, 0, 7, -9],
[ 2, 8, -1, 3, 9, -13, 7],
[ 0, 0, 2, -3, -4, 12, -8],
[-1, -4, 2, 4, 8, -31, 37]])
const = vector(QQ, [3, 9, 1, 4])
coeff.solve_right(const)