For simplicity, consider the area enclosed by the line y = 1 and the parabola y = x ^ 2. Archimedes concluded that the bounded area is 4/3 times the area of an inscribed triangle (imagine a triangle from 0,0 to 1,1 to -1,1). In his proof, Archimedes showed that the infinite series 1/1 + 1/4 + 1/16 + 1/64... converged to 4/3. We can express this as the summation from 1 to infinity of the function 1 / (4 ^ (n - 1)).

To express this in Clojure, we first need to define a power function. We could use Math/pow from Java but Greeks didn't have a double. So we will define a simple power function that operates with rationals, with the power argument restricted to being a whole number.

(defn power [i n] (apply * (replicate n i)))

Note that (power 4 0) does the right thing because (apply * nil) returns 1.

Next, we define a function to express one term in the series:

(defn one-term [n] (/ 1 (power 4 (dec n))))

We also need a general summation function:

(defn summation [from to f] (apply + (map f (range from (inc to)))))

Test it with:

(summation 1 10 (fn [x] x)) => 55.

One of the benefits of a lambda calculus based language, such as Clojure, is that we can pass an unapplied function (e.g., one-term) as data in the third argument to summation.

Finally, we define a function called area-parabola:

(defn area-parabola [base height] (* (/ (* base height) 2) (summation 1 100 one-term)))

I use 100 as the upper range because it is good enough and my computer doesn't do infinity well. The answer comes back as a rational number with a very large numerator and denominator due to Clojure repeatedly finding the least common denominator during each iteration. Cast the result as a double in order to see it in decimal notation. Our original problem defined by the line y = 1 and the parabola y = x ^ 2, inscribes a triangle with a base of 2 and a height of 1, (i.e., an area of 1). Therefore, the answer is:

(double (area-parabola 2 1)) => 1.3333333333, which is approximately 4/3.

What was the mechanism that Archimedes used to conclude that the answer was 4/3? He did not divide some large numerator by a large denominator, nor did he add up smaller and smaller decimals. He proved it geometrically. I tried to go through an 1897 translation of his proof but I didn't make it. I cheated and took a look at Proposition 24 at the end where he concludes that the answer can't be greater than 4/3 or less than 4/3.

In 1906, a hidden document authored by Archimedes was found in a monastery in Constantinople. Entitled "The Method", some argue that it describes the essence of what would be called integral calculus, over 1800 years later.

## No comments:

Post a Comment