2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -7,8 +7,8 @@
|
|||
(defun euler (f y0 a b h)
|
||||
|
||||
;; Set the initial values and increments of the iteration variables.
|
||||
(do ((t a (incf t h))
|
||||
(y y0 (incf y (* h (funcall f t y)))))
|
||||
(do ((t a (+ t h))
|
||||
(y y0 (+ y (* h (funcall f t y)))))
|
||||
|
||||
;; End the iteration when t reaches the end b of the time interval.
|
||||
((>= t b) 'DONE)
|
||||
13
Task/Euler-method/Common-Lisp/euler-method-2.lisp
Normal file
13
Task/Euler-method/Common-Lisp/euler-method-2.lisp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
;; slightly more idiomatic Common Lisp version
|
||||
|
||||
(defun newton-cooling (time temperature)
|
||||
"Newton's cooling law, f(t,T) = -0.07*(T-20)"
|
||||
(declare (ignore time))
|
||||
(* -0.07 (- temperature 20)))
|
||||
|
||||
(defun euler (f y0 a b h)
|
||||
"Euler's Method.
|
||||
Approximates y(time) in y'(time)=f(time,y) with y(a)=y0 and t=a..b and the step size h."
|
||||
(loop for time from a below b by h
|
||||
for y = y0 then (+ y (* h (funcall f time y)))
|
||||
do (format t "~6,3F ~6,3F~%" time y)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue