## Sicp 2.1 2.3 Symbolic Differentiation

May 22, 2018

I plowed through sections 2.1-2.3 of SICP this past weekend, and my solutions are on Github for the exercises. The coolest topic in these sections was symbolic differentiation. In particular, exercise 2.58 covered a program that could compute derivatives of an expression, symbolically. For example, if you gave it an expression like:

``````3 * x * y + 4 + x + 9 * x * z
``````

and asked it to differentiate with respect to x, it would return:

``````((3 * y) + (1 + (9 * z)))
``````

Note that it can’t “simplify” some terms further - i.e. in some cases it might return `(3 * x) + (4 * x)` instead of `(7 * x)`, but that could possibly due to a limitation of my solution.

Anyways, some of my notes on these sections:

• The choice of representation of data can greatly simplify the code for an algorithm. For example, it took me a while to figure out a suitable representation for the n-queens problem in exercise 2.42, but once I thought of a simple representation, I worked out the solution pretty quickly.

• Thinking abstractly and naming variables appropriately help to organize your thoughts in a problem. I initially started off directly using cars and cdrs, but naming things using let greatly simplified the code. This sometimes leads to solutions that somehow work out on the first try.

• SICP would be tough for someone trying to learn to program for the first time. I’m enjoying it now, but it helps to have had some programming experience and mathematics knowledge.