0% found this document useful (0 votes)
52 views8 pages

User Manual:: 1. Enter The Number of Equations

This user manual describes how to use a program to solve systems of linear equations using iterative methods. It involves entering the number of equations, coefficients for each equation, initial guesses for the variables, and desired accuracy. The program then performs iterations to solve for the variables, displaying the results at each iteration until the changes are within the specified accuracy.

Uploaded by

James Santos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views8 pages

User Manual:: 1. Enter The Number of Equations

This user manual describes how to use a program to solve systems of linear equations using iterative methods. It involves entering the number of equations, coefficients for each equation, initial guesses for the variables, and desired accuracy. The program then performs iterations to solve for the variables, displaying the results at each iteration until the changes are within the specified accuracy.

Uploaded by

James Santos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

User Manual:

1. Enter the number of equations.


+
2. Enter the elements of each matrix in the form
Ax + By + Cz= D where x,y,z are the variables and A B C D are
the constant coefficiencts.
Use space as separator for each value.
3. Enter the initial values of the variable.
Use space as separator for each value.
4. Enter the accuracy at which you want the iteration to terminate.
5. Click enter to show the results of the tabulated results of
iteration.
SOURCE CODE:
#include<cmath>
using namespace std;
int main()
{
cout.precision(4);
cout.setf(ios::fixed);
int n,i,j,k,flag=0,count=0;
cout<<"\nEnter the no. of equations\n";
cin>>n;
double a[n][n+1];
double x[n];
double eps,y;
cout<<"\nEnter the elements of the matrix:\n";
for (i=0;i<n;i++)
for (j=0;j<=n;j++)
cin>>a[i][j];
cout<<"\nEnter the initial values of the variables:\n";
for (i=0;i<n;i++)
cin>>x[i];
cout<<"\nEnter the accuracy upto which you want the solution:\n";
cin>>eps;
for (i=0;i<n;i++)
for (k=i+1;k<n;k++)
if (a[i][i]<a[k][i])
for (j=0;j<=n;j++)
{
double temp=a[i][j];
a[i][j]=a[k][j];
a[k][j]=temp;
}
cout<<"Iter"<<setw(10);
for(i=0;i<n;i++)
cout<<"x"<<i<<setw(18);
cout<<"\n----------------------------------------------------------------------";
do //
{
cout<<"\n"<<count+1<<"."<<setw(16);
for (i=0;i<n;i++)
{
y=x[i];
x[i]=a[i][n];
for (j=0;j<n;j++)
{
if (j!=i)
x[i]=x[i]-a[i][j]*x[j];
}
x[i]=x[i]/a[i][i];
if (abs(x[i]-y)<=eps)
flag++;
cout<<x[i]<<setw(18);
}
cout<<"\n";
count++;
}while(flag<3);

cout<<"\n The solution is as follows:\n";


for (i=0;i<n;i++)
cout<<"x"<<i<<" = "<<x[i]<<endl;
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy