/************* Eigen value and eigen vector by Power method ***********/
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
float a[10][10],x[10],c[10],d=0,temp;
int n,i,j;
C C++ code : power method - numerical method to find eigen value and vector
Working C C++ Source code program for finding eigen value and eigen vector by power method
C C++ CODE: Gauss Jordon elimination method to solving linear equations
Working C C++ Source code program for Gauss Jordon elimination method to solving linear equations
/*************** Gauss Jordan method ********************/
#include<iostream.h>
#include<conio.h>
int main()
{
int i,j,k,n;
float a[10][10],d;
clrscr();
cout<<"No of equations ? ";cin>>n;
cout<<"Read all coefficients of matrix with b matrix too "<<endl;
for(i=1;i<=n;i++) // read nxn matrix - cofficients
for(j=1;j<=n+1;j++)
cin>>a[i][j];
/************** partial pivoting **************/
for(i=n;i>1;i--)
{
if(a[i-1][1]<a[i][1])
for(j=1;j<=n+1;j++)
{
d=a[i][j];
a[i][j]=a[i-1][j];
a[i-1][j]=d;
}
}
cout<<"pivoted output: "<<endl;
for(i=1;i<=n;i++)
{
for(j=1;j<=n+1;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
/********** reducing to diagonal matrix ***********/
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
if(j!=i)
{
d=a[j][i]/a[i][i];
for(k=1;k<=n+1;k++)
a[j][k]-=a[i][k]*d;
}
}
/************** reducing to unit matrix *************/
for(i=1;i<=n;i++)
{
d=a[i][i];
for(j=1;j<=n+1;j++)
a[i][j]=a[i][j]/d;
}
cout<<"your solutions: "<<endl;
for(i=1;i<=n;i++)
{
for(j=1;j<=n+1;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
getch();
return 0;
}
C C++ CODE : Gauss jordan method for finding inverse matrix
Working C C++ Source code program for Gauss jordan method for finding inverse matrix
/*************** Gauss Jordan method for inverse matrix ********************/
#include<iostream.h>
#include<conio.h>
int main()
{
int i,j,k,n;
float a[10][10]={0},d;
clrscr();
C C++ CODE : LU Decomposition for solving linear equations
Working C C++ Source code program for LU Decomposition for solving linear equations
/************** LU Decomposition for solving linear equations ***********/
#include<iostream.h>
#include<conio.h>
int main()
{
int n,i,k,j,p;
float a[10][10],l[10][10]={0},u[10][10]={0},sum,b[10],z[10]={0},x[10]={0};
clrscr();
cout<<"Enter the order of matrix ! ";
cin>>n;
C C++ CODE : Gauss elimination for solving linear equations
Working C C++ Source code program for Gauss elimination for solving linear equations
/************* Gauss elimination for solving linear equations *************/
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int n,i,j,k,temp;
float a[10][10],c,d[10]={0};
clrscr();
cout<<"No of equation ? ";
cin>>n;
C C++ CODE : least square fitting regression
Working C C++ Source code program for least square fitting regression
/*************** least square fitting ******************/
#include<iostream.h>
#include<conio.h>
#include<math.h>
int main()
{
int n,i,j;
float a,a0,a1,x[10],f[10],sumx=0,sumy=0,sumxy=0,sumx2=0;
clrscr();
cout<<"Enter no of sample points ? ";cin>>n;
C C++ CODE: Lagrange's interpolation
Working C C++ Source code program for Lagrange's interpolation
/********** Lagrange's interpolation ***************/
#include<iostream.h>
#include<conio.h>
int main()
{
int n,i,j;
float mult,sum=0,x[10],f[10],a;
clrscr();
C C++ CODE for Newton's interpolation
Working C C++ Source code program for Newton's interpolation
/***************** Newtons interpolation **************/
#include<iostream.h>
#include<conio.h>
int main()
{
int n,i,j;
float x[10],f[10],a,sum=0,mult;
clrscr();
C C++ CODE: Cubic Spline Interpolation
Working C C++ Source code program for Cubic Spline Interpolation
/********************* Cubic Spline Interpolation **********************/
#include<iostream.h>
#include<conio.h>
#include<math.h>
int main()
{
char choice='y';
int n,i,j,k;
C C++ code : horner's synthetic division
Working C C++ Source code program for horner's synthetic division method for finding solution of polynomial equation.
//horner's polynomial soln, synthetic division
#include <iostream.h>
#include <conio.h>
#include <complex.h>
void main()
{
int it,n;
complex a[10],b[10],c[10],x;
clrscr();
cout<<"Enter the degree of the polynomial:";
cin>>n;
Subscribe to:
Posts
(
Atom
)