Question: need def derivate(e, x): doesn't matter if its in 15 lines need the assertion lines to pass Question 7: Implementation of derivative o dx (fog)
need def derivate(e, x):
doesn't matter if its in 15 lines
need the assertion lines to pass

Question 7: Implementation of derivative o dx (fog) .8+ f We now let you implement the derivative of a general expression. The function is recursive: for instance, if the expression is (*, f.g), to compute its derivative with respect to a variable x, we use: f g and so we need to recursively call symbolic derivation on the f and g sub-expressions, to obtain o fldx and dg/dx, and then produce and return an expression representing the result. Important: The code for checking expression equality is not able to cope with the commutativity of + and *. So, in your solution, please use exactly these forms: a dg (f + g) + Ox' f (fg) af g f .g-f g g2 af g and not, for instance, dan (f g) = g + f which is mathematically equivalent, but would be considered different by the tests. ! af g 8+ f do () = [53] ### Implement "derivate def derivate(e, x): """Returns the derivative of ewrt x. It can be done in less than 15 lines of code. """ ### YOUR CODE HERE [54] ### Tests for derivate for single-operator expressions. 4 points. == == 1 assert derivatel('+', 'x', 'x'), 'x') assert derivate( (' 4, 'x'), 'x') assert derivate leterhenxhenxh assert derivatel('/', 2, 'x'), 'x') ('+', 1, 1) 0, 1) dintienditenant henlinnan hanted ('/', ('-', ('*', 0, 'x'), ('*', 2, 1)), ('*', 'x', 'x')) == ==
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
