The built-in Mathematica operator D gives derivatives immediately without any intermediate steps. In this notebook the operators WalkD and RunD are defined to show each step so that a beginner can learn how to take derivatives. WalkD says what rule is used at each step, but RunD is in too much of a hurry for that.
These are all the rules for taking derivatives.
Step-by-step differentiation with each step explained
The defined function WalkD takes a derivative and tells you what rule it is using at each step. Expressions of the form d[y, x] mean dy/dx. Mathematica uses the command D[y, x] to take the derivative of y with respect to x without showing any intermediate steps.
You can check the result with the built-in differentiation function D.
D[Sin[x + Cos[x]], x]
Quiet step-by-step differentiation
RunD does the same thing as WalkD without telling you what rule is being used at each step.
Can you see which rules are being applied at each step? You can check with WalkD.
This triple chain is a symbolic example. Do you see the pattern at the end? Can you predict what the derivative of a chain of four functions will look like?
Step-by-step second derivatives
You can use WalkD and RunD twice (in any combination) to give the first derivative followed by the second derivative. You can also do the third derivative using triple combinations, and so on.
Again, you can check this with the built-in differentiation operator.
WalkD and RunD do one step after another until the derivative is completely worked out. You can do a single step of a differentiation by using the differentiation rules.
How to apply a rule
This is the format for only a single step in taking the derivative of an expression. The slash-dot (/.) means the rule will be used on the expression.
expression /. rule
In this example we substitute A for x.
The differentiation rules have the arrows already inside them.
If there is a sum first, use the linearity rule.
LinearityRule is two rules in one, the first is for sums of functions and the second is for terms with a constant multiplier. Recall that in Mathematica % means the previous result.
% /. LinearityRule
Now use the power rule.
% /. PowerRule
SpecificRules gives the derivatives of individual functions that are not combined in any way with other functions.
% /. SpecificRules
% /. PowerRule
You can do two steps at a time.
The built-in operator D outputs derivatives immediately in one step.
Here is the derivative done manually one step at a time.
% /. SpecificRules /. ChainRule
% /. PowerRule
You can use all the rules together. After the first step you can continue with l until the derivative is finished, that is, until there is no more d in the expression. It is a good exercise to say what rule is being used at each step.
The rule d[x_, x_] is repeated intentionally.
Drop the specific rules for generic cases.
Apply specific rules last when applying all at once.
Rule sets for applying the rules individually.