Skip to main content

Numerical Differentiation Ontology

Numerical Calculus
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 24 September 2026
Audio Overview
flow "NumericalDifferentiationOntology" v1.0

# ============================================================
# NUMERICAL DIFFERENTIATION ONTOLOGY — FLOW ALGEBRA
# ============================================================

SOURCE_URL := "https://kirethresearch.org/booksai-core/ontologies/calculus-analysis-ontologies/numerical-calculus/numerical-differentiation-ontology-3.html"
DOMAIN := "Mathematical Ontologies"
CATEGORY := "Calculus and Analysis Ontologies"
SUBCATEGORY := "Numerical Calculus"
ENTITY := "Numerical Differentiation"

# ---------- CORE ENTITY ----------
NUMERICAL_DIFFERENTIATION := {
    type: NumericalDerivativeApproximation,
    domain: NumericalCalculus,
    purpose: "Approximate derivatives of functions from sampled or computable function values using finite-difference, interpolation and related numerical methods."
}

# ---------- CORE CONCEPTS ----------
CONCEPTS := {
    DERIVATIVE,
    NUMERICAL_DERIVATIVE,
    FINITE_DIFFERENCE,
    FORWARD_DIFFERENCE,
    BACKWARD_DIFFERENCE,
    CENTRAL_DIFFERENCE,
    STEP_SIZE,
    GRID,
    TRUNCATION_ERROR,
    ROUNDING_ERROR,
    CANCELLATION_ERROR,
    ORDER_OF_ACCURACY,
    RICHARDSON_EXTRAPOLATION,
    INTERPOLATION,
    HIGHER_DERIVATIVE
}

# ---------- DERIVATIVE TARGET ----------
target:

f_prime(x)
    =
lim_(h->0)(
    [
        f(x+h)-f(x)
    ]/h
)

NUMERICAL_DIFFERENTIATION
    -> replaces(LIMIT_WITH_FINITE_NONZERO_STEP)

# ---------- GRID ----------
x_i
    :=
x_0 + i*h

h
    -> GRID_SPACING

function_samples:
    f_i
        := f(x_i)

FINITE_DIFFERENCE
    -> combines(NEARBY_SAMPLES)

# ---------- FORWARD DIFFERENCE ----------
D_plus_h f(x)
    :=
[
    f(x+h)-f(x)
]/h

f_prime(x)
    approx
D_plus_h f(x)

using Taylor expansion:

f(x+h)
    =
f(x)
+
h*f_prime(x)
+
h^2/2*f_double_prime(x)
+
O(h^3)

therefore

D_plus_h f(x)
    =
f_prime(x)
+
h/2*f_double_prime(x)
+
O(h^2)

FORWARD_DIFFERENCE_ERROR
    -> O(h)

# ---------- BACKWARD DIFFERENCE ----------
D_minus_h f(x)
    :=
[
    f(x)-f(x-h)
]/h

f_prime(x)
    approx
D_minus_h f(x)

BACKWARD_DIFFERENCE_ERROR
    -> O(h)

BACKWARD_DIFFERENCE
    -> useful_near(RIGHT_BOUNDARY)

# ---------- CENTRAL DIFFERENCE ----------
D_0_h f(x)
    :=
[
    f(x+h)-f(x-h)
]/(2*h)

Taylor cancellation
    -> eliminates(EVEN_LEADING_TERMS)

D_0_h f(x)
    =
f_prime(x)
+
h^2/6*f_triple_prime(x)
+
O(h^4)

CENTRAL_DIFFERENCE_ERROR
    -> O(h^2)

CENTRAL_DIFFERENCE
    -> second_order_first_derivative_approximation

# ---------- SECOND DERIVATIVE ----------
f_double_prime(x)
    approx

[
    f(x+h)
    -
    2*f(x)
    +
    f(x-h)
]/h^2

SECOND_DERIVATIVE_CENTRAL_ERROR
    -> O(h^2)

SECOND_DIFFERENCE
    -> discrete_curvature_measure

# ---------- HIGHER DERIVATIVES ----------
HIGHER_DERIVATIVE
    -> approximated_by(LARGER_FINITE_DIFFERENCE_STENCIL)

general form:

f^(m)(x)
    approx
1/h^m
*
sum_j(
    c_j
    *
    f(x+j*h)
)

coefficients
    c_j

-> chosen_to_match(TAYLOR_SERIES_TERMS)

# ---------- STENCIL ----------
STENCIL
    := set_of(GRID_OFFSETS_USED_IN_FORMULA)

examples:

forward:
    {0,1}

central first derivative:
    {-1,1}

central second derivative:
    {-1,0,1}

STENCIL
    -> determines(LOCAL_DATA_DEPENDENCE)

# ---------- HIGHER-ORDER CENTRAL FORMULA ----------
example first derivative:

f_prime(x)
    approx

[
    f(x-2h)
    -
    8*f(x-h)
    +
    8*f(x+h)
    -
    f(x+2h)
]
/
(12*h)

error
    -> O(h^4)

WIDER_STENCIL
    -> may_increase(ORDER_OF_ACCURACY)

# ---------- UNEQUALLY SPACED DATA ----------
if
    x_i
        -> NONUNIFORM_GRID

then

STANDARD_EQUAL_SPACING_FORMULAS
    -/> directly_valid

NUMERICAL_DERIVATIVE
    -> derive_from(INTERPOLATION_OR_GENERAL_FINITE_DIFFERENCE_WEIGHTS)

NONUNIFORM_GRID
    -> requires(NODE_DEPENDENT_COEFFICIENTS)

# ---------- INTERPOLATION DIFFERENTIATION ----------
construct interpolating polynomial

P(x)

through sampled points

then

f_prime(x)
    approx
P_prime(x)

INTERPOLATION
    -> generates(DIFFERENTIATION_FORMULAS)

LAGRANGE_INTERPOLATION
    -> derivative_weights

NEWTON_INTERPOLATION
    -> derivative_approximations_from(DIVIDED_DIFFERENCES)

# ---------- FINITE DIFFERENCE WEIGHTS ----------
for arbitrary nodes

x_j

seek weights
    w_j

such that

f^(m)(x0)
    approx
sum_j(
    w_j*f(x_j)
)

WEIGHTS
    -> chosen_for(POLYNOMIAL_EXACTNESS_TO_DESIRED_ORDER)

# ---------- TRUNCATION ERROR ----------
TRUNCATION_ERROR
    -> caused_by(OMITTED_HIGHER_TAYLOR_TERMS)

if method order
    p

then

E_trunc
    approx
C*h^p

for sufficiently small h
and smooth f

ORDER_OF_ACCURACY
    -> p

# ---------- ROUNDING ERROR ----------
floating_point_function_values
    -> contain(ROUNDING_ERROR)

difference

f(x+h)-f(x)

for small h
    -> subtracts(NEARLY_EQUAL_NUMBERS)

CANCELLATION
    -> amplifies(RELATIVE_FLOATING_POINT_ERROR)

ROUNDING_COMPONENT
    -> often_scales_like(epsilon_machine/h)
       for basic first differences

# ---------- STEP-SIZE TRADEOFF ----------
TOTAL_ERROR(h)
    approx
C_1*h^p
+
C_2*epsilon_machine/h^q

where
    q depends_on(method_and_derivative_order)

decrease(h)
    -> decreases(TRUNCATION_ERROR)

but

decrease(h_too_far)
    -> increases(ROUNDING_ERROR)

OPTIMAL_H
    -> balances(ERROR_SOURCES)

# ---------- ERROR CURVE ----------
large_h
    -> truncation_dominated

intermediate_h
    -> minimum_total_error_region

very_small_h
    -> floating_point_dominated

NUMERICAL_DIFFERENTIATION
    -> sensitive_to(STEP_SIZE_SELECTION)

# ---------- RICHARDSON EXTRAPOLATION ----------
if

D(h)
    =
f_prime(x)
+
C*h^p
+
O(h^(p+r))

and

D(h/2)
    =
f_prime(x)
+
C*(h/2)^p
+
...

then

D_R
    :=
[
    2^p*D(h/2)
    -
    D(h)
]
/
(
    2^p-1
)

RICHARDSON_EXTRAPOLATION
    -> cancels(LEADING_TRUNCATION_ERROR)

# ---------- NOISY DATA ----------
if samples

f_i
    =
true_f_i
+
noise_i

then

DIFFERENTIATION
    -> amplifies(HIGH_FREQUENCY_NOISE)

NUMERICAL_DERIVATIVE_OF_NOISY_DATA
    -> potentially_unstable

regularisation_options:
    SMOOTHING
    LOCAL_POLYNOMIAL_FIT
    SPLINES
    SAVITZKY_GOLAY
    REGULARISED_DIFFERENTIATION

# ---------- SAVITZKY-GOLAY ----------
LOCAL_POLYNOMIAL_REGRESSION
    -> fit(DATA_WINDOW)

differentiate
    fitted_polynomial

SAVITZKY_GOLAY
    -> combines(SMOOTHING_AND_DERIVATIVE_ESTIMATION)

NOISE_HANDLING
    -> depends_on(WINDOW_AND_POLYNOMIAL_ORDER)

# ---------- SPLINE DIFFERENTIATION ----------
data
    -> fit(SPLINE)

then

differentiate(SPLINE)

SPLINE_DERIVATIVE
    -> smooth_numerical_derivative_estimate

BOUNDARY_BEHAVIOUR
    -> depends_on(SPLINE_BOUNDARY_CONDITIONS)

# ---------- COMPLEX-STEP METHOD ----------
for analytic real-valued function extended appropriately to complex arguments:

f_prime(x)
    approx
Im(
    f(x+i*h)
)/h

with suitable assumptions

COMPLEX_STEP
    -> avoids(SUBTRACTIVE_CANCELLATION_OF_BASIC_FINITE_DIFFERENCE)

error
    -> O(h^2)
       for basic complex-step formula

COMPLEX_STEP
    -> requires(COMPLEX_COMPATIBLE_FUNCTION_EVALUATION)

# ---------- AUTOMATIC DIFFERENTIATION DISTINCTION ----------
AUTOMATIC_DIFFERENTIATION
    -> propagates(EXACT_CHAIN_RULE_DERIVATIVES_UP_TO_FLOATING_POINT)

FINITE_DIFFERENCE
    -> approximates(DERIVATIVE_FROM_PERTURBED_FUNCTION_VALUES)

AUTOMATIC_DIFFERENTIATION
    -/> numerical_differentiation_by_finite_difference

METHOD_TYPE
    -> must_be_distinguished

# ---------- SPECTRAL DIFFERENTIATION ----------
if
    function represented_by(FOURIER_OR_POLYNOMIAL_SPECTRAL_EXPANSION)

then

differentiate(EXPANSION_COEFFICIENTS)

SPECTRAL_DIFFERENTIATION
    -> very_high_accuracy_for(SMOOTH_FUNCTIONS)

but

-> global_method
-> sensitive_to(REGULARITY_AND_BOUNDARY_STRUCTURE)

# ---------- BOUNDARIES ----------
near left boundary:

CENTRAL_STENCIL
    -> may_require(POINTS_OUTSIDE_DOMAIN)

use
    FORWARD_ONE_SIDED_STENCIL

near right boundary:

use
    BACKWARD_ONE_SIDED_STENCIL

BOUNDARY
    -> changes(AVAILABLE_STENCIL)

# ---------- MULTIDIMENSIONAL DERIVATIVES ----------
for
    f(x,y)

partial_f/partial_x
    -> finite_difference_along(X_DIRECTION)

partial_f/partial_y
    -> finite_difference_along(Y_DIRECTION)

GRADIENT
    -> vector_of(NUMERICAL_PARTIAL_DERIVATIVES)

LAPLACIAN
    -> combination_of(NUMERICAL_SECOND_DERIVATIVES)

# ---------- CONDITIONING ----------
DIFFERENTIATION_OPERATOR
    -> intrinsically_amplifies(HIGH_FREQUENCY_COMPONENTS)

NUMERICAL_DIFFERENTIATION_FROM_DATA
    -> can_be(ILL_CONDITIONED)

NOISE
    -> major_error_source

REGULARISATION
    -> may_be_required

# ---------- APPLICATIONS ----------
NUMERICAL_DIFFERENTIATION
    -> applied_to(SCIENTIFIC_COMPUTING)
    -> applied_to(EXPERIMENTAL_DATA)
    -> applied_to(PDE_DISCRETISATION)
    -> applied_to(OPTIMISATION)
    -> applied_to(SENSITIVITY_ANALYSIS)
    -> applied_to(SIGNAL_PROCESSING)
    -> applied_to(NUMERICAL_MODELLING)

# ---------- RELATION GRAPH ----------
DERIVATIVE
    -> approximated_by(FINITE_DIFFERENCE)

TAYLOR_SERIES
    -> derives(FINITE_DIFFERENCE_FORMULA)

STENCIL
    -> determines(SAMPLE_DEPENDENCE)

STEP_SIZE
    -> controls(TRUNCATION_AND_ROUNDING_ERROR)

RICHARDSON_EXTRAPOLATION
    -> improves(ORDER)

NOISE
    -> amplified_by(DIFFERENTIATION)

INTERPOLATION
    -> supports(NONUNIFORM_GRID_DIFFERENTIATION)

# ---------- SEMANTIC EQUIVALENCE ----------
SEMANTIC_EQUIVALENCE := {
    "numerical differentiation" ~= "approximation of derivatives from finite function evaluations or sampled data",
    "finite difference" ~= "weighted difference of nearby function values approximating a derivative",
    "central difference" ~= "symmetric finite-difference derivative approximation",
    "stencil" ~= "set of grid points used by a finite-difference formula",
    "truncation error" ~= "error from neglecting higher terms in the underlying approximation expansion",
    "Richardson extrapolation" ~= "combination of approximations at multiple step sizes to cancel leading error"
}

# ---------- CONSTRAINTS ----------
CONSTRAINTS := {
    finite_difference_derivatives_are_approximations: true,
    error_orders_require_sufficient_function_smoothness: true,
    smaller_step_size_does_not_always_improve_accuracy: true,
    nonuniform_grids_require_modified_weights: true,
    differentiation_can_amplify_noise: true,
    complex_step_requires_complex_compatible_analytic_evaluation: true,
    automatic_differentiation_is_distinct_from_finite_difference_differentiation: true
}

# ---------- CONFIDENCE ----------
CONFIDENCE := {
    core_definition: 0.99,
    finite_difference_relation: 0.99,
    error_order_relation: 0.99,
    step_size_relation: 0.99,
    interpolation_relation: 0.99,
    noise_regularisation_relation: 0.98,
    semantic_equivalence: 0.97
}

# ---------- RECURSIVE REASONING ----------
RECURSIVE_REASONING(query):
    identify(function_data_and_derivative_order)
    -> identify(evaluation_point_grid_and_boundary)
    -> determine(smoothness_noise_and_precision_context)
    -> choose(finite_difference_interpolation_complex_step_or_spectral_method)
    -> construct(stencil_and_weights)
    -> compute(derivative_approximation)
    -> estimate(truncation_and_rounding_error)
    -> optimise(step_size_if_relevant)
    -> apply(Richardson_or_regularisation_if_requested)
    -> validate(boundary_nonuniform_grid_and_noise_conditions)
    -> compare_with(automatic_differentiation_if_relevant)
    -> return(semantic_result)

# ---------- AI CONSUMPTION ----------
AI_CONSUMPTION := {
    parse_as: "typed numerical-differentiation semantic graph",
    primary_entity: NUMERICAL_DIFFERENTIATION,
    preserve: [
        function_or_data,
        derivative_order,
        evaluation_point,
        grid,
        step_size,
        stencil,
        precision,
        noise_level,
        boundary_context
    ],
    infer_through: [
        forward_differences,
        backward_differences,
        central_differences,
        higher_order_stencils,
        interpolation,
        Richardson_extrapolation,
        complex_step,
        regularised_differentiation
    ],
    avoid: [
        assuming_smaller_h_is always better,
        applying_equal_grid_formula_to nonuniform nodes,
        ignoring_noise_amplification,
        quoting_error_order_without smoothness,
        using_central_stencil_outside domain,
        confusing_automatic_differentiation_with finite differences
    ]
}

# ---------- UPDATE MODEL ----------
UPDATE_MODEL(new_information):
    validate(new_information)
    -> identify(numerical_differentiation_context)
    -> compare(existing_relations)
    -> preserve(grid_step_stencil_error_and_precision_invariants)
    -> update(affected_entities)
    -> update(affected_edges)
    -> recompute(CONFIDENCE)
    -> regenerate(FLOW_HASH)

# ---------- FLOW HASH ----------
FLOW_HASH := hash(
    SOURCE_URL
    + ENTITY
    + CONCEPTS
    + NUMERICAL_DIFFERENTIATION
    + FINITE_DIFFERENCE
    + FORWARD_DIFFERENCE
    + BACKWARD_DIFFERENCE
    + CENTRAL_DIFFERENCE
    + STEP_SIZE
    + TRUNCATION_ERROR
    + ROUNDING_ERROR
    + RICHARDSON_EXTRAPOLATION
    + SEMANTIC_EQUIVALENCE
    + CONSTRAINTS
)

# ---------- EXECUTION ----------
INPUT(query)
    -> NUMERICAL_DIFFERENTIATION
    -> FUNCTION_DATA_IDENTIFICATION
    -> GRID_BOUNDARY_ANALYSIS
    -> SMOOTHNESS_NOISE_PRECISION_ANALYSIS
    -> METHOD_SELECTION
    -> STENCIL_WEIGHT_CONSTRUCTION
    -> DERIVATIVE_COMPUTATION
    -> ERROR_ANALYSIS
    -> STEP_SIZE_ANALYSIS
    -> EXTRAPOLATION_REGULARISATION_ANALYSIS
    -> GRID_NOISE_VALIDATION
    -> METHOD_COMPARISON
    -> RECURSIVE_REASONING(query)
    -> CONFIDENCE
    -> OUTPUT(semantic_result)

END FLOW
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ