#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
时间: 2024-10-12 16:36:15