Løsning af lineære ligningssystemer i maple 

Vi indlæser først pakken LinearAlgebra  

> restart:with(LinearAlgebra):
 

Vi skal løse lineære ligningssystemer ved brug af kommandoerne GaussianElimination , ReducedRowEchelonForm , LinearSolve , som alle hører under pakken LinearAlgebra. 

Disse kommandoer tager alle matricer som input. GaussianElimination reducerer matricen til en trappematrix.  ReducedRowEchelonForm reducerer inputmatricen til den reducerede trappematrix.  LinearSolve giver løsningsmængden til det lineære ligningssystem der har input matricen som totalmatrix. I tilfældet med 2 eller 3 variable kan vi også plotte linier og grafer og vise det geometriske aspekt af ligningssystemerne. Det gør vi ved brug af kommandoen Student[LinearAlgebra][LinearSystemPlot] . 

Et eksempel med præcis en løsning 

Vi betragter det lineære ligningssystem 

> x[1]+x[2]+x[3]=2;x[1]+2*x[2]+3*x[3]=3;3*x[1]+2*x[2]+2*x[3]=0;
 

 

 

`+`(x[1], x[2], x[3]) = 2
`+`(x[1], `*`(2, `*`(x[2])), `*`(3, `*`(x[3]))) = 3
`+`(`*`(3, `*`(x[1])), `*`(2, `*`(x[2])), `*`(2, `*`(x[3]))) = 0 (1.1)
 

Det har totalmatricen 

> C1:=<<1 |1 | 1 | 2>, <1 | 2 | 3 | 3 >, <3 | 2 | 2 | 0>>;
 

Matrix(%id = 4320501800) (1.2)
 

Vi finder 

> GaussianElimination(C1);
 

Matrix(%id = 4321659728) (1.3)
 

Man ser at ligningssystemet har præcis en løsning, men det kræver stadig lidt regning at finde den.  

> ReducedRowEchelonForm(C1);
 

Matrix(%id = 4321755200) (1.4)
 

Heraf kan vi med det samme aflæse løsningen: x[1] = -4,x[2] = 11, x[3] = -5. Det finder man også med 

> LinearSolve(C1);
 

Vector[column](%id = 4322073136) (1.5)
 

Løsninger er skæringspunktet af tre planer 

> Student[LinearAlgebra][LinearSystemPlot](C1);
 

Plot
 

 

Et eksempel uden løsninger 

> x[1]+x[2]+x[3]=1;2*x[1]+x[2]+3*x[3]=1;2*x[1]+3*x[2]+x[3]=1;
 

 

 

`+`(x[1], x[2], x[3]) = 1
`+`(`*`(2, `*`(x[1])), x[2], `*`(3, `*`(x[3]))) = 1
`+`(`*`(2, `*`(x[1])), `*`(3, `*`(x[2])), x[3]) = 1 (2.1)
 

> C2:=<<1 |1 | 1 | 1>, <2 | 1 | 3 | 1>, <2 | 3 | 1| 1>>;
 

Matrix(%id = 4303246624) (2.2)
 

> GaussianElimination(C2);
 

Matrix(%id = 4320292016) (2.3)
 

> ReducedRowEchelonForm(C2);
 

Matrix(%id = 4320151608) (2.4)
 

> LinearSolve(C2);
 

Error, (in LinearAlgebra:-LA_Main:-LinearSolve) inconsistent system
 

> Student[LinearAlgebra][LinearSystemPlot](C2);
 

Plot
 

Et eksempel med uendelig mange løsninger 

> x[1]+x[2]+x[3]=1;2*x[1]+x[2]+3*x[3]=1;2*x[1]+3*x[2]+x[3]=3;
 

 

 

`+`(x[1], x[2], x[3]) = 1
`+`(`*`(2, `*`(x[1])), x[2], `*`(3, `*`(x[3]))) = 1
`+`(`*`(2, `*`(x[1])), `*`(3, `*`(x[2])), x[3]) = 3 (3.1)
 

> C3:=<<1 |1 | 1 | 1>, <2 | 1 | 3 | 1>, <2 | 3 | 1| 3>>;
 

Matrix(%id = 4344391144) (3.2)
 

> GaussianElimination(C3);
 

Matrix(%id = 4344453416) (3.3)
 

> ReducedRowEchelonForm(C3);
 

Matrix(%id = 4344860920) (3.4)
 

> LinearSolve(C3, free=t);
 

Vector[column](%id = 4345298320) (3.5)
 

Bemærk løsningerne udtrykkes ved en parameter . 

> Student[LinearAlgebra][LinearSystemPlot](C3);
 

Plot
 

Et komplekst eksempel 

> I*x[1]+x[2]=1;x[1]+(1+I)*x[2]=0;2*x[1]+x[2]=-I;
 

 

 

`+`(`*`(I, `*`(x[1])), x[2]) = 1
`+`(x[1], `*`(`+`(1, I), `*`(x[2]))) = 0
`+`(`*`(2, `*`(x[1])), x[2]) = `+`(`-`(I)) (4.1)
 

> C4:=<<I|1|1>,<1|1+I|0>,<2|1|-I>>;
 

Matrix(%id = 4346526096) (4.2)
 

> GaussianElimination(C4);
 

Matrix(%id = 4346574936) (4.3)
 

> ReducedRowEchelonForm(C4);
 

Matrix(%id = 4346638888) (4.4)
 

> LinearSolve(C4);
 

Vector[column](%id = 4346755288) (4.5)
 

Metoden for matrix inversion 

> A:=<<1,1,I>|<0,1,1-I>|<0,-I,1>>;
 

Matrix(%id = 4346767696) (5.1)
 

> MatrixInverse(A);
 

Matrix(%id = 4346834776) (5.2)
 

Vi benytter nu eliminationsmetoden til at bestemme  den inverse. 

> <A|<1,0,0>|<0,1,0>|<0,0,1>>;ReducedRowEchelonForm(%);
 

 

Matrix(%id = 4346840288)
Matrix(%id = 4346890560) (5.3)
 

>
 

>