answersLogoWhite

0

Here is the program for Gauss elimination method

#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

{float a[6][6],b[6],x[6],t,s;

int i,j,n,k;

clrscr();

cout<<"Enter the maximum no. of matrix"<<endl;

cin>>n;

cout<<"Enter th elements of matrix"<<endl;

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

cin>>a[i][j];

}

}

cout<<"enter the right constant"<<endl;

for(i=0;i<n;i++)

{

cin>>b[i];

}

for(k=0;k<n-1;k++)

{

for(i=k+1;i<n;i++)

{

t=a[i][k]/a[k][k];

a[i][k]=0;

for(j=k;j<n;j++)

{

a[i][j]=a[i][j]-(t*a[k][i]);

}

b[i]=b[i]-(t*b[k]);

}

}

x[n-1]=b[n-1]/a[n-1][n-1];

for(i=n-1;i>=0;i--)

{

s=0;

for(j=i+1;j<n;j++)

{s=s+(a[i][j]*x[j]);

}

x[i]=(b[i]-s)/a[i][i];

}

cout<<"the solution is"<<endl;

for(i=0;i<n;i++)

{

cout<<"x["<<i<<"]="<<x[i]<<endl;

}

getch();

}

C program for Gauss Jordan method:

#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

{float a[6][6],b[6],x[6],t,s;

int i,j,n,k;

clrscr();

cout<<"Enter the maximum no. of matrix"<<endl;

cin>>n;

cout<<"Enter th elements of matrix"<<endl;

for(i=0;i<n;i++)

{

for(j=0;j<n;j++)

{

cin>>a[i][j];

}

}

cout<<"enter the right constant"<<endl;

for(i=0;i<n;i++)

{

cin>>a[i][n];

}

for(k=0;k<n;k++)

{

for(i=0;i<n;i++)

if(i!=k)

{

for(j=k+1;j<n+1;j++)

{

a[i][j]=a[i][j]-(a[i][k]/a[k][k])*a[k][j]);

cout<<"the solution is"<<endl;

for(i=0;i<n;i++)

{

x[i]=(a[i][n]/a[i][i]);

cout<<"x["<<i<<"]="<<x[i]<<endl;

}

getch();

}

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
ReneRene
Change my mind. I dare you.
Chat with Rene
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran

Add your answer:

Earn +20 pts
Q: What are the numerical method of gauss elimination and gauss Jordan method?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

Solve the following systems of simultaneous linear equations using Gauss elimination method and Gauss-Seidel Method?

Solve the following systems of simultaneous linear equations using Gauss elimination method and Gauss-Seidel Method 2x1+3x2+7x3 = 12 -----(1) x1-4x2+5x3 = 2 -----(2) 4x1+5x2-12x3= -3 ----(3) Answer: I'm not here to answer your university/college assignment questions. Please refer to the related question below and use the algorithm, which you should have in your notes anyway, to do the work yourself.


Flow chart for gaussian elimination with partial pivoting?

gauss


How can you solve for the inverse of a 3 by 3 matrix?

Gauss Elimination


Why would you choose Gauss Jordan over Gauss seidel numeric methods?

It will solve the solution "exactly", but will take a very very long time for large matrices. Gauss Jordan method will require O(n^3) multiplication/divisions and O(n^3) additions and subtractions. Gauss seidel in reality you may not know when you have reached a solution. So, you may have to define the difference between succesive iterations as a tolerance for error. But, most of the time GS is much prefured in cases of large matrices.


Solve system of equation using Gauss Jordan form- When I try to solve these I find that the matrix is singular. Does that mean no solution x plus 2y-3z equals 1 y-2z equals 2 2y-4z equals 4?

The matrix is singular because the last equation is the same as the second equation (simply multiplying every term in an equation by the same number (in this case, 2) does not produce an equation with new information). for example 1) 3x=3y 2) 2x=2y has no useful solution beyond the information from 1) that x=y You would get a singular matrix for this. The Gauss-Jordan method will not solve equations which cannot be solved by the old "elimination method".