Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**Language is SCHEME (R5RS)** 6. Consider the problem of defining a function int

ID: 3889722 • Letter: #

Question

**Language is SCHEME (R5RS)**

6. Consider the problem of defining a function interval-sum so that (interval-sum m n) returns the sum of all the integers between m and n. (So, for example (interval-sum 10 12) should return the value 33 = 10+11+ 12.) One strategy is (define (interval-sum m n) (if (= mn) and another solution, which recurses the "other direction" is (define (interval-sum m n) (if (m n) (+ m (interval-sum (m 1) n)))) These both work. It seems like one should be able to combine these to produce another version: (define (interval-sum m n) (if (= mn) (interval- sum (+ m 1 (- n 1)) But this only works for certain pairs of input numbers. What's going on?

Explanation / Answer

More generally the ODE around a point x such that y(x)0 is equivalent to y/y2=12x, that is, (1/y)=(x2x). Hence, on every interval where y is defined and not identically zero, there exists a constant c such that y(x)=1/(x2x+c). The value of c depends on the initial condition one is given, hence the interval on which y

is defined also depends on the initial condition.

In your example, y(0)=1/6

, hence c=6, y(x)=1/(x2x6) and the maximal interval of definition around 0 is bounded by the roots of x2x6=(x+2)(x3) which are closest to 0, namely 2 and 3

.

But consider another example: if y(3)=1/8

, then c=20, y(x)=1/(x2x20) and the maximal interval of definition around 3 is bounded by the roots of x2x20=(x5)(x+4) which are closest to 3, hence this interval is (4,+5)

.

The interval can also be semi-infinite or infinite. For instance, if y(3)=1/15

, then c=3, y(x)=1/(x2x+3) and the maximal interval of definition around 3 is the real line (,+). If y(3)=1/12, then c=0, y(x)=1/(x2x) and the maximal interval of definition around 3 is the half line (,0).