slik1977

Lab1Methods345

Mar 17th, 2022 (edited)
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include "Algo1.h"
  4.  
  5. int main(void)
  6. {
  7.     const auto f = [](double x) -> double
  8.     {
  9.         return sin(x) * x * x * x;
  10.     };
  11.  
  12.     double x = fibonacci(0, 6, f, 50);
  13.     double y = parabola(0, 6, f, 50, 0.0001);
  14.     double z = brent(0, 6, f, 50, 0.0001);
  15.     std::cout << x << " " << f(x) << std::endl;
  16.     std::cout << y << " " << f(y) << std::endl;
  17.     std::cout << z << " " << f(z) << std::endl;
  18.     std::cout << std::endl;
  19.  
  20.     x = fibonacci(0, 20, f, 50);
  21.     y = parabola(0, 20, f, 50, 0.0001);
  22.     z = brent(0, 20, f, 50, 0.0001);
  23.     std::cout << x << " " << f(x) << std::endl;
  24.     std::cout << y << " " << f(y) << std::endl;
  25.     std::cout << z << " " << f(z) << std::endl;
  26.     std::cout << std::endl;
  27.  
  28.     x = fibonacci(0, 100, f, 50);
  29.     y = parabola(0, 100, f, 50, 0.0001);
  30.     z = brent(0, 100, f, 50, 0.0001);
  31.     std::cout << x << " " << f(x) << std::endl;
  32.     std::cout << y << " " << f(y) << std::endl;
  33.     std::cout << z << " " << f(z) << std::endl;
  34.     std::cout << std::endl;
  35.  
  36.     return 0;
  37. }
Add Comment
Please, Sign In to add comment