Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include "Algo1.h"
- int main(void)
- {
- const auto f = [](double x) -> double
- {
- return sin(x) * x * x * x;
- };
- double x = fibonacci(0, 6, f, 50);
- double y = parabola(0, 6, f, 50, 0.0001);
- double z = brent(0, 6, f, 50, 0.0001);
- std::cout << x << " " << f(x) << std::endl;
- std::cout << y << " " << f(y) << std::endl;
- std::cout << z << " " << f(z) << std::endl;
- std::cout << std::endl;
- x = fibonacci(0, 20, f, 50);
- y = parabola(0, 20, f, 50, 0.0001);
- z = brent(0, 20, f, 50, 0.0001);
- std::cout << x << " " << f(x) << std::endl;
- std::cout << y << " " << f(y) << std::endl;
- std::cout << z << " " << f(z) << std::endl;
- std::cout << std::endl;
- x = fibonacci(0, 100, f, 50);
- y = parabola(0, 100, f, 50, 0.0001);
- z = brent(0, 100, f, 50, 0.0001);
- std::cout << x << " " << f(x) << std::endl;
- std::cout << y << " " << f(y) << std::endl;
- std::cout << z << " " << f(z) << std::endl;
- std::cout << std::endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment