Invert-unit-series procedure

Let S be a power series (exercise 3.59 ) whose constant term is 1 . Suppose we want to find the power series 1/S , that is, the series X such that S · X = 1 . Write S = 1 + SR where SR is the part of S after the constant term. Then we can solve for X as follows:

3.61

In other words, X is the power series whose constant term is 1 and whose higher-order terms are given by the negative of SR times X . Use this idea to write a procedure invert-unit-series that computes 1/S for a power series S with constant term 1 . You will need to use mul-series from exercise 3.60


There are no comments yet.

Authentication required

You must log in to post a comment.

Login
(define (stream-car stream) (car stream))

(define (stream-cdr stream) (force (cdr stream)))

define (stream-ref s n)
  (if (= n 0)
      (stream-car s)
      (stream-ref (stream-cdr s) (- n 1))))

(define (stream-map proc . list-of-stream)
    (if (null? (car list-of-stream))
        '()
        (cons-stream
            (apply proc 
                   (map (lambda (s)
                            (stream-car s))
                        list-of-stream))
            (apply stream-map 
                   (cons proc (map (lambda (s)
                                       (stream-cdr s))
                                   list-of-stream))))))

(define (scale-stream stream factor)
  (stream-map (lambda (x) (* x factor)) stream))

(define (add-streams s1 s2)
  (stream-map + s1 s2))

(define (mul-streams s1 s2)
    (stream-map * s1 s2))

(define (div-streams s1 s2)
    (stream-map / s1 s2))

(define ones (cons-stream 1 ones))

(define integers (cons-stream 1 (add-streams ones integers)))



(define exp-series
  (cons-stream 1 (integrate-series exp-series)))

(check-equal? (stream-ref (invert-unit-series exp-series) 0) 1)
(check-equal? (stream-ref (invert-unit-series exp-series) 1) -1)
(check-equal? (stream-ref (invert-unit-series exp-series) 2) 1/2)