2 * From Handbook of Floating-Point Arithmetic
3 * Program 1.1 "A sequence that seems to converge to a wrong limit"
4 * Modified to work with a template type and then print the results for our favourite types
5 * I know it is O(N^2) when it should be O(N), but in terms of amount of typing it is O(much nicer this way for small values of N)
14 template <class T> T s(T u, T v, int max)
17 for (int i = 3; i <= max; i++)
19 w = T(111.) - T(1130.)/v + T(3000.)/(v*u);
30 printf("#n\tfloat\tdouble\tlong\tReal\n");
31 for (int i = 3; i <= 30; ++i)
33 printf("%d\t%.15f\t%.15lf\t%.15llf\t%.15lf\n", i,
34 s<float>(u0,u1,i), s<double>(u0,u1,i), s<long double>(u0,u1,i), Float(s<Real>(u0,u1,i)));