Scientific computing
Scientific work in AEL, the Agent Engineering Language, comes from optional packages. Optional packages provide numerical arrays, complex numbers and linear algebra, and optimization, signal processing, integration and automatic differentiation. A program that does not use them carries none of their code, and a console program that uses them needs no server.
The packages
| Package | What it provides |
|---|---|
math/array | Typed dense arrays with views, slicing, broadcasting, an explicit memory layout and checked shape arithmetic. |
math/linalg | Vector and matrix operations, factorizations, linear solves and eigenvalue problems. |
math/sparse | Declared sparse formats, sparse arithmetic and solvers, and checked conversion to and from dense arrays. |
math/optimization | Constrained and unconstrained optimization and least squares, with a convergence status on every result. |
math/signal | Filtering, transforms, spectral analysis and streaming signal operations with bounded state. |
math/integration | Numerical quadrature and the integration of ordinary differential equations, with tolerances and event handling. |
math/random | Seeded generators, independent streams derived from one seed, and common distributions. |
math/autodiff | Forward and reverse automatic differentiation for the operations it lists. |
You add each package on its own with ael pack add:
ael pack add math/array
ael pack add math/linalg
ael pack add math/optimization
These packages, like every AEL package, are written in AEL and ship as compiled, verified AEL, with no bundled native code and no install scripts. Robotics and quantum packages build on the same arrays and linear algebra.
Checked numerical results
- Shapes are checked. An array's element type, shape and layout are part of its value. Mismatched dimensions, and dimensions whose size would overflow, fail with a typed error instead of producing a wrong answer.
- Solvers report how they ended. Converged, did not converge, hit its iteration limit, or met an ill-conditioned input: each is a separate outcome that your code handles.
- Tolerances are explicit. Integration, optimization and solvers take the tolerances and step limits you set, and report the error estimate they reached where the method provides one.
- Randomness is reproducible. A seed and the package version reproduce the same stream. The generators in
math/randomare for simulation and sampling, not for secrets. - Relaxed modes are opt-in. A mode that relaxes exact reproducibility, such as reordering a sum, has to be selected explicitly.
- Copies are visible. Views share memory only when ownership and layout allow it; otherwise the copy is made and reported.
Numerical work runs within the same budgets as the rest of your program, and packages do not start threads outside them.
Agents and numerical code
A typical pattern keeps the numbers deterministic and lets a model do what it is good at: a model-driven node proposes an experiment or explains a result, and deterministic nodes compute.
# agents/analysis.agent.ael
agent analysis(input: Dataset) -> Report {
config {
nodes: [fitter = fit, writer = explain];
edges: [fit_to_explain(fitter, writer)];
starts: [fitter];
completion: writer.result;
}
}
# nodes/fit.node.ael
node fit(input: Dataset) -> FitResult {
return fit_curve(input);
}
fn fit_curve(input: Dataset) -> FitResult {
# Deterministic: uses the optimization package and calls no model.
}
The deterministic node costs no model tokens, and its result reaches the model only as typed data. See Agents, nodes and edges. The body of fit_curve is a placeholder, as A first agent explains.
Honest limits
- Floating-point numbers are outside the language reference; numerical arrays, complex numbers and linear algebra come from the packages above. See Numbers.
- Each package lists the operations it covers and those it does not. The packages are written for AEL, not copies of another language's libraries.
- This page states no timing or size figures.
- To run scientific programs you already have in another language, call them as tools; see Calling your existing programs.