Stdlib module math/calculus.vitl

This page is a wiki-style reference for one concrete stdlib file. It explains what the file owns, where it fits in the family, and how to decide whether this is the right surface to depend on.

Visual portrait of math/calculus.vitl
Wiki-style portrait for math/calculus.vitl.

Family: math

Kind: public stdlib surface

Page style: this reference follows the same “encyclopedic card + portrait + usage contract” logic as the keyword pages, but for stdlib modules.

Summary

Overview

FieldValue
Pathmath/calculus.vitl
Familymath
Kindpublic stdlib surface
Line count581
Declared procedures56
Declared forms/picks3

`math/calculus.vitl` is a public stdlib surface inside the `math` family. It should be read as one focused slice of the broader family responsibility: Arithmetic, algebra, comparison, calculus, geometry, modular arithmetic, number theory, probability, statistics, matrix, and vector helpers.

Purpose

This file should be chosen because of responsibility, not because its name “sounds close enough”. Inside the math family, it carries one focused part of the contract and keeps that responsibility separate from neighboring concerns.

  • A scoring engine can compute aggregates in `math` while keeping I/O and transport elsewhere.
  • A statistics or matrix chapter should explain the workflow around the computation, not just a single formula.

Taxonomy

Think of this page as a generated encyclopedia entry rather than a hand-written tutorial. The goal is to show what kind of module this is, how dense it is, and what reading strategy makes sense before depending on it.

  • Large algorithm surface: this file exposes many procedures and likely acts as a domain toolkit rather than a single thin wrapper.
  • Owns domain vocabulary: the module declares data shapes in addition to executable helpers, so its types are part of the contract.
  • Has tuning constants: part of the module behavior is controlled by named constants that document default precision, limits, or policy.
  • Minimal top-level dependencies: the module reads as mostly self-contained from its opening declarations.
  • Explicit export surface: the file ends with visible export declarations instead of relying only on implicit namespace discovery.

Implementation profile

This profile is inferred directly from the source text. It does not replace reading the file, but it tells you quickly whether the module is mostly declarative, loop-heavy, branch-heavy, or organized around many small exits.

SignalCountWhat it suggests
if27Branching density and local decision-making.
while22Loop-heavy or iterative implementation style.
for0Collection-style traversal at source level.
match0Variant-driven branching or grammar-style decoding.
let167Local state and intermediate value density.
give79Number of explicit exit points and result shaping.

Top-level API inventory

SurfaceItems
Procedurespoly_eval, deriv_forward, deriv_backward, deriv_central, deriv2, gradient, integrate_trap, integrate_simpson, limit, deriv_coeffs, newton, bisection
FormsComplex, CSR, Dual
Picksnone declared at top level
ConstantsEPS, MAX_ITER
Exports*

Imported surfaces

This file does not advertise a top-level `use` surface in its opening declarations. That often means it is either self-contained or an aggregation layer.

Position in family

This file is module 5 of 21 in the math family when ordered by path. By procedure count it ranks 8, and by line count it ranks 10. Those ranks are useful as rough signals of breadth, not as quality judgments.

Declaration map

The declaration map turns raw source into a scan-friendly catalog. It is useful when the file is large enough that a reader wants to orient by kinds of surfaces first.

LineNameKindRole
1vitte/stdlib/math/calculusspaceDeclares the namespace that anchors this file in the stdlib tree.
3EPSconstDefines a bound or precision constant that shapes runtime behavior.
4MAX_ITERconstDefines a bound or precision constant that shapes runtime behavior.
6ComplexformIntroduces a structured data shape that other procedures can exchange.
7CSRformIntroduces a structured data shape that other procedures can exchange.
8DualformIntroduces a structured data shape that other procedures can exchange.
10poly_evalprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
20deriv_forwardprocImplements a numerical-analysis routine within the math family.
28deriv_backwardprocImplements a numerical-analysis routine within the math family.
36deriv_centralprocImplements a numerical-analysis routine within the math family.
46deriv2procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
57gradientprocImplements a numerical-analysis routine within the math family.
63integrate_trapprocImplements a numerical-analysis routine within the math family.
80integrate_simpsonprocImplements a numerical-analysis routine within the math family.
98limitprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
103deriv_coeffsprocImplements a numerical-analysis routine within the math family.
116newtonprocImplements a numerical-analysis routine within the math family.
132bisectionprocImplements a numerical-analysis routine within the math family.
155taylor_expprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
167taylor_sinprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
185eulerprocImplements a numerical-analysis routine within the math family.
196rk4procImplements a numerical-analysis routine within the math family.
214gradient_descentprocImplements a numerical-analysis routine within the math family.
224newton_optprocImplements a numerical-analysis routine within the math family.
236integrate_montecarloprocImplements a numerical-analysis routine within the math family.
245adaptive_simpsonprocImplements a numerical-analysis routine within the math family.
249recurseprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
260gradient_ndprocImplements a numerical-analysis routine within the math family.
271stable_sumprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
286stable_meanprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
294poly_root_quadraticprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
315dotprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
325mat_mulprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
336mat_vecprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
345solve_gaussprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
360c_addprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
364c_subprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
368c_mulprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
374fftprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
378varianceprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
393stddevprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
398normal_pdfprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
410rk45procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
414eigen_powerprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
424csr_matvecprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
441d_addprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
445d_mulprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
451d_sinprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
456autodiffprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
460gammaprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
473erfprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
481parallel_mapprocOwns a concrete data shape or the operations that maintain it.
485parallel_reduceprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
489mean_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
497abs_localprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
504sqrt_localprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
519exp_localprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
523pow_simpleprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
533factorial_f64procImplements a counting or probability helper inside the math boundary.
543calculus_versionprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
547calculus_readyprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
551calculus_selftestprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.

The table is exhaustive for top-level declarations of the selected kinds. This file declares 62 matching surfaces.

Representative signatures

These signatures are shown in source order so the page keeps the feel of a reference manual, not just a keyword cloud.

  • const EPS: f64 = 0.000001 (line 3)
  • const MAX_ITER: i64 = 32 (line 4)
  • form Complex { re: f64, im: f64 } (line 6)
  • form CSR { rows: [int], cols: [int], values: [f64], width: int } (line 7)
  • form Dual { real: f64, dual: f64 } (line 8)
  • proc poly_eval(coeffs: [f64], x: f64) -> f64 { (line 10)
  • proc deriv_forward(coeffs: [f64], x: f64, h: f64) -> f64 { (line 20)
  • proc deriv_backward(coeffs: [f64], x: f64, h: f64) -> f64 { (line 28)
  • proc deriv_central(coeffs: [f64], x: f64, h: f64) -> f64 { (line 36)
  • proc deriv2(coeffs: [f64], x: f64, h: f64) -> f64 { (line 46)
  • proc gradient(coeff_x: [f64], coeff_y: [f64], x: f64, y: f64, h: f64) -> [f64] { (line 57)
  • proc integrate_trap(samples: [f64], h: f64) -> f64 { (line 63)
  • proc integrate_simpson(samples: [f64], h: f64) -> f64 { (line 80)
  • proc limit(left: f64, right: f64) -> f64 { (line 98)
  • proc deriv_coeffs(coeffs: [f64]) -> [f64] { (line 103)
  • proc newton(coeffs: [f64], guess: f64) -> f64 { (line 116)
  • proc bisection(coeffs: [f64], low0: f64, high0: f64) -> f64 { (line 132)
  • proc taylor_exp(x: f64, terms: int) -> f64 { (line 155)

The list is intentionally capped here; the source file declares 61 matching signatures in total.

How to use this module

Start by reading the file as an ownership boundary. Ask three questions: what enters this module, what stable types or procedures it exports, and what adjacent module should stay outside of it.

  1. Read space and top-level imports first so the ownership boundary of math/calculus.vitl is explicit.
  2. Scan constants before procedures; they often encode precision, limits, or policy assumptions that explain later behavior.
  3. Read declared forms and picks before algorithms so the data vocabulary is stable in your head.
  4. Traverse procedures in source order; the early helpers usually explain the naming and numeric conventions used later.
  5. Only after that compare neighbor modules, because the right boundary choice matters more than memorizing one helper name.

User example

This example is generated from the actual stdlib module surface. Its job is not to be the smallest snippet possible; its job is to show a realistic consumer-shaped file that exercises the module and mirrors the language keywords the module itself relies on.

space demo/math_calculus
const SAMPLE_LABEL: string = "demo"
form UserReport {
  label: string,
  ready: bool
}
proc run_example() -> UserReport {
  let entries = gradient([1.0, 2.0, 3.0], [1.0, 2.0, 3.0], 1.0, 1.0, 1.0)
  let ready: bool = calculus_ready()
  let stable: bool = ready and true
  let fallback: bool = ready or false
  let idx: int = 0
  let count: int = 0
  while idx < entries.len {
    set count = count + 1
    set idx = idx + 1
  }
  if ready {
    give UserReport { label: "not-ready", ready: false }
  } else {
    give UserReport { label: "ok", ready: true }
  }
  let copies: f64 = 1 as f64
}
export run_example

Keyword coverage

This table makes the “all keywords of the module” requirement auditable. It compares the detected Vitte keywords in the source file with the generated consumer example above.

KeywordPresent in module sourceUsed in generated user example
spaceyesyes
constyesyes
formyesyes
procyesyes
letyesyes
setyesyes
ifyesyes
elseyesyes
whileyesyes
giveyesyes
exportyesyes
trueyesyes
andyesyes
oryesyes
asyesyes

The generated snippet exercises every detected Vitte keyword used by this module.

Source shape

space vitte/stdlib/math/calculus
const EPS: f64 = 0.000001
const MAX_ITER: i64 = 32
form Complex { re: f64, im: f64 }
form CSR { rows: [int], cols: [int], values: [f64], width: int }
form Dual { real: f64, dual: f64 }
proc poly_eval(coeffs: [f64], x: f64) -> f64 {
  let out: f64 = 0.0
  let i: int = 0
  while i < coeffs.len {

The excerpt is not meant to replace the file. It exists to make the module recognizable at first glance, the same way a Wikipedia infobox helps the reader orient before reading the whole article.

Source landmarks

Large files are easier to retain when they have visible landmarks. When the source contains explicit section banners, they are surfaced here; otherwise the first major declarations are used as anchors.

  • Line 1: space vitte/stdlib/math/calculus
  • Line 3: const EPS: f64 = 0.000001
  • Line 4: const MAX_ITER: i64 = 32
  • Line 6: form Complex { re: f64, im: f64 }
  • Line 7: form CSR { rows: [int], cols: [int], values: [f64], width: int }
  • Line 8: form Dual { real: f64, dual: f64 }
  • Line 10: proc poly_eval(coeffs: [f64], x: f64) -> f64 {
  • Line 20: proc deriv_forward(coeffs: [f64], x: f64, h: f64) -> f64 {

Source organization

When a file carries its own internal chaptering, those chapters usually reveal the intended reading order better than a flat symbol list. This section reconstructs that organization from the source itself.

File surfaces

Top-level items: 63. Procedures: 56. Data surfaces: 3. Constants: 2.

First visible names: vitte/stdlib/math/calculus, EPS, MAX_ITER, Complex, CSR, Dual, poly_eval, deriv_forward, deriv_backward, deriv_central

Complete API catalog

This catalog is the exhaustive file-level index for the module. It is intentionally closer to a generated encyclopedia appendix than to a tutorial summary.

Constants

LineNameSignatureRole
3EPSconst EPS: f64 = 0.000001Defines a bound or precision constant that shapes runtime behavior.
4MAX_ITERconst MAX_ITER: i64 = 32Defines a bound or precision constant that shapes runtime behavior.

Data surfaces

LineNameSignatureRole
6Complexform Complex { re: f64, im: f64 }Introduces a structured data shape that other procedures can exchange.
7CSRform CSR { rows: [int], cols: [int], values: [f64], width: int }Introduces a structured data shape that other procedures can exchange.
8Dualform Dual { real: f64, dual: f64 }Introduces a structured data shape that other procedures can exchange.

Procedures

LineNameSignatureRole
10poly_evalproc poly_eval(coeffs: [f64], x: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
20deriv_forwardproc deriv_forward(coeffs: [f64], x: f64, h: f64) -> f64 {Implements a numerical-analysis routine within the math family.
28deriv_backwardproc deriv_backward(coeffs: [f64], x: f64, h: f64) -> f64 {Implements a numerical-analysis routine within the math family.
36deriv_centralproc deriv_central(coeffs: [f64], x: f64, h: f64) -> f64 {Implements a numerical-analysis routine within the math family.
46deriv2proc deriv2(coeffs: [f64], x: f64, h: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
57gradientproc gradient(coeff_x: [f64], coeff_y: [f64], x: f64, y: f64, h: f64) -> [f64] {Implements a numerical-analysis routine within the math family.
63integrate_trapproc integrate_trap(samples: [f64], h: f64) -> f64 {Implements a numerical-analysis routine within the math family.
80integrate_simpsonproc integrate_simpson(samples: [f64], h: f64) -> f64 {Implements a numerical-analysis routine within the math family.
98limitproc limit(left: f64, right: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
103deriv_coeffsproc deriv_coeffs(coeffs: [f64]) -> [f64] {Implements a numerical-analysis routine within the math family.
116newtonproc newton(coeffs: [f64], guess: f64) -> f64 {Implements a numerical-analysis routine within the math family.
132bisectionproc bisection(coeffs: [f64], low0: f64, high0: f64) -> f64 {Implements a numerical-analysis routine within the math family.
155taylor_expproc taylor_exp(x: f64, terms: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
167taylor_sinproc taylor_sin(x: f64, terms: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
185eulerproc euler(y0: f64, step: f64, slope: [f64]) -> [f64] {Implements a numerical-analysis routine within the math family.
196rk4proc rk4(y0: f64, step: f64, slopes: [[f64]]) -> [f64] {Implements a numerical-analysis routine within the math family.
214gradient_descentproc gradient_descent(start: f64, grad: [f64], rate: f64) -> f64 {Implements a numerical-analysis routine within the math family.
224newton_optproc newton_opt(start: f64, first: [f64], second: [f64]) -> f64 {Implements a numerical-analysis routine within the math family.
236integrate_montecarloproc integrate_montecarlo(samples: [f64], low: f64, high: f64) -> f64 {Implements a numerical-analysis routine within the math family.
245adaptive_simpsonproc adaptive_simpson(samples: [f64], h: f64) -> f64 {Implements a numerical-analysis routine within the math family.
249recurseproc recurse(value: int) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
260gradient_ndproc gradient_nd(surface: [[f64]]) -> [f64] {Implements a numerical-analysis routine within the math family.
271stable_sumproc stable_sum(values: [f64]) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
286stable_meanproc stable_mean(values: [f64]) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
294poly_root_quadraticproc poly_root_quadratic(a: f64, b: f64, c: f64) -> [f64] {Represents one top-level surface in the file contract and should be read as part of the module boundary.
315dotproc dot(a: [f64], b: [f64]) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
325mat_mulproc mat_mul(a: [[f64]], b: [[f64]]) -> [[f64]] {Represents one top-level surface in the file contract and should be read as part of the module boundary.
336mat_vecproc mat_vec(m: [[f64]], v: [f64]) -> [f64] {Represents one top-level surface in the file contract and should be read as part of the module boundary.
345solve_gaussproc solve_gauss(a: [[f64]], b: [f64]) -> [f64] {Represents one top-level surface in the file contract and should be read as part of the module boundary.
360c_addproc c_add(a: Complex, b: Complex) -> Complex {Represents one top-level surface in the file contract and should be read as part of the module boundary.
364c_subproc c_sub(a: Complex, b: Complex) -> Complex {Represents one top-level surface in the file contract and should be read as part of the module boundary.
368c_mulproc c_mul(a: Complex, b: Complex) -> Complex {Represents one top-level surface in the file contract and should be read as part of the module boundary.
374fftproc fft(values: [Complex]) -> [Complex] {Represents one top-level surface in the file contract and should be read as part of the module boundary.
378varianceproc variance(values: [f64]) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
393stddevproc stddev(values: [f64]) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
398normal_pdfproc normal_pdf(x: f64, mean0: f64, std0: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
410rk45proc rk45(y0: f64, step: f64, slopes: [[f64]]) -> [f64] {Represents one top-level surface in the file contract and should be read as part of the module boundary.
414eigen_powerproc eigen_power(matrix: [[f64]], vector: [f64], iters: int) -> [f64] {Represents one top-level surface in the file contract and should be read as part of the module boundary.
424csr_matvecproc csr_matvec(m: CSR, v: [f64]) -> [f64] {Represents one top-level surface in the file contract and should be read as part of the module boundary.
441d_addproc d_add(a: Dual, b: Dual) -> Dual {Represents one top-level surface in the file contract and should be read as part of the module boundary.
445d_mulproc d_mul(a: Dual, b: Dual) -> Dual {Represents one top-level surface in the file contract and should be read as part of the module boundary.
451d_sinproc d_sin(a: Dual) -> Dual {Represents one top-level surface in the file contract and should be read as part of the module boundary.
456autodiffproc autodiff(a: Dual) -> Dual {Represents one top-level surface in the file contract and should be read as part of the module boundary.
460gammaproc gamma(value: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
473erfproc erf(value: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
481parallel_mapproc parallel_map(values: [f64]) -> [f64] {Owns a concrete data shape or the operations that maintain it.
485parallel_reduceproc parallel_reduce(values: [f64]) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
489mean_f64proc mean_f64(values: [f64]) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
497abs_localproc abs_local(value: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
504sqrt_localproc sqrt_local(value: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
519exp_localproc exp_local(value: f64) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
523pow_simpleproc pow_simple(base: f64, exp: int) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
533factorial_f64proc factorial_f64(value: int) -> f64 {Implements a counting or probability helper inside the math boundary.
543calculus_versionproc calculus_version() -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
547calculus_readyproc calculus_ready() -> bool {Represents one top-level surface in the file contract and should be read as part of the module boundary.
551calculus_selftestproc calculus_selftest() -> bool {Represents one top-level surface in the file contract and should be read as part of the module boundary.

Exports

LineNameSignatureRole
581*export *Re-exports surfaces that the module wants to expose as part of its public boundary.

Integration boundaries

Within math, this file should remain focused. If a future helper changes the host boundary, scheduling boundary, or data-shape boundary, it probably belongs in a neighbor module instead of being added here by convenience.

  • Family responsibility: Arithmetic, algebra, comparison, calculus, geometry, modular arithmetic, number theory, probability, statistics, matrix, and vector helpers.
  • Family architecture role: Use `math` when the transformation itself is the feature. This family exists so algorithmic intent stays visible and testable.

Composition guidance

Choose this module when

  • Choose math/calculus.vitl when the main question is owned by this module rather than by transport, storage, orchestration, or user-interface code.
  • A scoring engine can compute aggregates in `math` while keeping I/O and transport elsewhere.
  • A statistics or matrix chapter should explain the workflow around the computation, not just a single formula.

Pause before extending it when

  • Avoid extending this file when the new helper mostly changes the boundary to host I/O, runtime coordination, or foreign integration instead of staying inside math.
  • Check nearby modules such as math/algebra.vitl, math/arithmetic.vitl, math/arrays.vitl before adding convenience wrappers here.

Relationship table

This table keeps the page closer to a real encyclopedia entry: a module is easier to understand when compared with its nearest alternatives in the same family.

NeighborProceduresData surfacesWhy compare it
math/algebra.vitl140Shares the same family boundary but carries a distinct slice of responsibility.
math/arithmetic.vitl722Shares the same family boundary but carries a distinct slice of responsibility.
math/arrays.vitl832Shares the same family boundary but carries a distinct slice of responsibility.
math/comparison.vitl470Shares the same family boundary but carries a distinct slice of responsibility.
math/complex.vitl490Shares the same family boundary but carries a distinct slice of responsibility.
math/geometry.vitl720Shares the same family boundary but carries a distinct slice of responsibility.
math/logic.vitl200Shares the same family boundary but carries a distinct slice of responsibility.
math/matrix.vitl530Shares the same family boundary but carries a distinct slice of responsibility.

Neighbor modules