1.29

secje posted @ 2010年7月06日 03:49 in sicp , 1426 阅读
(define (cube x) (* x x x))
(define (sum term a next b)
  (if (> a b)
      0
      (+ (term a)
         (sum term (next a) next b))))

(define (simpson f a b n)
  (define (get-h) (/ (- b a) n))
  (define (get-y k) (f (+ a (* k (get-h)))))
  (define (simpson-term k)
    (cond ((or (= k 0) (= k n)) (get-y k))
          ((even? k) (* 2.0 (get-y k)))
          (else (* 4.0 (get-y k)))))
  (define (simpson-next k) (+ k 1))
  (* (sum simpson-term 0 simpson-next n) (/ (get-h) 3.0)))

(define (integral f a b dx)
  (define (add-dx x) (+ x dx))
  (* (sum f (+ a (/ dx 2.0)) add-dx b)
     dx))

(simpson cube 0 1 10000)
(integral cube 0 1 0.0001)

 输出

0.2500000000000011

0.24999999874993412

simpson更准确点

 

Junior Dakil Result 说:
2022年8月27日 21:56

Comilla board is another education board working under Secondary and Higher Secondary Education, Bangladesh, and the education board is also successfully completed the Grade 8 terminal examinations at all selected examination test centers at Comilla division, and the Junior School Certificate and Junior Dakhil Certificate terminal examination is a second largest examination in the country. Junior Dakil Result Comilla Board The Comilla Board is also completed those subject wise exams between 1st to 3rd week of November as per schedule announced by School Education department, and there are a huge number of students are participated like as all other educational boards from all districts of the division, right now they are waiting to check JSC & JDC Result 2022 Comilla Board with subject wise marks and total marksheet with final CGPA grade of the student.

Brooke 说:
2023年7月10日 07:19

The code snippet you shared demonstrates the implementation of Simpson's rule and integral approximation. seo services cochin It's great to see such mathematical concepts being applied. Simpson's method provides a more accurate result compared to the integral approximation. Keep

civaget 说:
2023年12月07日 10:18

There are always 구글 상위노출 opportunities in your niche waiting to be discovered. Are you ready to seize them?

civaget 说:
2023年12月13日 02:09

휴식 is the key to harmony in our fast-paced lives, offering solace and rejuvenation to both body and mind.

civaget 说:
2023年12月19日 08:22

For a peaceful retreat, 김포휴게텔 is the place to be. The ambiance, cuisine, and skilled therapists make it truly outstanding.

civaget 说:
2023年12月26日 03:27

Experience the thrill of sports with 스포츠중계. The best streaming platform, bar none.

civaget 说:
2024年1月15日 03:43

i have a brother that is autistic and we love him so much and gave all of our support on him; ufaคืนยอดเสีย

boardmodelpaper.com 说:
2024年1月20日 05:30

Board Model Papers 2024 provide all states of 6th to 10th text books 2024 Candidates who are Searching for 6th to 10th and 11th to 12th text books and syllabus, sample questions, exam pattern, and Co-Curricular Subject textbooks can refer to this entire article. boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course. Here, we have gathered all subjects of Board textbooks for all Class along with the direct download links.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter