SE01 GaussianElimination Error

0 views
Skip to first unread message

arl...@gmail.com

unread,
Nov 29, 2006, 6:45:03 PM11/29/06
to EE4217
Hello, An error was detected with the following test matrix:
934|7
434|8
111|3
correct result is:(-.2,4,-.8):
The test was:
...
public void testSolveMatrix1 (){
try {
m = new Matrix ( new double [] [] {{9,3,4} ,{4,3,4} ,{1,1,1}});
double [] b = new double [] {7,8,3};
double [] result=solver.solve(m,b);
assertEquals ( -0.2,result[0]);
assertEquals ( 4,result[1]);
assertEquals ( -0.8,result[2]);
}
catch (Exception e) { e.printStackTrace (); }
}
...
The assertion failed on the value for result[0].

so maybe there was an error in the last steps when
re-substituting the answers from the last rows
z and y in to x.(According to the Gauss-Elimination Method)

Line 40 of GaussianEliminationFlawed.java had a loop that did not
reach to the first row, to re-substitute back in to (x):

// now we have to resubstitute
for (int i = dimension-1 ; i > 0; i--) {
//change to >= to include the first ROW for X
for (int i = dimension-1 ; i >= 0; i--) {

By changing the code, the vector showed the correct value for x:
and the test passed. result=(-.2,4,-.8)

Reply all
Reply to author
Forward
0 new messages