#include <fstream.h>
#include <iomanip.h>
#include <math.h>

// Chapter 2.3, p.79-80
// calculate x-sin(x) using a Taylor series expansion
template <class Type>
Type f(Type x)
{
	const int n = 10;
	int i;
	Type s, t;

	if ( fabs(x) >= 1.9) 
		s = x - sin(x);
	else
	{
		t = x * x * x /6.0;
		s = t;
		for (i = 2; i <= n; i++)
		{
			t = -t * x * x / (Type) ((2 * i + 2) * (2 * i + 3));
			s += t;
		}
	}
	return (s);
}

