Two top-ROI engine items from expansion-v2 / the competitive analysis: Units-in-discovery (specs/dimensional-search) — wire lawsynth-units into discovery to prune dimensionally-inconsistent candidate terms in-loop (à la PySR/SciML/ AI-Feynman). Wildcard-aware inference (free coefficients absorb residual units), opt-in --units NAME=UNIT flag, exact-rational Buckingham-pi dimensionless-groups helper. Demo: oscillator prunes 8/20 terms (dimensioned sin/cos), identical recovery; default path byte-identical. 185 tests across 4 crates. Koopman/DMD (crates/lawsynth-koopman, specs/koopman) — the linear-operator method LawSynth lacked: DMD/DMDc/EDMD with hand-rolled deterministic SVD (one-sided Jacobi) + eigendecomposition (Hessenberg->complex-QR->inverse-iteration), no external crates. Recovers eigenvalues to ~2e-16, EDMD 100x better than raw DMD, DMDc [A B] to <1e-8; 34 tests, bit-exact determinism. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
19 lines
756 B
Rust
19 lines
756 B
Rust
use lawsynth_core::Identifier;
|
|
use lawsynth_expr::Expr;
|
|
use lawsynth_symbolic::calibrate_affine;
|
|
use std::{hint::black_box, time::Instant};
|
|
fn main() {
|
|
let x = Identifier::new("x").unwrap();
|
|
let expression = Expr::symbol(x.clone());
|
|
let contexts =
|
|
(0..1_000).map(|i| [(x.clone(), i as f64)].into_iter().collect()).collect::<Vec<_>>();
|
|
let targets = (0..1_000).map(|i| 2.0 * i as f64 + 1.0).collect::<Vec<_>>();
|
|
let started = Instant::now();
|
|
let mut count = 0;
|
|
for _ in 0..100 {
|
|
let calibrated = calibrate_affine(&expression, &contexts, &targets).unwrap();
|
|
count += black_box(calibrated.expression.to_canonical_string().len());
|
|
}
|
|
println!("calibrated {count} nodes in {:?}", started.elapsed());
|
|
}
|