### 23.2.1 Approximating derivatives

The nDeriv command numerically approximates the value of a derivative.

- nDeriv takes as arguments:
  - expr, expression.
  - Optionally, x, the variable used in the expression (by default x).
  - Optionally, h (by default 0.001).
- nDeriv(ex⟨,x,h⟩) returns an approximated value of the derivative of the expression ex at the point x using the formula:

  f(x+h)−f(x−h)
  2h

For a more general command on numeric differentiation, see Section 13.2.4.

#### Examples

nDeriv(x^2,x)

| ⎛ ⎝ | ⎛ ⎝ | x+0.001 | ⎞ ⎠ | 2− | ⎛ ⎝ | x−0.001 | ⎞ ⎠ | 2 | ⎞ ⎠ | · 500.0

subst(nDeriv(x^2,x),x=1)

2.0 |  |  |  |  |  |  |  |  |  |

nDeriv(exp(x^2),x,0.00001)

⎛
⎜
⎝

e

⎛ ⎝ | x+1.0×10−5 | ⎞ ⎠ | 2

−e

⎛ ⎝ | x−1.0×10−5 | ⎞ ⎠ | 2

⎞
⎟
⎠

· 50000.0

subst(exp(nDeriv(x^2,x,0.00001)),x=1)

7.38905609706 |  |  |  |  |  |  |  |  |  |

which is an approximate value of e2≈ 7.38905609893.