#include "library.h" double func(const double x) { const double w = x*x*x/1000000.0; return (cos(w)/(x+1.0))*10000.0+250.0; } double other(const double x) { const double w = x*x/10000.0; return (sin(w)/(x+0.5))*10000.0+250.0; } void plot(double f(const double x), const double x0, const double x1) { if (x1-x0 < 1.0) { const double y0 = f(x0), y1 = f(x1); move_to(x0, y0); draw_to(x1, y1); } else { const double xm = (x0+x1)/2; plot(f, x0, xm); plot(f, xm, x1); } } void main() { make_window(500, 500); set_pen_width(3); set_pen_color(color::blue); plot(func, 0.0, 500.0); set_pen_color(color::red); plot(other, 0.0, 500.0); }