#include <kv/strobomap.hpp>
#include <kv/kraw-approx.hpp>

namespace ub = boost::numeric::ublas;

typedef kv::interval<double> itv;


struct Duffing {
	template <class T> ub::vector<T> operator() (const ub::vector<T>& x, T t){
		ub::vector<T> y(2);

		y(0) = x(1);
		y(1) = - 0.125 * x(1) - x(0)*x(0)*x(0) + 0.5 * cos(t);

		return y;
	}
};

int main()
{
	ub::vector<double> x;
	ub::vector<itv> ix;
	bool r;

	std::cout.precision(17);

	Duffing f;

	kv::StroboMap<Duffing,double> g(f, (itv)0., kv::constants<itv>::pi() * 2.);

	kv::FixedPoint< kv::StroboMap<Duffing,double> > h(g);

	x.resize(2);
	x(0) = 1.27;
	x(1) = 0.68;
	r = kv::krawczyk_approx(h, x, ix, 3);
	if (r) std::cout << "Solution Found\n";
}
