6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology To do this, I am going to need a way of representing expressions, which I will do using lists. Thus the algebraic expression 3 I choose to represent as the list(+ x 3), that is a list of the symbol, +, the symbol, x, and the number 3. For base cases, I will just represent a variable by its symbol Products I will represent in a similar fashion. And given an expression involving more than two terms i will break into recursive pieces each of which involves at most two terms Thus, I am going to restrict my system to sums and products of at most two terms. I haven,'t said how to build the ystem, of course, but only how I am going to represent expressions in my system Symbolic differentiation Bide 8.3.2 (deriv <expr> swith-respecl-to-var) aa> snew-expr2 As we have already said, we would like to build a procedure deriv that takes as input some representation of an algebraic (+X3) expression, and a representation of the variable with respect to which we want to take the derivative. and returns a 5y) epresentation of the new expression that represents the (+x(+y3) derivative of that algebraic expression 4 Slide 8.3.3 mbolic differentiation So, for example, here is the behavior I would like. I would like (donly cepra owith-respece-tovarpy) -- snewexpn to differentiate x t 3 with respect to x and get back the Algebraic expression Representation value 1. Notice the use of the single quote to indicate that I want the list structure itself as the value of the argument, creating a representation of the algebraic expression. Thus, we want our system to take a symbolic algebraic expression input, and return a new symbolic algebraic expression as output, satisfying the rules of calculus +K3) Building a system for differentiation Slide. 3. 4 Example of To build this system, I am going to stitch together several idea I using lists of lists to represent expressions, using symbols to s, How to use the symbol type symbolic manipulation capture algebraic expressions, and using procedural abstractions to manipulate the list structures corresponding to those get started expressions. To build the system, I am going to consider several stages focusing on how to initially get things going, then how to build a direct implementation, and finally how to learn from the direct method to create a better implementation. Throughout we will see how these ideas of data structures and pi ocedure abstractions work together to implement this system6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. To do this, I am going to need a way of representing expressions, which I will do using lists. Thus the algebraic expression x + 3 I choose to represent as the list (+ x 3), that is a list of the symbol, +, the symbol, x, and the number 3. For base cases, I will just represent a variable by its symbol. Products I will represent in a similar fashion. And given an expression involving more than two terms I will break into recursive pieces each of which involves at most two terms. Thus, I am going to restrict my system to sums and products of at most two terms. I haven't said how to build the system, of course, but only how I am going to represent expressions in my system. Slide 8.3.2 As we have already said, we would like to build a procedure deriv that takes as input some representation of an algebraic expression, and a representation of the variable with respect to which we want to take the derivative, and returns a representation of the new expression that represents the derivative of that algebraic expression. Slide 8.3.3 So, for example, here is the behavior I would like. I would like to differentiate x + 3 with respect to x and get back the value 1. Notice the use of the single quote to indicate that I want the list structure itself as the value of the argument, creating a representation of the algebraic expression. Thus, we want our system to take a symbolic algebraic expression as input, and return a new symbolic algebraic expression as output, satisfying the rules of calculus. Slide 8.3.4 To build this system, I am going to stitch together several ideas, using lists of lists to represent expressions, using symbols to capture algebraic expressions, and using procedural abstractions to manipulate the list structures corresponding to those expressions. To build the system, I am going to consider several stages, focusing on how to initially get things going, then how to build a direct implementation, and finally how to learn from the direct method to create a better implementation. Throughout, we will see how these ideas of data structures and procedural abstractions work together to implement this system