In SICP section 3.5 the following procedure is given
(define (integral integrand initial-value dt)
(define int
(cons-stream
initial-value
(add-streams (scale-stream integrand dt)
int)))
int)
I understand how the procedure itself works but not how or why it finds the integral.
With some pseudocode mashup, it is
which is a stream of partial sums following the definition of an integral, calculating an approximation of the area beneath the function's curve by the rectangle rule, under the assumption that the consecutive values of the function,
ys, are taken at evenly spacedxvalues on the X axis atdtdistances between them, i.e. we havefor the function
foo(x), at any valid indexk.So we don't actually have the actual
xcoordinates, as we just assume they are evenly spaced in our representation of functions as streams of theiryvalues.