It is vain to do with more what can be done with fewer.- William of Occam, 14th-century
The lyf so short, the craft so long to lerne.--- Chaucer
Use the trapezoidal rule, which means the two points at the end get 1/2 the weight that the ones in the middle do.
Eg (nintegrate exp 3.0 5.0 11) would calculate (exp 3.0), (exp 3.2), (exp 3.4), ..., (exp 4.8), (exp 5.0), and would add them all up (except only adding in half of (exp 3.0) and (exp 5.0) because they're at the ends), multiply by the step size (in this case 0.2) and return that result. To numerically integrate sin(x)/exp(x) between zero and 5, you could use (nintegrate (lambda (x) (/ (sin x) (exp x))) 0.0 5.0 100). To make ff the numeric indefinite integral of f, you could go
(define ff (lambda (x) (nintegrate f 0.0 x 1000)))
For a bit of extra credit, make a version nintegrate-s which uses Simpson's rule.
Eg
(nintegrate2 (lambda (x y) (* x (cos (+ x y)))) 10.1 12.2 20 1.0 10.0 30)would numerically calculate the integral of that function over the rectangular interval x=(10.1:12.2), y=(1.0:10.0), at the 20x30 array of points (ie x steps through 20 points, y steps through 30 points).
((lambda (f) (f f 100)) (lambda (g n) (if (= n 0) 1 (* n (g g (- n 1))))))