⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch4itmain.cc

📁 C++ source code for book-C++ and Object Oriented Numeric computing for scientists and engineers
💻 CC
字号:
// to compile: 
// c++ ch4it.cc ch4itmain.cc

#include "ch4it.h"

int main() {

  using namespace std;

// fa()
  double root = bisctn0(1.0e-2, 1, fa, delta, epsn);
  cout << "Approximate root of fa() by bisctn0() is: " << root << '\n';
  cout << "Fcn value at approx root (residual) is: " << fa(root) << '\n';

  cout << "Approximate root by bisctn1() is:" 
       << bisctn1(1.0e-2, 1, fa, fa(1.0e-2), delta, epsn) << '\n';

  cout << "Approximate root by bisctn2() is:" 
       << bisctn2(1.0e-2, 1, fa, fa(1.0e-2), delta, epsn, 500) << '\n';

  int itern = 1;
  cout << "Approximate root by bisectionr() is:" 
       << bisectionr(1.0e-2, 1, fa, fa(1.0e-2), delta, epsn, 
                     500, itern) << '\n';
  cout << "Number of iterations used in bisectionr() = " << itern << '\n'; 

  root = bisection(1, 1.0e-2, fa, delta, epsn, 500);
  cout << "Approx root of fa() by bisection() is: " << root << '\n';
  cout << "Fcn value at approx root (residual) is: " << fa(root) << '\n';


// fb()
  root = bisctn0(1, 3, fb, delta, epsn);
  cout << "\nApproximate root of fb() by bisctn0() is: " << root << '\n';
  cout << "Fcn value at approx root (residual) is: " << fb(root) << '\n';

  cout << "Approximate root by bisctn1() is:" 
       << bisctn1(1, 3, fb, fb(1), delta, epsn) << '\n';
  cout << "Approximate root by bisctn2() is:" 
       << bisctn2(1, 3, fb, fb(1), delta, epsn, 500) << '\n';
  itern = 1;
  cout << "Approximate root by bisectionr() is:" 
       << bisectionr(1, 3, fb, fb(1), delta, epsn, 500, itern) << '\n';
  cout << "Number of iterations used in bisectionr() = " << itern << '\n'; 
  root = bisection(1, 3, fb, delta, epsn, 500);
  root = bisection(3, 1, fb, delta, epsn, 500);
  cout << "Approximate root of fb() by bisection() is: " << root << '\n';
  cout << "Fcn value at approximate root (residual) is:" << fb(root) << '\n';


// fc()
  root = bisctn0(0, 4, fc, delta, epsn);
  cout << "\nApproximate root of fc() by bisctn0() is: " << root << '\n';
  cout << "Fcn value at approximate root (residual) is:" << fc(root) << '\n';

  cout << "Approximate root by bisctn1() is:" 
       << bisctn1(0, 4, fc, fc(0), delta, epsn) << '\n';
  cout << "Approximate root by bisctn2() is:" 
       << bisctn2(0, 4, fc, fc(0), delta, epsn, 500) << '\n';
  itern = 1;
  cout << "Approximate root by bisectionr() is:" 
       << bisectionr(0, 4, fc, fc(0), delta, epsn, 500,itern) << '\n';
  cout << "Numer of iterations used in bisectionr() = " << itern << '\n'; 
  root = bisection(0, 4, fc, delta, epsn, 500);
  root = bisection(4, 0, fc, delta, epsn, 500);
  cout << "Approximate root of fc() by bisection() is: " << root << '\n';
  cout << "Fcn value at approximate root (residual) is:" << fc(root) << '\n';
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -