compute method

dynamic compute()

Implementation

dynamic compute() {
  // Check for indeterminate forms
  if (function.isIndeterminate(point)) {
    try {
      return _applyLHopitalsRule();
    } catch (e) {
      return _numericalApproach(); // Fallback to a numerical approach
    }
  }

  if (direction == 'left') {
    return _leftLimit();
  } else if (direction == 'right') {
    return _rightLimit();
  } else {
    dynamic left = _leftLimit();
    dynamic right = _rightLimit();
    if (left == right) {
      return left;
    } else {
      throw Exception('Limit does not exist');
    }
  }
}