Blob
1 (defvar *tolerance* 0.0001)2 (defun fixed-point (f first-guess)3 (labels (4 (close-enough? (v1 v2)5 (< (abs (- v1 v2)) *tolerance*))6 (try (guess)7 (let ((next (funcall f guess)))8 (if (close-enough? guess next)9 next10 (try next)))))11 (try first-guess)))12 (defvar *dx* 0.00001)13 (defun deriv (g)14 (lambda (x)15 (/ (- (funcall g (+ x *dx*))16 (funcall g x))17 *dx*)))18 (defun newton-transform (g)19 (lambda (x)20 (- x (/ (funcall g x)21 (funcall (deriv g) x)))))