灯下 登录
计算机科学 / SICP / 2.3.2 Example: Symbolic Differentiation

Exercise 2.57 · 习题

Exercise 2.57: Extend the differentiation
program to handle sums and products of arbitrary numbers of (two or more)
terms. Then the last example above could be expressed as

(deriv '(* x y (+ x 3)) 'x)

Try to do this by changing only the representation for sums and products,

without changing the deriv procedure at all. For example, the

addend of a sum would be the first term, and the augend would be

the sum of the rest of the terms.

练习 2.57:将微分程序扩展到能处理任意项数(两项或更多)的和式与积式。这样,上面最后一个示例就可以写成

(deriv '(* x y (+ x 3)) 'x)

尝试仅通过改变和式与积式的表示,而完全不改变 deriv 过程本身来完成这一任务。例如,和式的被加数 (addend) 是第一项,加数 (augend) 是其余各项之和。

Racket #lang sicp
(deriv '(* x y (+ x 3)) 'x)