标签:
#lang racket
(define (newton-transform g)
(define dx 0.00001)
(define (deriv g)
(lambda (x)
(/ (- (g (+ x dx)) (g x)) dx)
);lambda
);deriv
(lambda (x)
(- x (/ (g x) ((deriv g)x))));lambda
);newton-transform
(define (fixed-point f guess)
(define tolerance 0.00001);公差
(define (get-point x)
(let ((result (f x)))
(if (< abs(- result x) tolerance)
result
(get-point (/ (+ result x) 2))
);if
);let
);get-point
(get-point guess)
);fixed-point
(define (newtons-method g guess)
(fixed-point (newton-transform g) guess)
);newtons-method
标签:
原文地址:http://www.cnblogs.com/wizzhangquan/p/4391787.html