Skip to main content

Posts

Showing posts from December, 2021

simpson's 1/3 rule

  ///Bismillahir Rahmanir Rahim ///Author:Tanvir Ahmmad ///Dept.CSE,IU,Bangladesh #include< iostream > using   namespace  std; int  main() {      double  up,low,h,arr_y[ 1009 ],sum= 0 ;     cout<< "Given function f(x)=1/(1+X)" <<endl<< "Given the upper limit of integration : " ;     cin>>up;     cout<< "Given the lower limit of integration : " ;     cin>>low;     cout<< "Given the value of h : " ;     cin>>h;      int  n=(up-low)/h;     cout<< "So the value of n = " <<n<<endl;      for ( int  i= 0 ; i<=n; i++)  ...

trapezoidal rule

///Bismillahir Rahmanir Rahim ///Tanvir Ahmmad ///Dept.CSE,IU,Bangladesh #include<iostream> using namespace std; int main() {     double up,low,h,arr_y[1009],sum=0;     cout<<"Given function f(x)=1/(1+X)"<<endl<<"Given the upper limit of integration : ";     cin>>up;     cout<<"Given the lower limit of integration : ";     cin>>low;     cout<<"Given the value of h : ";     cin>>h;     int n=(up-low)/h;     cout<<"So the value of n = "<<n<<endl;     for(int i=0; i<=n; i++)     {         arr_y[i]=(1.0/(1.0+(i*h)));         if(i==0) cout<<"X=X0        Y["<<i<<"]="<<arr_y[i]<<endl;         else cout<<"X=X0+"<<i<<"h"<<"     Y["<<i<<"]="<<arr_y[i]...

newton raphson method

   ///Bismillahir Rahmanir Rahim ///Author:Tanvir Ahmmad ///CSE,Islamic University,Bangladesh #include<iostream> using namespace std; double fun_1(double num) {     return ((num*num)-(4*num)-7); } double deri_fun_1(double num) {     return ((2*num)-4); } int main() {     char ch = 253;     double num,brk_limit;     int step,cas=1;     cout<<"Given equation : "<<"X"<<ch<<"-4X-7"<<endl;     cout<<"       f(x)=X"<<ch<<"-4X-7"<<endl;     cout<<"      f'(x)=2X-4"<<endl;     cout<<"Please enter an inter initial guess : ";  ...

lagrange interpolation method

///Bismillahir Rahmanir Rahim ///Author:Tanvir Ahmmad ///CSE,Islamic University,Bangladesh ///Dept.CSE,IU,Bangladesh #include<iostream> using namespace std; typedef int in; typedef double db; int main() {     in n,fin;     cout<<"Enter number of data point: ";     cin>>n;     in arr_x[n+3],arr_y[n+3];     cout<<"Input these "<<n<<" points:"<<endl;     for(in i=1; i<=n; i++) cin>>arr_x[i]>>arr_y[i];     cout<<"After given values : "<<endl;     for(in i=1; i<=n; i++)         cout<<"x["<<i<<"] = "<<arr_x[i]<<"  "<...