From 0f04e97fa748b6740da4c9512b596d7d3a2788c5 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 6 Oct 2010 16:47:04 -0400 Subject: Add the Euler method. --- tests/Euler.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/Euler.cpp (limited to 'tests/Euler.cpp') diff --git a/tests/Euler.cpp b/tests/Euler.cpp new file mode 100644 index 0000000..5666cd8 --- /dev/null +++ b/tests/Euler.cpp @@ -0,0 +1,25 @@ +#include "vZ.hpp" +#include +#include +#include + +// y' = y (y == C*exp(t)) +double +f(double t, double y) +{ + return y; +} + +int +main() +{ + vZ::EulerIntegrator integrator(f); + integrator.y(1.0).x(0.0).h(0.01); + + integrator.integrate(2.0); + + std::cout << integrator.y() << std::endl + << std::exp(2.0) << std::endl; + + return EXIT_SUCCESS; +} -- cgit v1.2.3