# Approximating computation of the derivative number: nDeriv

### 10.3.2 Approximating computation of the derivative number: nDeriv

The nDeriv command numerically approximates the value of a derivative.

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

  f(var+h)−f(var−h)
  2h

#### Examples.

- Input:
  nDeriv(x^2,x)
  Output:

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

- Input:
  subst(nDeriv(x^2,x),x=1)
  Output:

  2.0

- Input:
  nDeriv(exp(x^2),x,0.00001)
  Output:

  ⎛
  ⎜
  ⎝

  e

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

  −e

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

  ⎞
  ⎟
  ⎠

  · 50000.0

- Input:
  subst(exp(nDeriv(x^2,x,0.00001)),x=1)
  Output:

  7.38905609706

  which is an approximate value of e2≈ 7.38905609893.