#lang racket
(require plot (only-in srfi/41 stream-map))
(plot-new-window? #t)
(define-values (*m* *k* *dt*) (values 1 10 0.01))
(define *v*
(stream-cons 0
(stream-map (lambda (v x)
(- v (* (/ *k* *m*) x *dt*))) *v* *x*)))
(define *x*
(stream-cons 1
(stream-map (lambda (x v)
(+ x (* v *dt*))) *x* (stream-rest *v*))))
(define *xs* (stream->list (stream-take *x* 500)))
(define *ts* (map (lambda (x) (* x *dt*)) (range 500)))
(plot (lines (map vector *ts* *xs*))
#:x-label "t" #:y-label "x" #:title "t-x")
I2xhbmcgcmFja2V0CgoocmVxdWlyZSBwbG90IChvbmx5LWluIHNyZmkvNDEgc3RyZWFtLW1hcCkpCihwbG90LW5ldy13aW5kb3c/ICN0KQoKKGRlZmluZS12YWx1ZXMgKCptKiAqayogKmR0KikgKHZhbHVlcyAxIDEwIDAuMDEpKQoKKGRlZmluZSAqdioKICAoc3RyZWFtLWNvbnMgMAogICAgICAgICAgICAgICAoc3RyZWFtLW1hcCAobGFtYmRhICh2IHgpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKC0gdiAoKiAoLyAqayogKm0qKSB4ICpkdCopKSkgKnYqICp4KikpKQoKKGRlZmluZSAqeCoKICAoc3RyZWFtLWNvbnMgMQogICAgICAgICAgICAgICAoc3RyZWFtLW1hcCAobGFtYmRhICh4IHYpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKCsgeCAoKiB2ICpkdCopKSkgKngqIChzdHJlYW0tcmVzdCAqdiopKSkpCgooZGVmaW5lICp4cyogKHN0cmVhbS0+bGlzdCAoc3RyZWFtLXRha2UgKngqIDUwMCkpKQooZGVmaW5lICp0cyogKG1hcCAobGFtYmRhICh4KSAoKiB4ICpkdCopKSAocmFuZ2UgNTAwKSkpCihwbG90IChsaW5lcyAobWFwIHZlY3RvciAqdHMqICp4cyopKQogICAgICAjOngtbGFiZWwgInQiICM6eS1sYWJlbCAieCIgIzp0aXRsZSAidC14Iik=