Skip to content

Instantly share code, notes, and snippets.

@sverhoeven
Created October 2, 2020 08:19
Show Gist options
  • Save sverhoeven/9f8ea6d4dbb53936a2c2c2a704125752 to your computer and use it in GitHub Desktop.
Save sverhoeven/9f8ea6d4dbb53936a2c2c2a704125752 to your computer and use it in GitHub Desktop.
run-cpp-on-web: webassembly
#include <iostream>
#include <iomanip>
#include "newtonraphson.hpp"
int main() {
float initial_guess = -4;
float tolerance = 0.001;
NewtonRaphson newtonraphson(tolerance);
float root = newtonraphson.solve(initial_guess);
std::cout << "Function root is approximately at x = ";
std::cout << std::fixed << std::setprecision(2) << root << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment