| Author |
Comment/Response |
Bill Simpson
|
09/07/12 9:37pm
From In[11]:=
B={{1.1161, 0.1254, 0.1397, 0.149, 1.5471},
{0.1582, 1.1675, 0.1768, 0.1871, 1.4471},
{0.1968, 0.2071, 1.2168, 0.2271, 1.7471},
{0.2368, 0.2471, 0.2568, 1.2671, 1.8471})
In[12]:=(*We must process all four columns*)
For[column=1,column≤4,column++,
(*Find the pivot row*)
(*Begin by assuming the first row is the pivot row*)
pivotrow=1;
For[row=2,row≤4,row++,
If[B[[row,column]]>B[[pivotrow,column]],
(*element is larger, revise pivot row assumption*)
pivotrow=row]
];
(*Now we know the pivot row*)
(*Process all four rows*)
For[row=1,row≤4,row++,
If[row≠pivotrow,
(*then we subtract scaled pivot row from row*)
B[[row]]=B[[row]]-B[[row,column]]/B[[pivotrow,column]]*B[[pivotrow]],
(*else we scale the row to have a leading 1*)
B[[row]]=B[[row]]/B[[row,column]]
]
];
];
Print["B=",MatrixForm[B]];
From In[19]:=B=
{{1.0000, 1.3877*^-17, 0.0000, -1.3877*^-17, 1.0542},
{0.0000, 1.0000, 0.0000, 0.0000, 0.8057},
{0.0000, 0.0000, 1.0000, -2.7755*^-17, 0.9584},
{0.0000, 0.0000, 0.0000, 1.0000, 0.9093}}
Study this and test this very carefully to make certain that I have made no mistakes in this.
But there is some chance this is at least partly correct because the result seems to match
In[31]:= LinearSolve[A,RHS]
Out[31]= {1.05427,0.80576,0.958446,0.909333}
URL: , |
|