Wolfram Language

Symbolic & Numeric Calculus

Evaluate a Derivative Using First Principles

Difference quotients can be used directly to compute not only the first derivative, but higher-order derivatives as well. Consider first the function g and its associated difference quotient.

In[1]:=
Click for copyable input
g[x_] := x^2 Exp[x]
In[2]:=
Click for copyable input
dq1[x_] = DifferenceQuotient[g[x], {x, h}]
Out[2]=

Taking the limit of the difference quotient gives the first derivative.

In[3]:=
Click for copyable input
Limit[dq1[x], h -> 0]
Out[3]=
In[4]:=
Click for copyable input
Limit[dq1[x], h -> 0]; Simplify[% == g'[x]]
Out[4]=

The second derivative can be computed directly from the second difference quotient, without ever referencing the first derivative.

In[5]:=
Click for copyable input
dq2[x_] = DifferenceQuotient[g[x], {x, 2, h}]
Out[5]=

The limit as is the second derivative.

In[6]:=
Click for copyable input
Limit[dq2[x], h -> 0]
Out[6]=
In[7]:=
Click for copyable input
Limit[dq2[x], h -> 0]; Simplify[% == g''[x]]
Out[7]=

The difference quotient of the first derivative is a different function from the second-order difference quotient of g, but its limit is also the second derivative.

In[8]:=
Click for copyable input
dqp[x_] = DifferenceQuotient[g'[x], {x, h}]
Out[8]=
In[9]:=
Click for copyable input
Limit[dqp[x], h -> 0]
Out[9]=

Related Examples

de es fr ja ko pt-br ru zh