All Programs are Written and Compiled in Dev C++. So, it may generate some error in case of other compilers and may need some modifications in program. Download Dev C++

Friday 13 February 2015

Newton-Raphson's Method

#include<iostream>
#include<math.h>
#include<iomanip>
#define err 0.0001
//Correction upto three places
using namespace std;
float f(float x)
{
return pow(x,4)-x-9;
//Function f(x)
}
float df(float x)
{
return 4*pow(x,3)-1;
//Diffirenciation of f(x)
}

Iteration Method of Solving Transcidental Equations

#include<iostream>
#include<math.h>
#define err 0.0001
//Correction upto three Places
using namespace std;
float iterative(float x)
{
return pow((x+9),0.25); //Function G(x)=0
}
float f(float x)
{
return x*x*x*x-x-9; //Function f(x)=0
}
int main()
{
int i=1;
float x0,x1;
cout<<"Enter the first approximation ";
cin>>x0;

Secant Method of Solving Transcidental Equation

#include<iostream>
#include<math.h>
#include<iomanip>
#define err 0.0001
//Correction upto three places
using namespace std;
float f(float x)
{
return x*x*x-2*x-5; //Place your Function here
}
float secant(float x0,float x1)
{
return x1-((x1-x0)/(f(x1)-f(x0))*f(x1));
}
int main()
{
int i=2;
float x0,x1,x2,x3;
cout<<"Enter two initial approximate roots x0,x1 : ";
cin>>x0>>x1;

Method Of false Position (Regula-Falsi method)

#include<iostream>
#include<math.h>
#include<iomanip>
#define err 0.0001
//Correction upto three places
using namespace std;
float f(float x)
{
return cos(x)-x*exp(x); //Place your Function Here
}
float regula(float x0,float x1)
{
return x0-((x1-x0)/(f(x1)-f(x0))*f(x0));
}
int main()
{
int i=1,max;
float x0,x1,x2,x3;
cout<<"Enter two initial approximate roots x0,x1 : ";
cin>>x0>>x1;

Bisection Method of Solving Equation

#include<iostream>
#include<math.h>
#include<iomanip>
#define bisect(a,b) (a+b)/2
#define err 0.0001
//Correction upto three places
using namespace std;
float f(float x)
{
return pow(x,4)-x-9; //Put Your Function here
}
int main()
{
int i=1,max;
float x,x1,a,b;
cout<<"Enter two initial approximate roots a,b : ";
cin>>a>>b;