#include "library.h" int factorial(int n) { if (n <= 0) return 1; return n * factorial(n - 1); } double f(double x) { const double u = x/50; const double v = u - pow(u, 3)/factorial(3) + pow(u, 5)/factorial(5) - pow(u, 7)/factorial(7) + pow(u, 9)/factorial(9) - pow(u, 11)/factorial(11); return 350 + 250 * v; } double g(double x) { return 350 + 250 * sin(x/50); } void tabulate(int N, int Last, double thefunction(double)) { if (N <= Last) { const double y = thefunction(N); print("N = "); print(N); print(", y = "); print(y); new_line(); draw_to((double)N, y); tabulate(N + 1, Last, thefunction); } } void main() { make_window(700, 700); set_pen_width(2); move_to(0.0, f(0)); tabulate(0, 700, f); set_pen_color(color::red); move_to(0.0, g(0)); tabulate(0, 700, g); }