Write a report in which you discuss and compare your Gauss elimination and Gauss-Jordan programs.   Gauss elimination #include int main ( ) {     int i, j, k, n;     float A[20] [20], c, x [10], sum=0.0;     printf("\Enter the order of matrix: ");     Sacnf("%d,&n);     prinf("\n Enter the elements of augmented matrix row-wise: \n\n");     for(i =1; i<=n; i++)     {         for(j=1; j<(n+1); j++)         {               printf("A[%d][%d] : ", i, j);                 scanf("%f", [i][j]);                 }          }          for(j=1; jj)                     {                       c=A[i][j]/A[j][j];                        for(k=1; k<=n+!; k++)                         {                          A[i][k] = A[i][k]-c*A[j][k];                           }                       }              }     } x[n]= A[n] [n+1]/A[n][n]; for(i=n-1; i>=1; i--)  {     sum=0;      for(j=i+1; j<=n; j++)      {             sum=sum+A[i][j]*x[j];          }             x[i]=A[i][n+1]-sum)/A[i][I];         }      printf("\n The solution is : \n");       for(i=1; i<=n; i++)        {             printf("\nx%d=%f\t", i, x[i];        }  return(0); }      Gauss-Jordan method   #include int main() {     int i,j,k,n;     float A[20][20],c,x[10],sum=0.0;     printf("\nEnter the order of matrix: ");     scanf("%d",&n);     printf("\nEnter the elements of augmented matrix row-wise:\n\n");     for(i=1; i<=n; i++)     {         for(j=1; j<=(n+1); j++)         {             printf("A[%d][%d] : ", i,j);             scanf("%f",&A[i][j]);         }     }     for(j=1; j<=n; j++) /* loop for the generation of upper triangular matrix*/     {         for(i=1; i<=n; i++)         {             if(i>j)             {                 c=A[i][j]/A[j][j];                 for(k=1; k<=n+1; k++)                 {                     A[i][k]=A[i][k]-c*A[j][k];                 }             }         }     }     x[n]=A[n][n+1]/A[n][n];     /* this loop is for backward substitution*/     for(i=n-1; i>=1; i--)     {         sum=0;         for(j=i+1; j<=n; j++)         {             sum=sum+A[i][j]*x[j];         }         x[i]=(A[i][n+1]-sum)/A[i][i];     }     printf("\nThe solution is: \n");     for(i=1; i<=n; i++)     {         printf("\nx%d=%f\t",i,x[i]); /* x1, x2, x3 are the required solutions*/     }     return(0); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Write a report in which you discuss and compare your Gauss elimination and Gauss-Jordan programs.

 

Gauss elimination

#include<stdio.h>

int main ( )

{

    int i, j, k, n;

    float A[20] [20], c, x [10], sum=0.0;

    printf("\Enter the order of matrix: ");

    Sacnf("%d,&n);

    prinf("\n Enter the elements of augmented matrix row-wise: \n\n");

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

    {

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

        {

              printf("A[%d][%d] : ", i, j);

                scanf("%f", [i][j]);

                }

         }

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

         {

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

                {

                   if(i>j)

                    {

                      c=A[i][j]/A[j][j];

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

                        {

                         A[i][k] = A[i][k]-c*A[j][k];

                          }

                      }

             }

    }

x[n]= A[n] [n+1]/A[n][n];

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

 {

    sum=0;

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

     {

            sum=sum+A[i][j]*x[j];

         }

            x[i]=A[i][n+1]-sum)/A[i][I];

        }

     printf("\n The solution is : \n");

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

       {

            printf("\nx%d=%f\t", i, x[i];

       }

 return(0);

 

 

Gauss-Jordan method

 

#include<stdio.h>

int main()

{

    int i,j,k,n;

    float A[20][20],c,x[10],sum=0.0;

    printf("\nEnter the order of matrix: ");

    scanf("%d",&n);

    printf("\nEnter the elements of augmented matrix row-wise:\n\n");

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

    {

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

        {

            printf("A[%d][%d] : ", i,j);

            scanf("%f",&A[i][j]);

        }

    }

    for(j=1; j<=n; j++) /* loop for the generation of upper triangular matrix*/

    {

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

        {

            if(i>j)

            {

                c=A[i][j]/A[j][j];

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

                {

                    A[i][k]=A[i][k]-c*A[j][k];

                }

            }

        }

    }

    x[n]=A[n][n+1]/A[n][n];

    /* this loop is for backward substitution*/

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

    {

        sum=0;

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

        {

            sum=sum+A[i][j]*x[j];

        }

        x[i]=(A[i][n+1]-sum)/A[i][i];

    }

    printf("\nThe solution is: \n");

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

    {

        printf("\nx%d=%f\t",i,x[i]); /* x1, x2, x3 are the required solutions*/

    }

    return(0);

}

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Matrix multiplication
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education