## Sine Waves

Plots values extracted from a program which generates coordinates for a single sine wave.

### `sine/sine.ss`

```(module sine mzscheme
(define (run)
(let loop ([x -200])
(let ([sin-x (sin (/ x 20.0))])
(if (x . < . 200)
(loop -200)))))
(run))```

### `sine/sine-mztake.ss`

```(require (lib "animation.ss" "frtime"))

(define-mztake-process p ("sine.ss" [x/sinx-trace 5 8 bind '(x sin-x)]))

(define x/sinx (hold x/sinx-trace))

(define x     (first x/sinx))
(define sin-x (second x/sinx))

(printf-b "x: ~a" x)
(printf-b "sin(x/20): ~a" sin-x)

(printf-b "largest  x: ~a  sin(x/20): ~a"
(largest-val-b (changes (first x/sinx)))
(largest-val-b (changes (second x/sinx))))

(printf-b "smallest x:~a  sin(x/20):~a"
(smallest-val-b (changes (first x/sinx)))
(smallest-val-b (changes (second x/sinx))))

(display-shapes
(list* (make-line (make-posn 0 200) (make-posn 400 200) "gray")
(make-line (make-posn 200 0) (make-posn 200 400) "gray")

(let ([x (+ 200 x)]
[sin-x (+ 200 (* 100 sin-x))])
(history-b 50 (changes (make-circle
(make-posn x sin-x)
5
(if (< 200 sin-x)
(if (< 200 x) "blue" "darkblue")      #| Quadrants 3 and 4 |#
(if (< 200 x) "red" "darkred")))))))) #|           1 and 2 |#

(start/resume p)```