#include<iostream>
#include<math.h>
#include<cstdlib>
#include<time.h>
using namespace std ;
return ( ( 4*c ) /n ) ;
}
main ( )
{
char ch=227 ;
//variable declaration
int seed=time ( NULL ) ; /*'seed' initialized with system time value ( to be used in
srand( ) function ) */
int N ; // 'N' holds the no. of -values to be generated
double n ; /* 'n' holds the number of data points to be used for each
value evaluation */
double A[N][2] ; // 2-D array 'A' holds the tabular data
srand ( seed ) ;
#include<iostream>
#include<fstream>
#include<cstdlib>
using namespace std ;
main ( )
{
char ch=227 ;
// variable declaration
int niter ; // 'niter' holds the number of data points to be used for each
value evaluation
int N ; // 'N' holds the total no. of pi-values to be generated in the text file
double pi ; // 'pi' holds each calculated pi-value
cout.precision ( 15 ) ;
cout<<"Enter the number of data points you want for calculating the value of "<<ch<<" ";
cin>>niter ;
cout<<"\nEnter the number of "<<ch<<" values you want in your text file " ;
cin>>N ;
// Loops for generating and putting each pi-value in the text file 'pi.txt'
#include<iostream>
#include<math.h>
using namespace std ;
// Defining function 'f' for returning function's value at any point 'x'
double f ( double x )
{
return ( x*x-2 ) ;
}
main ( )
{
cout.precision ( 15 ) ;
//Variable Declaration
double a,b ; // a and b hold any two values about the root ( f ( a ) < 0 and f ( b ) > 0 )
double e ; // e holds the accuracy upto which root is to be found
double mid ; // mid holds the mid-values of the two points about the root
int c=0 ; // c keeps the count of number of steps
cout<<"Enter the values of a and b such that f ( a ) < 0 and f ( b ) > 0 " ;
cin>>a>>b ;
cout<<"\nDefine the accuracy upto which you want to calculate the root " ;
cin>>e ;
#include<iostream>
#include<math.h>
using namespace std ;
// Defining function 'f' for returning function's value at any point 'x'
double f ( double x )
{
return x*x-2 ;
}
// Defining function 'derivative_f' for returning function's derivative value at any point 'x'
main ( )
{
cout.precision ( 15 ) ;
// Variable Declaration
cout<<"Enter any value that you think is close to the root " ;
cin>>a ;
cout<<"\nEnter the accuracy you want in the determination of roots " ;
cin>>e ;
// Code for calculating the root using Newton-Raphson method
#include<iostream>
#include<math.h>
using namespace std ;
// Defining function 'f' for returning function's value at any point 'x'
double f ( double x )
{
return ( ( x*x ) -2 ) ;
}
main ( )
{
cout.precision ( 15 ) ;
// Variable Declaration
double a,b ; // a and b hold any two values close to the root
double e ; // e holds the accuracy up to which root is to be found
double z ; // z holds the value of root calculated in each step
int c=1 ; // c keeps the count of number of steps
cout<<"Enter any two values that you think are close to the root " ;
cin>>a>>b ;
cout<<"\nEnter the accuracy you want in the determination of roots " ;
cin>>e ;