# solver for AX=B by gauss elimination

i need a program to solve AX=B by gauss elimination.
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Don't you think some more explanation is required?
0
Commented:
Do your own linear algebra homework. Hint: your professor will know that BLAS at netlib is too complex for you to write yourself. Please remember to strip off the comments so that it's not too obvious. He/she will still recognize it, of course.
0
Commented:
I am willing to help but I am not going to do it for you.  Post some code.
0
Commented:
Can you solve AX=B with gauss elimination?? I thought gauss elimination was for equations like ax² +bx + c = 0.
the solution for AX=B is X=B/A isn't it??
Or is it so long ago that i'm wrong?

0
Commented:
Well, yes, if you want to use Gauss-Jordan elimination to compute A¯¹
0
Commented:
try this..my teacher made me do it..and here it is..just..make it dynamic array..

#include "stdafx.h"
#include "iostream.h"
#include "iomanip.h"
#include "math.h"

int main() {
int lngth;
cout << "Size of matrix:\n";
cin >> lngth;
if (lngth>10) return 0;
double a[10][10], b[10], x,      y, z[10];
for (int ix=0; ix<=lngth-1; ix++) {
for (int iy=0; iy<=lngth-1; iy++) {
cout << "Term of "<< ix+1 << "x" << iy+1 << ":";
cin >> a[iy][ix];
}
cout << "Please enter solution for this equation" << ":";
cin >> b[ix];
}
for (int u=0; u<=lngth-1; u++) {
for (int v=0; v<=lngth-1; v++) {
if (a[u][v]!=0) {
if (double(a[u][v])!=1) {
cout << setw(3) <<a[u][v];
} else {
cout << setw(3) << " ";
}
cout << char('a'+v);
if (v!=lngth-1) {
cout << " +";
}
} else {
cout << setw(6) << " ";
}
}
cout << "\t = " << b[u];
cout << '\n';
}

for (int i=0; i<=lngth-1; i++) {
for (int j=0; j<=lngth-1; j++){
x=a[i][i];
y=a[j][i];
if (x==0) {
for (int h=0; h<=lngth-1; h++) {
if ((h!=i)&&(a[h][i]!=0)) {
for (int w=0; w<=lngth-1; w++) {
a[i][w]=a[i][w]+a[h][w];
}
b[i]=b[i]+b[h];
break;
}
}
}
if ((x!=1)&&(x!=0)) {
for (int m=0; m<=lngth-1; m++) {
a[i][m]=a[i][m]/x;
}
b[i]=b[i]/x;
}
if  ((!(i==j))&&(y!=0)) {
for (int k=0; k<=lngth-1; k++) {
a[j][k]=(a[i][k]*y)-(a[j][k]);
}
float s=(b[i]*y), t=(b[j]);
if (s-t==0) {
b[j]=0;
} else {
b[j]=(b[i]*y)-(b[j]);
}
}
}
}
cout << '\n';
for (int l=0; l<=lngth-1; l++) {
z[l]=(double)(b[l])/(double)(a[l][l]);
cout << char('a'+l) << "=" <<setprecision(20) << z[l] <<"\n";
}
return 0;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.