SICP Exercise 3.60 mul-series
Exercise 3.60. With power series represented as streams of coefficients as in exercise 3.59 , adding series is implemented by add-streams . Complete the definition of the following procedure for multiplying series: (define (mul-series s1 s2) (cons-stream < ?? > (add-streams < ?? > < ?? >))) You can test your procedure by verifying that s i n 2 x + c o s 2 x = 1, using the series from exercise 3.59 . SOLUTION Logic used in mul-series: (a0 + a1x + a2x^2 + a3x^3 + ...) * (b0 + b1x + b2x^2 + b3x^3 + ...) is: (a0 * b0) + {a0 * (b1x + b2x^2 + b3x^3 + ...)} + {b0 * (a1x + a2x^2 + a3x^3 + ...)} + {(a1x + a2x^2 + a3x^3 + ...) * (b1x + b2x^2 + b3x^3 + ...)} The coefficients after multiplying the two series above will be: Variable | Coefficient ------------------------------- x^0 | a0*b0 x^1 | a0*b1 + a1*b0 x^2 | a0*b2 + a1*b1 ...