CSCI 4150: Introduction to Artificial Intelligence, Fall 2004

Exercise 0 Solution

(define (approx-pi N)
  (if (zero? N)
      4
      (+ (* 4 (/ (expt -1 N) (+ (* 2 N) 1)))
	 (approx-pi (- N 1)))))
Note that I've multiplied the 4 into the series.

By the way, this series converges very slowly to pi. (For N=300, you will only be accurate to 2 decimal places.) The series in A1p10 converges much quicker.