/* -*-ePiX-*- */ /* weierstrass.xp -- April 02, 2003 */ #include using namespace ePiX; const int N = 8; // Number of summands /* "cb" is the Charlie Brown function, see functions.cc */ double weierstrass(double t) { double y=0; for(int i=0; i < N; ++i) y += pow(2,-i)*cb(pow(2,i)*t); return y; } main() { bounding_box(P(-2, -0.5), P(2, 1.5)); picture(300, 150); unitlength("0.015in"); begin(); h_axis(8); v_axis(4); h_axis_masklabels(x_size, P(0,-4), b); blue(); plot(cb, x_min - 0.25, x_max+0.25, 4*x_size + 2); bold(); black(); plot(weierstrass, x_min, x_max, pow(2,N)); red(); plot(weierstrass, 0.5, 1.5, pow(2,N-2)); end(); }