Scientific computing
Scientific work in the Open 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 oel pack add:
oel pack add math/array
oel pack add math/linalg
oel pack add math/optimization
These packages, like every package, are written in the language and ship in compiled, verified form, 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.oel
agent analysis(input: Str<256>) -> Str<256> {
config {
id: "analysis"; version: "1.0.0";
ports: [
{ id: "input"; direction: "input"; schema_type: "String<256>";
modalities: ["text"]; min_count: 1; max_count: 1;
max_bytes: 256; join: "all"; },
{ id: "result"; direction: "output"; schema_type: "String<256>";
modalities: ["text"]; min_count: 1; max_count: 1;
max_bytes: 256; join: "all"; }
];
limits: {
ram_bytes: 33554432; cpu_millicores: 1000; cpu_millis: 8000;
duration_ms: 120000; input_tokens: 16384; output_tokens: 1024;
model_calls: 2; tool_calls: 0; steps: 10000; concurrency: 2;
max_children: 2; max_depth: 2; queue_items: 1; queued_bytes: 65536;
stream_bytes_per_second: 0; storage_bytes: 0; connections: 0;
cost_microunits: 0;
};
authority: []; capabilities: []; profile: "host"; state_domain: "request";
nodes: [{ id: "fitter"; source: "nodes/fit.node.oel"; }, { id: "writer"; source: "nodes/explain.node.oel"; }];
agents: []; edges: ["edges/fit_to_explain.edge.oel"]; starts: ["fitter"];
inputs: [{ port: "input"; to: { instance: "fitter"; port: "input"; }; }];
dispatch: "sequential";
completion: { kind: "all"; result: { instance: "writer"; port: "result"; }; };
}
}
The agent's other node and its edge, in their smallest form:
# nodes/explain.node.oel
node explain(input: Str<256>) -> Str<256> {
config {
id: "explain"; version: "1.0.0";
policy: {
kind: "model"; entry: "explain"; model_binding: "primary_model";
mode: "bounded_loop"; max_attempts: 2; max_repairs: 0;
};
ports: [
{ id: "input"; direction: "input"; schema_type: "String<256>";
modalities: ["text"]; min_count: 1; max_count: 1;
max_bytes: 256; join: "all"; },
{ id: "result"; direction: "output"; schema_type: "String<256>";
modalities: ["text"]; min_count: 1; max_count: 1;
max_bytes: 256; join: "all"; }
];
limits: {
ram_bytes: 16777216; cpu_millicores: 1000; cpu_millis: 1000;
duration_ms: 120000; input_tokens: 16384; output_tokens: 1024;
model_calls: 2; tool_calls: 0; steps: 32; concurrency: 1;
max_children: 0; max_depth: 1; queue_items: 1; queued_bytes: 65536;
stream_bytes_per_second: 0; storage_bytes: 0; connections: 0;
cost_microunits: 0;
};
authority: []; profile: "host"; state_domain: "request";
capabilities: []; tools: []; assets: [];
prompt: {
schema_version: 0;
sources: [{ kind: "project_file"; ref: "prompts/explain.md"; }];
input_renderer: "render_input";
require_system: false; allow_run_override: false;
};
prompt_variables: [];
binding: {
schema_version: 0; binding_id: "primary_model";
adapter_id: "openai_core"; adapter_version: "1.0.0";
family: "openai_chat"; endpoint: "http://127.0.0.1:8080/v1";
model_id: "primary-model"; auth: { kind: "env"; ref: "MODEL_API_KEY"; };
max_attempts: 2; timeout_ms: 60000;
defaults: {}; allowed_overrides: [];
capabilities: {
input_modalities: ["text"]; output_modalities: ["text"];
instructions: true; structured_output: false; tools: false;
streaming: false; max_context_tokens: 32768; max_output_tokens: 1024;
parameters: []; usage: "bounded_estimate";
};
};
binding_capability_revision: "1";
}
return input;
}
# edges/fit_to_explain.edge.oel
edge fit_to_explain(input: Str<256>) -> Str<256> {
config {
id: "fit_to_explain";
from: { instance: "fitter"; port: "result"; };
to: { instance: "writer"; port: "input"; };
mode: "request"; deadline_ms: 5000;
}
return input;
}
# nodes/fit.node.oel
node fit(input: Str<256>) -> Str<256> {
config {
id: "fit"; version: "1.0.0"; policy: { kind: "deterministic"; entry: "fit"; };
ports: [{ id: "input"; direction: "input"; schema_type: "String<256>"; modalities: ["text"]; min_count: 1; max_count: 1; max_bytes: 256; join: "all"; },
{ id: "result"; direction: "output"; schema_type: "String<256>"; modalities: ["text"]; min_count: 1; max_count: 1; max_bytes: 256; join: "all"; }];
limits: { ram_bytes: 1048576; cpu_millicores: 1000; cpu_millis: 1000; duration_ms: 5000; input_tokens: 0; output_tokens: 0;
model_calls: 0; tool_calls: 0; steps: 16; concurrency: 1; max_children: 0; max_depth: 0; queue_items: 1; queued_bytes: 65536;
stream_bytes_per_second: 0; storage_bytes: 0; connections: 0; cost_microunits: 0; };
authority: []; profile: "host"; state_domain: "request"; capabilities: []; tools: []; assets: [];
prompt: null; prompt_variables: null; binding: null; binding_capability_revision: null;
}
return input;
}
The deterministic node costs no model tokens, and its result reaches the model only as typed data. See Agents, nodes and edges. The nodes on this page are placeholders: fit returns its input where your fitting code goes.
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 the language, 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.