Exercise 3.62

(define (div-series num denom)
  (let ((denom-const (stream-car denom)))
    (if (zero? denom-const)
        (error ("DIV-SERIES -- denominator constant term must be non-zero" ))
        (mul-series num 
                    (scale-stream ; restore the scaling factor 
                     (invert-unit-series  ; requires a stream that has a unit constant term
                      (scale-stream denom (/ 1 denom-const)))
                     denom-const)))))

(define tan-series (div-series sine-series 
                               cosine-series))

(show-stream tan-series 10)
0
-1
0
-1/3
0
-2/15
0
-17/315
0
-62/2835
done

I’ve no idea how I can really test these values or whether they’re correct or not.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s