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
37
|
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;
const int N(12); // Number of rectangles
// gather references to integrand
double f(double t)
{
return Sin(t);
}
int main()
{
picture(P(0,0), P(3,1), "3x1in");
begin();
const double dx(xsize()/N);
riemann_sum(f, xmin(), xmax(), N, UPPER);
fill(Black(0.1));
riemann_sum(f, xmin(), xmax(), N, LOWER);
nofill();
h_axis(xsize());
v_axis(2*ysize());
h_axis_labels(xsize(), P(0,-4), b);
label(P(2, f(2)), P(4,2), "$y=\\sin x$", tr);
bold(Blue());
plot(f, xmin(), xmax(), 40);
end();
}
|