evaluateDerivativeOn method

num evaluateDerivativeOn(
  1. double x
)

Evaluates the derivative of the function on the given x value.

Implementation

num evaluateDerivativeOn(double x) {
  // Setting the precision to 1.0e-15
  final h = math.pow(1.0e-15, 1 / 3) * x;

  final upper = evaluateOn(x + h);
  final lower = evaluateOn(x - h);

  return (upper - lower) / (h * 2);
}