Created
October 2, 2020 09:33
-
-
Save sverhoeven/6d41c2342bbf4de7537be4926f36c769 to your computer and use it in GitHub Desktop.
run-cpp-on-web: vega
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include "newtonraphson.hpp" | |
int main() { | |
float initial_guess = -4; | |
float tolerance = 0.001; | |
NewtonRaphson newtonraphson(tolerance); | |
newtonraphson.solve(initial_guess); | |
std::cout << std::fixed; | |
std::cout << std::setprecision(2); | |
for (Iteration iteration : newtonraphson.iterations) { | |
std::cout << "index = " << iteration.index; | |
std::cout << " x = " << iteration.x; | |
std::cout << " y = " << iteration.y; | |
std::cout << " slope = " << iteration.slope; | |
std::cout << " delta_x = " << iteration.delta_x << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment