#include <fstream.h>
#include <iomanip.h>
#include <math.h>

typedef double runtype;

// Chapter 1.1, p.13
void main()
{
	const int n = 10;
	int i;
	runtype error, x, h, y;

	x = 0.5;
	h = 1.0;
	cout << setw(5) << "i" << setw(15) << "h" << setw(15) << "y";
	cout << setw(15) << "error" << endl;
	cout << "--------------------------------------------------" << endl;
	for (i = 1; i <= n; i++)
	{
		h *= 0.25;
		y = (sin (x + h) - sin (x)) / h;
		error = fabs(cos(x) - y);
		cout << setw(5) << i << setw(15) << h << setw(15) << y;
		cout << setw(15) << error << endl;
	}
}
