Gaussian Elimination
Apr 18, 2007Example usage:
To solve Ax=B
|25 5 1| |106.8 |
A = |64 8 1| , B = |177.21|
|144 12 1| |279.21|
exec dbo.gaussianElimination
N'<matrix>
<row values="25,5,1,106.8"/>
<row values="64,8,1,177.21"/>
<row values="144,12,1,279.21"/>
</matrix>', @verbose = 1
Will give this:
inputMatrix
--------------------------------------------------------------------------------
25,5,1,106.8
64,8,1,177.21
144,12,1,279.21
result
--------------------------------------------------------------------------------
x0 = 0.290000
x1 = 19.700000
x2 = 1.050000
testingScenario
--------------------------------------------------------------------------------
set nocount on
declare @x0 float
declare @x1 float
declare @x2 float
set @x0 = 0.290000
set @x1 = 19.700000
set @x2 = 1.050000
select (25 * @x0) + (5 * @x1) + (1 * @x2) --= 106.8
select (64 * @x0) + (8 * @x1) + (1 * @x2) --= 177.21
select (144 * @x0) + (12 * @x1) + (1 * @x2) --= 279.21
Resultant row echelon matrix after solving the augmented input matrix
========================================================================================================================
m n0 n1 n2 n3
------- ----------------------------------------------------- ----------------------------------------------------- ----------------------------------------------------- -----------------------------------------------------
m0 1.0 0.0 0.0 0.28999999999999826
m1 0.0 1.0 0.0 19.700000000000028
m2 0.0 0.0 1.0 1.0499999999998986