# discretize.Tests.checkDerivative¶

discretize.Tests.checkDerivative(fctn, x0, num=7, plotIt=True, dx=None, expectedOrder=2, tolerance=0.85, eps=1e-10, ax=None)[source]

Basic derivative check

Compares error decay of 0th and 1st order Taylor approximation at point x0 for a randomized search direction.

Parameters: fctn (callable) – function handle x0 (numpy.ndarray) – point at which to check derivative num (int) – number of times to reduce step length, h plotIt (bool) – if you would like to plot dx (numpy.ndarray) – step direction expectedOrder (int) – The order that you expect the derivative to yield. tolerance (float) – The tolerance on the expected order. eps (float) – What is zero? bool did you pass the test?!
from discretize import Tests, utils
import numpy as np

def simplePass(x):
return np.sin(x), utils.sdiag(np.cos(x))
Tests.checkDerivative(simplePass, np.random.randn(5))