/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;

const int N(8); // Number of summands

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;
}

int main()
{
  picture(P(-2, 0), P(2, 1.5), "3.2 x 1.2in");

  begin();

  h_axis(2*xsize());
  v_axis(2*ysize());
  h_axis_labels(xsize(), P(-4,-8));
  
  blue();
  plot(cb, xmin() - 0.25, xmax()+0.25, 4*xsize() + 2);

  bold(Black());
  plot(weierstrass, xmin(), xmax(), pow(2,N));

  pen(Red());
  plot(weierstrass, 0.5, 1.5, pow(2,N-2));

  end();
}
