Simplifying Difference Quotients
In this example, we demonstrate how to use Python to simplify difference quotients, allowing us to see how to compute the derivative of a function from the limit definition. Suppose we wish to use the limit definition to find the derivative of f(x) = 1/x^3. Since the limit definition uses h as well as x, we define both to be symbolic variables. Now we use the process described in an earlier video: list the steps to solve by hand, then determine the Python command(s) needed to perform these steps. To do this by hand, we need to:
1) Define our difference quotient ( f(x+h) - f(x) ) / h.
2) Simplify the expression
3) Substitute h = 0 into our simplified expression
Of course, we could just take the derivative using the diff command, or after STEP 1 take the limit using the limit command, but the purpose of a problem like this is to help us understand the “by hand” process so we can be prepared for it on quizzes or exams-maybe even help you figure out where you made a mistake by hand! For STEP 1, we evaluate a function by substituting in for x, so we use the subs command. For STEP 2, we can rewrite expressions using the factor, expand, or simplify commands, and for STEP 3, we will again use the subs command. Looking at our result from STEP 1, if we try the simplify command for STEP 2, we obtain an error when we substitute in STEP 3. We get a similar result if we try the expand command for STEP 2. BUT if we combine the two methods: expand, THEN simplify, we are able to substitute 0 in for h in STEP 3. Sometimes if we want our expression to look “right”, we may have to use some combination of the expand, factor, and simplify commands.