Hi i use this code for gauss elimination method. when i use the second form of this algorithm i don't get the correct result, but in both cases the code is the same. so why this works:
for(k = 0 ; k < (n-1) ; k++) {
for(i = k ; i < (n-1) ; i++) {
temp = a[i+1][k]/a[k][k]; //Why?
for(j = k ; j < n ; j++) {
a[i+1][j] -= a[k][j] * temp;
}
}
}
and this doesn't work:
for(k = 0 ; k < (n-1) ; k++) {
for(i = k ; i < (n-1) ; i++) {
for(j = k ; j < n ; j++) {
a[i+1][j] -= a[k][j] * a[i+1][k]/a[k][k];
}
}
}