Question: Is the LinearAlgebra command GenerateMatrix Improperly Sorting My Set of Equations?

I am using GenerateMatrix to construct a matrix out of a set of 6 equations with 6 variables.  The output of Generate Matrix is not sorted correctly.  Where am I going wrong? Is this a bug?

restart

NULL``

with(LinearAlgebra)

NULL

NULL

The command GenerateMatrix is not sorting my set of equations properly.

NULL

NULL

Define a set of 6 equations.

equation_set := [5964.000000-770.0000000*T__1+750.0000000*T__2 = 0, 20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0, 20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0, 20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0, 20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0, 5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0]

[5964.000000-770.0000000*T__1+750.0000000*T__2 = 0, 20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0, 20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0, 20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0, 20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0, 5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0]

(1)

NULL

NULL

NULL

This is what each one looks like individually.

equation_set[1]

5964.000000-770.0000000*T__1+750.0000000*T__2 = 0

(2)

equation_set[2]

20*T[1]-770.0000000*T[2]+750.0000000*T[3]+100.0000000 = 0

(3)

equation_set[3]

20*T[2]-770.0000000*T[3]+750.0000000*T[4]+100.0000000 = 0

(4)

equation_set[4]

20*T[3]-770.0000000*T[4]+750.0000000*T[5]+100.0000000 = 0

(5)

equation_set[5]

20*T[4]-770.0000000*T[5]+750.0000000*T[6]+100.0000000 = 0

(6)

equation_set[6]

5900.787944-770.0000000*T[6]+750.0000000*T[5] = 0

(7)

NULL

The variables used in the above set of equations.

variables_set := [T[1], T[2], T[3], T[4], T[5], T[6]]

[T[1], T[2], T[3], T[4], T[5], T[6]]

(8)

variables_set[1]

T[1]

(9)

A, b := GenerateMatrix(equation_set, variables_set)

Matrix(%id = 36893490238808803916), Vector[column](%id = 36893490238808803796)

(10)

This output seems wrong because a row of zeros appears in A``.  The first entry of the column vector contains the full equation. Thus, it seems GenerateMatrix didn't sort the set of equation properly.  I tried re-writing the  offending equation  as 5964.000000-770.0000000*T__1+750.0000000*T__2 = 0,but maple just changes it back on evaluation.NULL


 I think the output should look like:


A, b := Matrix(6, 6, {(1, 1) = -770.0000000, (1, 2) = 750.0000000, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 20, (2, 2) = -770.0000000, (2, 3) = 750.0000000, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = 20, (3, 3) = -770.0000000, (3, 4) = 750.0000000, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 20, (4, 4) = -770.0000000, (4, 5) = 750.0000000, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 20, (5, 5) = -770.0000000, (5, 6) = 750.0000000, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 750.0000000, (6, 6) = -770.0000000}), Vector(6, {(1) = -5964.000000, (2) = -100.0000000, (3) = -100.0000000, (4) = -100.0000000, (5) = -100.0000000, (6) = -5900.787944})

NULL

I rename the matrix and column vector and use LinearSolve to find a solution for T.

AA := Matrix(6, 6, {(1, 1) = -770.0000000, (1, 2) = 750.0000000, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (2, 1) = 20, (2, 2) = -770.0000000, (2, 3) = 750.0000000, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (3, 1) = 0, (3, 2) = 20, (3, 3) = -770.0000000, (3, 4) = 750.0000000, (3, 5) = 0, (3, 6) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 20, (4, 4) = -770.0000000, (4, 5) = 750.0000000, (4, 6) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 20, (5, 5) = -770.0000000, (5, 6) = 750.0000000, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 750.0000000, (6, 6) = -770.0000000})

Matrix(%id = 36893490238866723772)

(11)

``

bb := Vector(6, {(1) = -5964.000000, (2) = -100.0000000, (3) = -100.0000000, (4) = -100.0000000, (5) = -100.0000000, (6) = -5900.787944})

Vector[column](%id = 36893490238885708252)

(12)

NULL

NULL

T := LinearSolve(AA, bb)

Vector[column](%id = 36893490238857651132)

(13)

NULL

Download GenerateMatrix_Improper_Sorting.mw

Please Wait...