Documente Academic
Documente Profesional
Documente Cultură
CProgramforGaussEliminationMethod|CodewithC
C Tutorial
Numerical Methods
How To ?
Search...
Code with C
MiniProjects
SourceCode
StudentProjects
C++Code
34%
in Numerical Methods
5 Comments
29%
34%
29%
29%
Java Projects
C++ Projects
C Projects
Downloads
Find us on Facebook
Codewithc.com
Assuming a1 0, x is eliminated from the second equation by subtracting (a2/ a1) times the first equation
from the second equation. In the same way, the C code presented here eliminates x from third equation
by subtracting (a3/a1) times the first equation from the third equation.
Like
780peoplelikeCodewithc.com.
Facebooksocialplugin
Popular
Recent
Comments
Tags
http://www.codewithc.com/cprogramforgausseliminationmethod/
1/4
1/13/2015
CProgramforGaussEliminationMethod|CodewithC
SourceCodeforGaussEliminationMethodin
C:
Download
May 3, 2014
16
}
17
for(j=1; j<=n; j++) /* loop for the generation of upper triangular matrix*/
18
{
19
for(i=1; i<=n; i++)
20
{
21
if(i>j)
22
{
23
c=A[i][j]/A[j][j];
24
for(k=1; k<=n+1; k++)
25
{
26
A[i][k]=A[i][k]-c*A[j][k];
27
}
28
}
29
}
30
}
31
x[n]=A[n][n+1]/A[n][n];
32
/* this loop is for backward substitution*/
33
for(i=n-1; i>=1; i--)
34
{
35
sum=0;
36
for(j=i+1; j<=n; j++)
37
{
38
sum=sum+A[i][j]*x[j];
39
}
40
x[i]=(A[i][n+1]-sum)/A[i][i];
41
}
42
printf("\nThe solution is: \n");
43
for(i=1; i<=n; i++)
44
{
45
printf("\nx%d=%f\t",i,x[i]); /* x1, x2, x3 are the required solutions*/
46
}
47
return(0);
48 }
Input/Output:
Also see,
http://www.codewithc.com/cprogramforgausseliminationmethod/
2/4
1/13/2015
CProgramforGaussEliminationMethod|CodewithC
DownloadSourceCode
C++Code
ScienceProjects
Share !
Tweet
Like
Share
Previous:
Next:
5 comments
Patrik
December 16, 2014 at 8:08 pm
Anonymous
November 26, 2014 at 7:32 pm
Can you also include the function of partial pivoting in this program?
Reply
Pavan
September 4, 2014 at 12:36 pm
your program is not working for some special matrices , u should improve the program in such a way that
it has to work for all types of matrices
Reply
Pramesh Pudasaini
September 4, 2014 at 1:32 pm
PassingBy
November 30, 2014 at 10:50 am
E.g. matrix, where at some point element on the main diagonal will be equal 0.
You should try https://en.wikipedia.org/wiki/Elementary_matrix#Operations
Reply
Leave a Reply
Your email address will not be published. Required fields are marked *
Name *
Email *
Website
PostComment
http://www.codewithc.com/cprogramforgausseliminationmethod/
3/4
1/13/2015
CProgramforGaussEliminationMethod|CodewithC
Home|AboutUs|ContactUs|PrivacyPolicy|TermsofUse
Copyright20142015CodewithC.Allrightsreserved.
http://www.codewithc.com/cprogramforgausseliminationmethod/
4/4