8.10

### Lecture 29: Neural networks

This assignment is due on Sunday, December 3 at 11:59pm. Submit it using Handin as assignment lecture29. You only need to submit the first exercise.

Watch the first 10 minutes of the following video.
Here’s the data definition for a Formula:
 ; A Formula is one of: ; - Number ; - "x" ; - (make-add Formula Formula) ; - (make-mul Formula Formula) (define-struct add [first second]) (define-struct mul [first second])
For example, x²+2x+1 is represented by this Formula:

Exercise 1. Design a function eval that takes a formula and a value for x, and returns the value of the formula at that x.
 (check-expect (eval formula1 10) 121)
Hint: The template for processing a Formula can use the built-in functions number? and string?.

For the rest of this page, you don’t need to submit anything.

Exercise 2. Computers can do calculus for us! Design a function dx that takes a formula and returns another formula that is the derivative of the given formula.
 (check-expect (eval (dx formula1) 10) 22)
Hint: Handle the mul case using the product rule.