summaryrefslogtreecommitdiff
path: root/graphics/epix/samples/weierstrass.xp
blob: 2822b0737a1004e5ea8a95e847ea0faefd8f7fa8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* -*-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();
}