Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
(defun left-rectangle (f a b n &aux (d (/ (- b a) n)))
|
||||
(* d (loop for x from a below b by d summing (funcall f x))))
|
||||
|
||||
(defun right-rectangle (f a b n &aux (d (/ (- b a) n)))
|
||||
(* d (loop for x from b above a by d summing (funcall f x))))
|
||||
|
||||
(defun midpoint-rectangle (f a b n &aux (d (/ (- b a) n)))
|
||||
(* d (loop for x from (+ a (/ d 2)) below b by d summing (funcall f x))))
|
||||
|
||||
(defun trapezium (f a b n &aux (d (/ (- b a) n)))
|
||||
(* (/ d 2)
|
||||
(+ (funcall f a)
|
||||
(* 2 (loop for x from (+ a d) below b by d summing (funcall f x)))
|
||||
(funcall f b))))
|
||||
|
||||
(defun simpson (f a b n)
|
||||
(loop with h = (/ (- b a) n)
|
||||
with sum1 = (funcall f (+ a (/ h 2)))
|
||||
with sum2 = 0
|
||||
for i from 1 below n
|
||||
do (incf sum1 (funcall f (+ a (* h i) (/ h 2))))
|
||||
do (incf sum2 (funcall f (+ a (* h i))))
|
||||
finally (return (* (/ h 6)
|
||||
(+ (funcall f a)
|
||||
(funcall f b)
|
||||
(* 4 sum1)
|
||||
(* 2 sum2))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue