FrankenSciPy

SciPy, rebuilt in Rust19 cratesv0.5.2 on crates.io

SciPy’s math, without the Python.

FrankenSciPy is SciPy rebuilt from scratch in safe Rust, from linear algebra to statistics: 1,532 of the 1,538 functions and classes SciPy exports, 916 of them checked against a live SciPy in the test suite. Every dense solve returns a certificate saying which algorithm ran and why. The curves here are computed by those crates, running in your browser.

cargo add fsci-linalg fsci-stats

Pick a function

Orders v = 0 to 19, x from 0 to 40: 20 ridges of 300 points.

The same call, twice

SciPyscipy.special.jv(v, x)

Rustfsci_special::jv(&v, &x, mode)

– largest difference from SciPy 1.17.1 over 6,000 values

– same bits– ≤ 4 ulp– ≤ 256 ulp– more

Drawn from SciPy’s recorded values. Starting fsci-special…

The Bessel ridges drift through fractional orders, each frame computed by fsci-special. Point at them and they settle on whole orders, where you can read any value beside SciPy’s for the same input. SciPy’s answers were recorded with SciPy 1.17.1 and NumPy 2.4.3 when this page was built. An ulp is one step between neighbouring doubles.

What’s inside

SciPy’s toolbox, crate by crate.

1,532 of SciPy’s 1,538 public functions and classes, in 19 crates you add one at a time. The counts on each card are from the census: implemented, and compared against a live SciPy.

  • x CERTIFICATErcond 1.0e-11Cholesky✓ bwd 8e-17

    Solve

    Linear algebra

    LU, QR, Cholesky, SVD, eig, Schur, expm and Riccati, real and complex, with a certificate on every dense solve.

    103 names79 compared live

    fsci-linalg

  • Factor

    Sparse matrices and graphs

    Seven formats, sparse LU, Krylov solvers from CG to LSMR, eigsh and eigs, and graph algorithms from Dijkstra to PageRank.

    112 names78 compared live

    fsci-sparse

  • Minimize

    Optimization

    Fourteen minimize methods, root finders, least squares and curve_fit, global search, and LP and MILP.

    77 names34 compared live

    fsci-opt

  • ADAMSBDF

    Integrate

    ODEs and quadrature

    solve_ivp's six methods including LSODA, solve_bvp, QUADPACK, cubature and quasi-Monte Carlo.

    32 names15 compared live

    fsci-integrate

  • Evaluate

    Special functions

    Gamma, Bessel, Airy, hypergeometric, elliptic and orthogonal polynomials, with SciPy's edge cases.

    358 names211 compared live

    fsci-special

  • Test

    Statistics

    Over a hundred distributions with fitting and moments, hypothesis tests, KDE and QMC samplers.

    358 names262 compared live

    fsci-stats

  • Filter

    Signal processing and FFT

    Filter design and filtfilt, Welch and STFT, wavelets, and a mixed-radix FFT with DCT and DST.

    229 names122 compared live

    fsci-signalfsci-fft

  • Fit

    Interpolation

    Cubic, Akima and PCHIP splines, B-splines, RBF, griddata and regular-grid interpolation.

    56 names15 compared live

    fsci-interpolate

  • Search

    Spatial, clusters and images

    KDTree, distances, Delaunay and Voronoi; k-means and hierarchical clustering; ndimage filters and morphology.

    159 names81 compared live

    fsci-spatialfsci-clusterfsci-ndimage

Also in the workspace: scipy.constants, scipy.datasets, scipy.io, scipy.odr, another 48 names. See every name on the map.

What changes for you

Eight jobs it’s built for.

Everyday problems with SciPy’s math outside a Python notebook, how they go today, and how they go with FrankenSciPy.

Call SciPy’s statistics from a Rust service

Today

Embed CPython through PyO3, ship NumPy and SciPy beside the binary, and send every call through the GIL.

With FrankenSciPy

fsci_stats::ttest_ind_welch(&a, &b) is an ordinary Rust call: synchronous, no interpreter, built by Cargo alone.

Eight calls, side by side

Know which algorithm produced a number

Today

scipy.linalg.solve returns x. Which factorization ran, and how close the matrix was to singular, are not in the result.

With FrankenSciPy

The solve returns a certificate: rcond, structure, a posterior over condition states, each algorithm’s expected loss, the one that answered and its backward error.

Watch a solve decide

Replay a decision for an audit

Today

Re-run the computation and hope the library version, the flags and every internal state still match.

With FrankenSciPy

replay_decision rebuilds the choice from the certificate and refuses any portfolio whose BLAKE3 state digest differs.

Replay one, then tamper with it

Port a SciPy pipeline and keep its answers

Today

Translate call by call, then compare outputs by eye on a handful of inputs.

With FrankenSciPy

Same names, defaults and edge cases. 916 public SciPy functions are already compared against a live SciPy in 783 test files.

Look up the functions you use

Refuse bad input instead of answering it

Today

A NaN in the matrix comes back as NaNs, and a nearly singular system comes back as a confident answer.

With FrankenSciPy

Hardened mode refuses non-finite input, rcond below 10⁻¹⁴ and matrices over 10,000 rows, each as a typed error with an audit event.

Send it five hostile inputs

Fit thousands of curves in one call

Today

Call scipy.optimize.curve_fit once per dataset, or pack the whole study into one large least-squares problem.

With FrankenSciPy

curve_fit_many fit 2,000 exponential decays 145× faster than the fastest of five SciPy routes, in a same-run measurement on 32 cores.

Every win and loss, measured

Run SciPy’s math in a browser

Today

Load a Python interpreter compiled to WebAssembly, then NumPy and SciPy, before the first call.

With FrankenSciPy

Compile the crates you need for wasm32. This page’s engine carries ten of them in 560 KB, compressed.

Meet this page’s engine

Solve stiff ODEs the way SciPy does

Today

Move to another solver and accept different step choices, and slightly different answers.

With FrankenSciPy

LSODA is ported from the C file SciPy runs, and its test requires SciPy’s step counts, evaluation counts and switch history.

Watch LSODA switch methods
1 of 8

01The surface

Thirty-three SciPy modules, one Cargo workspace.

FrankenSciPy keeps SciPy’s names, defaults and edge cases, so code ports one call at a time. The symbol census, regenerated against SciPy 1.17.1, counts what is implemented, what is compared live and what is still missing.

The module map

Every public name in SciPy, one square each.

One square per public name in SciPy 1.17.1, grouped by the crate that implements it and coloured by what the census finds: compared live, implemented, missing or not applicable.

The census data

Point at a module or a square; select a square to look it up

symbol censusSciPy 1.17.1From the repository

1,555 public names · 33 modules · 16 crates

  • 916compared live against SciPy
  • 616implemented, not compared yet
  • 6missing
  • 17not applicable to Rust

fsci-stats360

stats241/303

stats.contingency2/6

stats.mstats11/31

stats.qmc4/11

stats.sampling4/9

fsci-special358

special211/358

fsci-signal182

signal83/157

signal.windows9/25

fsci-sparse117

sparse25/53

sparse.csgraph24/26

sparse.linalg29/38

fsci-linalg106

linalg72/98

linalg.interpolative7/8

fsci-opt78

differentiate0/3

optimize30/71

optimize.elementwise4/4

fsci-ndimage75

ndimage39/75

fsci-interpolate56

interpolate15/56

fsci-fft51

fft20/41

fftpack10/10

fsci-spatial49

spatial8/18

spatial.distance22/27

spatial.transform0/4

fsci-cluster36

cluster.hierarchy10/32

cluster.vq2/4

fsci-integrate33

integrate15/33

fsci-io31

io3/14

io.arff3/4

io.matlab4/10

io.wavfile2/3

fsci-odr10

odr2/10

fsci-constants8

constants5/8

fsci-datasets5

datasets0/5

Point at a module

One square per name, grouped by crate. Select a square to look it up below.

How the census counts

Names come from each module’s __all__, counted once in the module that owns them, exactly as scripts/symbol_census.py counts them. A name is compared when a diff test’s inline SciPy script calls it and the same file calls the matching Rust item; a test that reaches SciPy through getattr is not seen, so the compared count is a lower bound.

The committed census file, docs/planning/symbol_census.json, counts 909 compared. Tests that landed after it was last regenerated bring the count on this tree to 916, the number this page uses throughout.

Every public name in SciPy 1.17.1’s __all__, counted once in the module that owns it, at commit d2b206d3d. A module’s count is its compared names over all its names.

Look up a function

Does it have the one you use?

Search any SciPy name for its Rust counterpart and the test files that compare it. Missing and not-applicable names carry the census’s reason.

Dispositions, with reasons

Type a SciPy name to see its Rust counterpart and the tests that compare it

symbol censusrepositoryFrom the repository

The six SciPy names with no Rust implementation yet:

  1. scipy.io.matlab.MatReadErrorMissing

    MATLAB read failures are IoError variants, not a distinct error class (frankenscipy-1ksfv.12)

  2. scipy.io.matlab.MatReadWarningMissing

    no warning channel for recoverable MATLAB read issues (frankenscipy-1ksfv.12)

  3. scipy.io.matlab.MatWriteErrorMissing

    MATLAB write failures are IoError variants, not a distinct error class (frankenscipy-1ksfv.12)

  4. scipy.io.matlab.MatWriteWarningMissing

    no warning channel for recoverable MATLAB write issues (frankenscipy-1ksfv.12)

  5. scipy.sparse.linalg.ArpackErrorMissing

    SparseError has no eigensolver error class (frankenscipy-6j5tz)

  6. scipy.sparse.linalg.MatrixRankWarningMissing

    spsolve on a singular matrix returns SingularMatrix instead of warning (frankenscipy-6j5tz)

“Compared” is the census’s own rule: a diff test’s SciPy script calls the name and the same file calls the Rust item. File links open the test on GitHub.

Same call, same answer

Port one call, check one answer.

Eight everyday calls, SciPy beside the Rust that replaces it. The Rust runs in this tab on SciPy’s recorded inputs, and every output is compared bit for bit.

Pick a call: the Rust runs here, and every output is checked against SciPy’s

fsci-linalgfsci-statsfsci-optfsci-integratefsci-fftfsci-signalfsci-interpolatefsci-specialSciPy 1.17.1Runs in your browser

SciPy

from scipy import linalg

x = linalg.solve(a, b)

Rust · fsci-linalg

use fsci_linalg::{solve, SolveOptions};

let x = solve(&a, &b, SolveOptions::default())?.x;

The result also carries a CASP certificate; chapter 03 opens it.

The inputs both sides used

a = [[4, -2, 1, 3], [3, 6, -4, 2], [2, 1, 8, -5], [1, -3, 2, 7]]
b = [1, -2, 3, 4]

SciPy’s recorded answer is below. Starting fsci-linalg…

OutputSciPy 1.17.1FrankenSciPy, liveDifference
Inputs and SciPy’s answers were recorded with SciPy 1.17.1 and NumPy 2.4.3; the page sends the same inputs to the Rust. An ulp is one step between neighbouring doubles.

02Checked against SciPy

Tested against SciPy, case by case.

A differential test hands its cases to a real SciPy 1.17.1 and holds FrankenSciPy’s answers to a tolerance named in the file. In CI a test that cannot reach SciPy fails, and so does any change that loosens a tolerance.

One test, start to finish

How a differential test works.

One Rust file per test: cases out to SciPy, the same cases through FrankenSciPy, each pair held to a named tolerance. This one checks the scaled Bessel and Hankel functions.

Read the whole test

Step through one real test, then run its eight cases in this tab

fsci-specialSciPy 1.17.1repositoryRuns in your browser
let cases: &[(&str, &str, f64, f64, f64)] = &[
    ("jve_real", "jve", 0.5, 1.25, 0.0),
    ("yve_real", "yve", 0.5, 1.25, 0.0),
    ("hankel1e_real", "hankel1e", 1.0, 1.25, 0.0),
    ("hankel2e_real", "hankel2e", 1.0, 1.25, 0.0),
    ("jve_complex", "jve", 0.5, 1.25, 0.5),
    ("yve_complex", "yve", 0.5, 1.25, 0.5),
    ("hankel1e_complex", "hankel1e", 0.5, 1.25, 0.5),
    ("hankel2e_complex", "hankel2e", 0.5, 1.25, 0.5),
];
diff_special_scaled_bessel.rs:55
let mut child = match fsci_conformance::scipy_oracle_command()
…
if std::env::var(REQUIRE_SCIPY_ENV).is_ok() {
    return Err(test_error(format!("failed to spawn scipy oracle: {e}")));
…
import json
import sys
from scipy import special

q = json.loads(sys.argv[1])
points = []
for case in q["points"]:
    z = complex(case["z_re"], case["z_im"])
    if case["z_im"] == 0.0:
        z = case["z_re"]
    value = complex(getattr(special, case["function"])(case["order"], z))
    points.append({"case_id": case["case_id"], "re": value.real, "im": value.imag})
print(json.dumps({"points": points}))
diff_special_scaled_bessel.rs:97
let output = match case.function.as_str() {
    "jve" => jve(&order, &z, RuntimeMode::Strict),
    "yve" => yve(&order, &z, RuntimeMode::Strict),
    "hankel1e" => hankel1e(&order, &z, RuntimeMode::Strict),
    "hankel2e" => hankel2e(&order, &z, RuntimeMode::Strict),
    other => return Err(test_error(format!("unknown function {other}"))),
}
.map_err(|err| test_error(err.to_string()))?;
diff_special_scaled_bessel.rs:152
const SCALED_BESSEL_TOL: f64 = 5.0e-8;
…
let scale = expected.abs().max(1.0);
let diff = (actual - expected).abs();
// Written as `<=` so a NaN component (NaN diff) is a failure, not a silent pass.
let pass = diff <= SCALED_BESSEL_TOL * scale;
ledger.compared(arm, &case.case_id, pass);
diff_special_scaled_bessel.rs:20
let mut ledger = CompareLedger::new("diff_special_scaled_bessel", &ARMS);
…
ledger.finish(min_per_arm);
diff_special_scaled_bessel.rs:182

SciPy’s answers are recorded; FrankenSciPy’s are computed when you press Run.

CaseSciPy 1.17.1FrankenSciPy, live|fsci − SciPy| against the tolerance
jve_real–––
yve_real–––
hankel1e_real–––
hankel2e_real–––
jve_complex–––
yve_complex–––
hankel1e_complex–––
hankel2e_complex–––

The excerpts are read from diff_special_scaled_bessel.rs when this page is built. SciPy’s answers were recorded with SciPy 1.17.1; FrankenSciPy’s are computed here by the functions the test calls.

Live, in this tab

Sixteen functions, 4,800 values.

Fourteen special functions and two distributions on 300 inputs each, recorded from SciPy 1.17.1. FrankenSciPy evaluates them here and every pair is compared bit for bit; the numbers are this run’s.

Run the battery: each strip holds all 300 values of one function, coloured by distance from SciPy

fsci-specialfsci-statsSciPy 1.17.1Runs in your browser
–of 4,800 values with exactly SciPy’s bits
Within 4 ulp
–
Worst relative difference
–
One pass of all sixteen
–
  • Same bits
  • 1 to 4 ulp
  • 5 to 256 ulp
  • More
    An ulp is one step between neighbouring doubles, so 0 ulp means the same 64 bits. Times are FrankenSciPy’s, averaged over repeated passes inside the engine, since a browser’s clock is too coarse for one pass.

    Bit for bit

    Where the match is exact.

    Some ports reproduce SciPy to the last bit or the last evaluation. Each card says whether a test asserts it on every run or it was measured and logged.

    Filter the claims by how each one is backed

    repositoryFrom the repository
    • 111 / 111MAT files

      loadmat reads SciPy’s MAT test corpus as SciPy does

      Asserted by the test

      What the test checks

      Every file in the corpus, under seven loadmat option sets. Floats are compared as hex bit patterns, and a built-in control shows that a one-bit change, a signed zero, a dtype change or a renamed variable would be caught. The 8 files SciPy rejects are rejected with the same error class.

      Asserted
      every value equal to the bit
    • 408 / 408layouts

      dendrogram lays out every tree as SciPy does

      Asserted by the test

      What the test checks

      Four linkage methods, six sizes from 2 to 60 points and seventeen option sets. Coordinates, leaf order, labels and colours must all be equal.

      Asserted
      every field exactly equal
    • 400 / 400matrices

      matrix_balance finds LAPACK’s permutation

      Asserted by the test

      What the test checks

      Sparse matrices where dgebal isolates eigenvalues by permutation. Permutations and power-of-two scalings are exact, so the balanced matrix, scaling and permutation are compared for equality.

      Asserted
      exact equality
    • 0 ulpat every step

      LSODA takes SciPy’s steps and switches

      Asserted by the testMeasured, logged

      What the test checks

      fsci ports the C translation of ODEPACK that SciPy runs. On Robertson, van der Pol, HIRES, Arenstorf, the Oregonator and more, the test requires SciPy’s step and evaluation counts and its switches between Adams and BDF. On the pinned host every step row and every odeint row also came out bit-identical.

      Asserted
      step counts, evaluations, LU count and switch history equal
      Measured
      values bit-identical, logged
    • 30 / 30cases

      Trust-region methods match SciPy’s counts

      Measured, logged

      What the test checks

      trust-ncg, trust-krylov, dogleg and trust-exact took SciPy’s exact iteration, function, gradient and Hessian counts on all 30 cases. The test itself asserts the answers and an iteration count within 30%.

      Measured
      exact counts, logged
    • 24 / 25cases

      COBYLA reproduces SciPy’s iterates

      Measured, logged

      What the test checks

      A transcription of PRIMA, which SciPy runs, that evaluates NumPy’s linear algebra in OpenBLAS’s order. 24 of 25 cases end with the same bits for x and f and the same number of evaluations. On hosts whose OpenBLAS uses older kernels, a borderline case can end differently (issue #17).

      Measured
      bit-identical cases, logged
    • 9 / 9problems

      solve_bvp arrives at SciPy’s mesh

      Asserted by the testMeasured, logged

      What the test checks

      SciPy’s collocation method, transcribed: on nine boundary-value problems it took SciPy’s iteration count and node count and produced the same mesh. One problem’s exact path, 7 iterations and 233 nodes, is asserted in the crate’s own tests.

      Asserted
      one exact path
      Measured
      same mesh on all nine
    • 6.8 × 10⁻¹⁵worst, 198 cases

      Complex linear algebra follows LAPACK

      Measured, logged

      What the test checks

      Complex solve, LU, QR, Hessenberg, Schur, eig and SVD follow the LAPACK routines SciPy calls, so eigenvalues come back in SciPy’s order. The test holds factors to 10⁻¹² and spectra to 10⁻¹⁰; the worst error measured was 6.8 × 10⁻¹⁵.

      Measured
      worst relative error
    • 7.8 × 10⁻¹⁶worst, 300 cases

      fftpack’s pseudo-differential operators

      Measured, logged

      What the test checks

      diff, tilbert, hilbert, cs_diff, shift and the rest of scipy.fftpack’s pseudo-differential operators. The test holds them to 10⁻¹³ relative to the signal; the worst error measured was 7.8 × 10⁻¹⁶.

      Measured
      worst relative error
    Asserted means the test fails if the property stops holding. Measured means the test asserts a looser tolerance and logs the exact result; the figures quoted were measured with SciPy 1.17.1 and recorded in the commits linked.

    The tolerance ratchet

    Tolerances can only tighten.

    1,167 tolerances in 782 diff files are pinned in a baseline. CI gate G9 fails the build if one loosens, and the lint refuses to write a looser baseline.

    tolerance_lint.rs

    Move the scaled-Bessel test’s tolerance and see what tolerance_lint says

    repositoryWorked example

    1,167 contracts in 782 files

    diff_special_scaled_bessel.rs

    const SCALED_BESSEL_TOL: f64 = 5.0e-8;
    Baseline5e-8in tolerance_baseline.json
    
    
    What the baseline holds

    The few contracts at 0.1 and above are ratios, iteration slack or statistical bounds, such as NIT_REL_TOL = 0.3. A tolerance passed to a comparison helper as a literal is not a contract the lint can see.

    At this commit the baseline does not yet list one diff file, diff_signal_stft_istft.rs, which the lint reports as unanchored until the baseline is refreshed.

    The histogram is fixtures/tolerance_baseline.json at this build, median 10⁻¹⁰. The terminal lines are the ones tolerance_lint prints about this contract.

    One oracle test, run twice: with SciPy, and in a CI job built to fail without it

    repositoryFrom the repository

    Its G3 shardSciPy 1.17.1 installed, oracle required

    1. run diff_sparse_basic_queries
    2. SciPy answers every case
    3. test passes

    The control jobno SciPy on the interpreter, oracle still required

    1. run diff_sparse_basic_queries
    2. the oracle cannot start
    3. test fails
    4. job passes

    Gate defectIf that test ever passed without SciPy, the job would fail, because a missing oracle would be skipping instead of failing.

    The job’s script, from ci.yml
    if python -c "import scipy" 2>/dev/null; then
      echo "control interpreter unexpectedly imports scipy" >&2
      exit 1
    fi
    export SCIPY_PYTHON="$(which python)"
    export FSCI_REQUIRE_SCIPY_ORACLE=1
    if cargo test -p fsci-conformance --test diff_sparse_basic_queries -- --nocapture; then
      echo "GATE DEFECT: the oracle-required lane PASSED with no SciPy present" >&2
      exit 1
    fi
    echo "control ok: the lane failed closed without SciPy"
    From .github/workflows/ci.yml, job “G3 control: no SciPy must fail”, which runs with the nightly fan-out. The last fan-out in which every job passed was 36123052714, on 2026-09-25.

    03Condition-aware solving

    Every solve shows its work.

    Every dense solve returns a certificate with its answer: the conditioning it measured, the algorithm it chose and why, the accuracy it reached, and a digest that replays the decision bit for bit. CASP, the Condition-Aware Solver Portfolio, makes and records that choice.

    Anatomy of a certificate

    Seven fields carry the whole decision.

    A real SolveCertificate, returned by a solve that runs in this tab. Point at a numbered field to see what it records; pick another matrix and every value changes.

    Point at a numbered field, or pick another matrix

    fsci-linalgfsci-runtimeRuns in your browser

    SolveCertificateas JSON
    Starting fsci-linalg…
    1. 1

      What answered

      The action that produced x, the one tried first, and whether it fell back.

      –
    2. 2

      rcond estimate

      How close to singular. Rounding error can grow by up to 1/rcond.

      –
    3. 3

      Structure

      Found exactly, in SciPy’s order. It decides which fast path is a candidate.

      –
    4. 4

      Posterior

      Belief over the 4 condition states, from rcond and any outcomes recorded.

      –
    5. 5

      Expected loss

      Each candidate’s cost plus its expected recovery cost, in units of one LU.

      –
    6. 6

      Accuracy

      Backward error, checked against 10⁻⁸, and a bound on the forward error.

      –
    7. 7

      state_digest

      BLAKE3 of the portfolio state that decided. A replay must start from it.

      –
    The JSON is the certificate fsci-linalg returned, as serde_json writes it, with only the line breaks inside arrays folded. Every solve from a fresh portfolio shows the same state_digest, because each decides from the same state.

    One solve, start to finish

    Conditioning decides which algorithm is safe.

    Pick a matrix. CASP measures rcond and structure, prices each algorithm, runs one and falls back if its backward error misses 10⁻⁸. Strict mode runs SciPy’s own route first.

    solve_with_casp in fsci-linalg

    Pick a matrix and watch the portfolio choose, attempt and certify

    fsci-linalgfsci-runtimeRuns in your browser
    1. Probe–
    2. Posterior–
    3. Loss–
    4. Choose–
    5. Attempt–
    6. Certify–

    Matrix

    Mode

    Try

    ––

    Starting fsci-linalg…

    Each matrix is built in the engine from a fixed seed with b = A·1, so the forward error is measured against the exact answer. Near rcond 10⁻¹², a rounding error in the sixteenth digit of b can reach the fourth digit of x.

    The decision surface

    Losses measured on 324 matrices.

    Expected loss is an action’s cost plus the expected cost of recovering when it fails. On a fresh portfolio, LU wins for every general matrix, as SciPy’s gesv does.

    The calibration report

    Pick a structure, then move along rcond to read each action’s expected loss

    fsci-runtimeRuns in your browser

    Cost per solve, in LU solves

    • LU1
    • QR2
    • SVD31.5
    • Diagonal0
    • Triangular0
    • Symmetric0.5

      One engine call asks a fresh SolverPortfolio for its choice at 321 values of rcond. Only the actions a structure admits are candidates: LU, QR and the SVD, plus at most one fast path.
      How the loss table was measured

      casp_calibrate ran every action on 324 seeded matrices at n = 8, 32, 128, in 12 families from Higham’s randsvd to Hilbert, Kahan and Wilkinson’s pivot-growth matrix. An action fails a matrix where the portfolio would fall back: an error, a non-finite answer, or a backward error above 10⁻⁸. Each failure is priced at the cheapest action that recovered that matrix.

      The SVD costs 31.5 times LU’s flops and refuses a square system whose numerical rank is short, so it comes last. The generated constants live in calibrated_losses.rs, and a test holds them to the report.

      Feedback

      It learns from its own failures.

      Each attempt is tallied by decade of rcond, and what it shows replaces that action’s calibrated failure rate. Record LU misses and passes at rcond 10⁻³ and watch the choice move.

      Record LU’s outcomes one at a time and watch the choice move

      fsci-runtimeRuns in your browser

      Every click replays the outcome list into a fresh portfolio through SolverPortfolio::record_outcome, with a Beta prior worth four trials. In Strict mode solve still tries SciPy’s LU first on a general matrix; the ranking orders the fallbacks.

      Reproducibility

      Replay any decision, bit for bit.

      The certificate carries a BLAKE3 digest of the state that decided. replay_decision refuses any other state, then demands the same choice, posterior and losses, bit for bit.

      The replay test

      Pick a matrix; its certificate is replayed against four portfolios

      fsci-linalgfsci-runtimeRuns in your browser
      Replayed againstState digestResultWhy
      One engine call solves with solve_with_casp, keeping a copy of the portfolio from just before, and replays four times. The conformance test does the same for 1,000 solves through one portfolio that keeps learning.

      04The algorithms

      SciPy’s own algorithms, ported routine by routine.

      Where SciPy runs a classic code, FrankenSciPy ports that code instead of writing its own: LSODA, QUADPACK, COBYLA, SLSQP, complex LAPACK and more. The tests then compare step counts, evaluation counts and iterates with SciPy’s, not only the final answers.

      ODEPACK’s LSODA

      One solver that notices the stiffness.

      Robertson’s kinetics is the standard stiff test. LSODA starts with Adams steps of 10⁻⁵ s, detects stiffness at 0.0055 s, switches to BDF and stretches its steps to 10¹¹ s.

      lsoda.rs in fsci-integrate

      Move along the run to read LSODA’s state at each of its 200 output times

      fsci-integrateSciPy 1.17.1native buildRuns in your browser
      t
      –
      Method
      –
      Step size
      –
      Steps
      –
      RHS evaluations
      –
      Jacobians
      –
      • Running fsci-integrate…
      The run is odeint(robertson, [1, 0, 0], t, full_output=True) at odeint’s defaults, with 200 times spaced evenly in log t. SciPy’s side was recorded with SciPy 1.17.1’s arm64 macOS wheel.
      What the test asserts, and why the counts part on this machine

      The repository’s test, diff_integrate_lsoda.rs, fails unless step counts, evaluation counts and switch history equal SciPy’s, and on its pinned x86-64 Linux host every row was also measured bit-identical (89d2b1600).

      Against the arm64 macOS wheel recorded here, the method history agrees at all 200 outputs and the step counts agree for the first 83 outputs, then part: 793 steps here against SciPy’s 811. The figure reports each difference it finds.

      Minimizers

      Follow a minimizer iterate by iterate.

      Rosenbrock’s curved valley is the standard minimizer test. Pick a method: FrankenSciPy runs it here, iterate by iterate, over SciPy’s recorded path. Click the map to start somewhere else.

      minimize.rs in fsci-opt

      Pick a method, then click the map to start from another point

      fsci-optSciPy 1.17.1native buildRuns in your browser

      Method

      fsci-opt, this tabSciPy 1.17.1, recordedfunction evaluations
      Start
      (−1.2, 1)
      Iterations
      –
      Evaluations
      –
      Ends at
      –
      f there
      –

      • Running fsci-opt…
      Both sides minimize 100·(t·t) + u·u, with t = y − x² and u = 1 − x, using finite-difference gradients at SciPy’s default steps. SciPy’s paths come from minimize(..., callback=...), recorded from (−1.2, 1) with SciPy 1.17.1.
      Why neither library’s rosen is used

      SciPy’s rosen computes 100*(t**2) and fsci’s computes (100*t)*t. The two round differently in the last bit, which is enough to send a minimizer down a different path, so both sides evaluate the same written-out expression. The map’s contours are drawn by this page.

      QUADPACK

      Split the panel with the largest error.

      QAGS integrates each panel with a 21-point Gauss–Kronrod rule, bisects the panel with the largest error estimate, and extrapolates the sums. Pick an integrand and compare its panels with SciPy’s.

      quadpack.rs in fsci-integrate

      Pick an integrand, then point at a panel to read its share of the integral and its error

      fsci-integrateSciPy 1.17.1native buildRuns in your browser

      Integral
      –
      Exact
      –
      Error estimate
      –
      Evaluations
      –
      Panels
      –
      • Running fsci-integrate…
      QUADPACK’s panels, largest error first
      RankPanelIntegral over itError estimatevs SciPy
      Each integrand uses only arithmetic and square roots, which IEEE 754 rounds exactly, so Rust and Python evaluate the same bits at the same points. SciPy’s side is quad(f, 0, 1, full_output=1) at its defaults, recorded with SciPy 1.17.1.
      Why the panel errors don’t add up to the reported error

      QAGS extrapolates the sequence of panel sums with Wynn’s epsilon algorithm, and the extrapolated value is more accurate than any of its panels. That is why 1/√x, infinite at 0, converges after six panels, and why the reported error can be far smaller than the panels’ sum.

      Provenance

      Where each port comes from.

      SciPy’s numerical core is old, tuned code whose edge cases users rely on. FrankenSciPy ports it where it can, and says where it uses its own algorithm for the same contract.

      The full recipes table in the README

      Open a row for what SciPy runs, the Rust that replaces it and what its test checks

      repositoryFrom the repository
      1. 01 LSODAAdams and BDF in one ODE solver, switching when the problem turns stiff C fsci-integrate/lsoda.rs AssertedMeasured
        SciPy runs
        SciPy’s lsoda.c, a C translation of ODEPACK’s DLSODA (Hindmarsh, with Petzold’s method switching).
        FrankenSciPy
        crates/fsci-integrate/src/lsoda.rs · Ported routine by routine
        Asserted
        Step counts, evaluation counts and switch history equal to SciPy’s.
        Measured
        Every row bit-identical on the pinned x86-64 host (89d2b1600).
      2. 02 QUADPACKAdaptive quadrature: QAGS, QAGI, QAGP and the weighted QAW routines C fsci-integrate/quadpack.rs AssertedMeasured
        SciPy runs
        QUADPACK (Piessens, de Doncker-Kapenga, Überhuber and Kahaner, 1983), as scipy.integrate.quad builds it.
        FrankenSciPy
        crates/fsci-integrate/src/quadpack.rs · Ported routine by routine
        Asserted
        SciPy’s ier, and the value to QUADPACK’s own accuracy request.
        Measured
        53 cases matched value, error, evaluation count and panel count exactly when the port landed (46c6065df).
      3. 03 COBYLADerivative-free minimization with constraints, by linear approximation Python fsci-opt/cobyla.rs AssertedMeasured
        SciPy runs
        Powell’s COBYLA as SciPy runs it: scipy._lib.pyprima, the Python translation of Zaikun Zhang’s PRIMA.
        FrankenSciPy
        crates/fsci-opt/src/cobyla.rs · Ported routine by routine
        Asserted
        SciPy’s status, success flag and message.
        Measured
        24 of 25 cases bit-identical in x and f, in OpenBLAS’s SkylakeX evaluation order (9ec3a5475).
      4. 04 SLSQPSequential least squares with equality and inequality constraints C fsci-opt/slsqp.rs AssertedMeasured
        SciPy runs
        Kraft’s SLSQP (1988), from SciPy’s C translation in __slsqp.c and __nnls.c.
        FrankenSciPy
        crates/fsci-opt/src/slsqp.rs · Ported routine by routine
        Asserted
        SciPy’s exit message; x within 10⁻⁶ on Hock–Schittkowski problems 6, 7, 21, 35, 71 and 76.
        Measured
        The same final iteration count as SciPy on 15 of 16 cases (569367b2c).
      5. 05 trust-constrByrd–Omojokun SQP for equalities, a trust-region interior point for the rest Python fsci-opt/trust_constr.rs Asserted
        SciPy runs
        SciPy’s _trustregion_constr package, with its projections and memoized function wrappers.
        FrankenSciPy
        crates/fsci-opt/src/trust_constr.rs · Ported routine by routine
        Asserted
        Status and message; x to 10⁻⁵, f to 10⁻⁷, Lagrange multipliers to 10⁻⁴.
      6. 06 Trust-region Newtontrust-ncg, dogleg, trust-exact and trust-krylov: four subproblem solvers, one driver Python fsci-opt/trust_region.rs AssertedMeasured
        SciPy runs
        SciPy’s _minimize_trust_region with CG–Steihaug, dogleg, Moré–Sorensen and GLTR subproblems.
        FrankenSciPy
        crates/fsci-opt/src/trust_region.rs · Ported routine by routine
        Asserted
        SciPy’s status; x and f to tolerance; iteration count within 30%.
        Measured
        All 30 cases matched SciPy’s exact iteration, function, gradient and Hessian counts.
      7. 07 Radau IIA and BDFThe implicit solve_ivp methods for stiff problems Python fsci-integrate/radau.rs AssertedMeasured
        SciPy runs
        SciPy’s _ivp/radau.py and _ivp/bdf.py, step for step.
        FrankenSciPy
        crates/fsci-integrate/src/radau.rs · Ported routine by routine
        Asserted
        y within one unit of SciPy’s error scale; evaluation and step counts within 1%.
        Measured
        15 of 16 finite-difference rows reproduce SciPy’s counts exactly.
      8. 08 DOP853The explicit eighth-order Runge–Kutta method, with dense output Python fsci-integrate/rk.rs Asserted
        SciPy runs
        SciPy’s _ivp/rk.py, with Hairer’s coefficients and its blended E5/E3 error norm.
        FrankenSciPy
        crates/fsci-integrate/src/rk.rs · Ported routine by routine
        Asserted
        y within one unit of SciPy’s error scale wherever SciPy’s own answer is reproducible at that scale.
      9. 09 solve_bvpBoundary-value problems by collocation with mesh refinement Python fsci-integrate/collocation.rs AssertedMeasured
        SciPy runs
        Kierzenka and Shampine’s algorithm, transcribed from SciPy’s _bvp.py.
        FrankenSciPy
        crates/fsci-integrate/src/collocation.rs · Ported routine by routine
        Asserted
        SciPy’s status; one boundary-layer problem pinned at SciPy’s 7 iterations and 233 nodes.
        Measured
        The same iterations, node count and mesh on 9 problems (46c6065df).
      10. 10 Complex LAPACKLU, QR, Hessenberg, Schur and eigenvectors of complex matrices LAPACK fsci-linalg/complex.rs AssertedMeasured
        SciPy runs
        The LAPACK routines SciPy calls: zgetf2, zgeqr2 and zung2r, zgebal, zgehd2 and zunghr, zlahqr, ztrevc3.
        FrankenSciPy
        crates/fsci-linalg/src/complex.rs · Ported routine by routine
        Asserted
        Factors entry by entry to 10⁻¹², with SciPy’s pivots, signs and eigenvalue order.
        Measured
        198 cases within 6.8 × 10⁻¹⁵ (7ec9bee19).
      11. 11 Jonker–Volgenantlinear_sum_assignment: the cheapest one-to-one assignment C++Same algorithm fsci-opt/lib.rs Asserted
        SciPy runs
        The shortest augmenting path method SciPy uses, including rectangular cost matrices.
        FrankenSciPy
        crates/fsci-opt/src/lib.rs · Same algorithm
        Asserted
        The total cost to 10⁻¹²; ties between optimal assignments may pick different pairs.
      12. 12 eigsh and eigsA few eigenvalues of a large sparse matrix COwn algorithm fsci-sparse/linalg.rs Asserted
        SciPy runs
        SciPy calls ARPACK’s implicitly restarted Lanczos and Arnoldi; FrankenSciPy restarts with thick-restart Lanczos and Krylov–Schur.
        FrankenSciPy
        crates/fsci-sparse/src/linalg.rs · Own algorithm, same contract
        Asserted
        Eigenvalues, residuals and convergence status against ARPACK’s, for every which, shift-invert and a mass matrix.
      13. 13 linprogLinear programs with HiGHS’s result shape: slacks, residuals and marginals C++Own algorithm fsci-opt/linprog.rs AssertedMeasured
        SciPy runs
        SciPy calls HiGHS; FrankenSciPy has its own bounded revised simplex and a Mehrotra interior point with crossover.
        FrankenSciPy
        crates/fsci-opt/src/linprog.rs · Own algorithm, same contract
        Asserted
        Status and message for each of SciPy’s three HiGHS methods.
        Measured
        102 outcomes compared with none failing when it landed.
      10 ported routine by routine1 same algorithm2 own algorithm, same contract13 with an asserted check
      Languages are what SciPy 1.17.1’s own extension modules are built from; none of them links a Fortran runtime. “Asserted” means the test fails without it; “Measured” was logged when the work landed, with the commit linked.

      05Safe to embed

      Safe Rust from the API down to the kernels.

      All 19 crates forbid unsafe code, nothing links BLAS or LAPACK, and cargo build is the whole build, so the same crates run in a server, a CLI or this tab. Bad input comes back as a typed error, and the audited entry points record why.

      Two modes, one API

      Strict for parity, hardened for services.

      Every mode-aware routine takes a RuntimeMode. Strict behaves as SciPy does, quirks included; Hardened keeps the signatures and refuses more. Neither repairs input: the caller gets a typed error, the ledger a reason.

      Mode handling in solve_with_audit

      Each input goes through solve_with_audit in both modes; switch off check_finite to see where they part

      fsci-linalgfsci-runtimeRuns in your browser
      • Hardened adds
      • NaN and ∞ even with check_finite off
      • rcond < 10⁻¹⁴ refused, not solved
      • > 10,000 rows or columns refused

      Running fsci-linalg…

      InputStrictHardened
      A NaN in the matrix3×3, one entry not a number

      …

      …

      A 10×11 matrixsolve needs a square one

      …

      …

      Hilbert 12×12rcond about 7 × 10⁻¹⁸

      …

      …

      b of the wrong length4×4 matrix, 3 values in b

      …

      …

      Rows of different lengths3, 2 and 3 entries

      …

      …

      A 10,001-row matrixdescribed, not sent

      No capresource budgets are the caller’s

      RefusedResourceExhausted

      resource_exhausted

      check_finite is SciPy’s switch for skipping the scan for NaN and infinity. audit_failclosed_property.rs drives all 49 audited APIs with bad input in every mode they have and asserts that each error is recorded as exactly one fail-closed event, the call’s last.

      The audit ledger

      An audit trail per call.

      The _with_audit entry points write every decision and refusal to a ledger the caller owns. Each event carries a BLAKE3 fingerprint of the routine and every input, hashed bit for bit, so 0.0 and −0.0 differ.

      Fingerprinter in fsci-runtime

      Change one entry of the matrix by a single bit and watch the solve’s fingerprint

      fsci-linalgfsci-specialfsci-fftfsci-runtimeRuns in your browser

      The system A·x = b

      The highlighted entry, A[0][2]

      x

      …

      Fingerprint of the solve

      with 0.0…

      now…

      The ledger, one JSON line per event

        One engine call runs four audited calls on a fresh ledger and returns its entries as serde writes them, timestamped by your browser’s clock. Only the solve reads the edited entry, so only its fingerprint is compared.

        Across platforms

        The same decisions on every platform.

        A last-bit difference matters where it tips a decision: one platform solves and another refuses. So the solver’s decision path computes exp and log10 with its own ports, built from +, −, × and ÷.

        The fix, in the changelog

        Compare each result from this tab with the build machine’s, value by value

        fsci-linalgfsci-specialfsci-statsfsci-integratefsci-fftnative buildRuns in your browser

        Running the battery…

        • same bits
        • different bits
          The build machine ran the same engine source compiled natively for arm64 macOS (commit d2b206d3d796); WebAssembly arithmetic is the same on every CPU. The values that differ come from the platform’s math library: LSODA’s powf and the FFT’s sin and cos.
          How the decision path stays the same everywhere

          exp and log10 come from the runtime’s own FDLIBM and musl ports, so they return the same bits on every platform. For matrices up to 4×4, rcond is computed with one-sided Jacobi rather than an SVD that calls the platform’s math library.

          Where the platform library is still used, the differences stay far below the tolerances: LSODA takes the same 236 steps and 453 evaluations in both builds, and its final state differs by at most 1.6 × 10⁻¹³, against its default rtol of 10⁻³ and atol of 10⁻⁶.

          What runs this page

          The engine in this tab.

          Every live figure calls fsci-web: ten FrankenSciPy crates compiled for wasm32-wasip1 and run through a small WASI shim. It reads one JSON request, writes one reply, and never reaches the network.

          The engine’s source

          These numbers come from your browser, and the call count rises as you use the page

          fsci-runtimeRuns in your browser

          Live, from this browser

          Engine, as delivered…compressed over the network
          Engine, unpacked…WebAssembly bytes
          Fetched and compiled…once per page
          Calls on this page…every live figure
          Time inside the engine…summed over those calls
          Built from…
            Size and transfer come from the browser’s Resource Timing entry for the engine, compile time from the first fetch to a compiled module, and each call’s time from the program’s start to its exit.

            06Performance

            Faster in places, slower in others, all measured.

            Every timing here comes from one run on one machine, FrankenSciPy and SciPy 1.17.1 side by side. Batched calls and structured stiff solves win by large factors; dense eigensolves, sparse LU and sparse addition still lose to the LAPACK, SuperLU and C++ code SciPy calls.

            Same-run ratios

            Wins and losses, on one scale.

            Batched calls SciPy can only loop, and solvers that use structure SciPy ignores, win by one to two orders of magnitude. Plain dense and sparse linear algebra still loses. Open any row for its setup and source.

            The performance ledger

            Filter the rows, then open one to see what was timed and where it is recorded

            repositoryFrom the repository

            12 faster 6 slower

            1. curve_fit_manyBatched API2,000 exponential-decay fits145×faster, FrankenSciPy faster. Open for the setup.

              One call fits all 2,000 traces. SciPy ran five public routes to the same answers and the fastest, a joint sparse least-squares solve over the whole study, is the one compared: 633.3 ms against 4.38 ms. 32 pinned cores.

              A batched API SciPy does not have. Each row of the batch is bit-identical to a single curve_fit call.

              SciPy ÷ FrankenSciPy = 145.1, 95% interval 135.7 to 150.82026-09-10perf_ledger_cc.md, line 1,575

            2. minimize_manyBatched APIBFGS from 128 starts102×faster, FrankenSciPy faster. Open for the setup.

              Against SciPy's BFGS with the exact analytic gradient, the fastest of four public routes: 748.8 ms against 7.35 ms. 32 pinned cores.

              Multistart is common in global optimization; SciPy runs the starts one at a time.

              SciPy ÷ FrankenSciPy = 101.6, 95% interval 98.70 to 103.22026-09-10perf_ledger_cc.md, line 1,648

            3. spsolveSparse directperiodic 9×11×13 grid, 32 solves84×faster, FrankenSciPy faster. Open for the setup.

              Against scipy.sparse.linalg.spsolve, one thread each: 6.08 ms against 510.1 ms.

              The same public call was 124.7× slower before its periodic structure was recognized.

              SciPy ÷ FrankenSciPy = 84.16, 95% interval 83.49 to 84.632026-08-19NEGATIVE_EVIDENCE.md, line 38,295

            4. solve_ivp, BDFStructuren = 512, diagonal Jacobian39×faster, FrankenSciPy faster. Open for the setup.

              Against solve_ivp(method='BDF') at the same tolerances: 13.6 ms against 522.2 ms.

              The win comes from noticing the Jacobian is diagonal. SciPy runs a dense LU on every refresh.

              SciPy ÷ FrankenSciPy = 38.80, 95% interval 37.23 to 40.242026-07-28perf_ledger_cc.md, line 3,908

            5. solve_ivp, BDFStructuren = 512, tridiagonal Jacobian12×faster, FrankenSciPy faster. Open for the setup.

              Same harness and size, a tridiagonal Jacobian solved through the banded path: 43.1 ms against 514.9 ms.

              Less structure, smaller win. The dense row further down is the same experiment with none.

              SciPy ÷ FrankenSciPy = 11.91, 95% interval 11.67 to 12.182026-07-28perf_ledger_cc.md, line 3,909

            6. tplquad_manyBatched API100 triple integrals7.1×faster, FrankenSciPy faster. Open for the setup.

              Against vectorized cubature on a persistent 32-worker process pool, SciPy's fastest public route: 14.24 ms against 2.03 ms.

              Batched quadrature over a parameter sweep.

              SciPy ÷ FrankenSciPy = 7.080, 95% interval 6.284 to 7.2862026-09-10perf_ledger_cc.md, line 1,788

            7. quad_manyBatched API2,048 integrals5.8×faster, FrankenSciPy faster. Open for the setup.

              Against quad on a persistent 32-worker process pool: 7.64 ms against 1.32 ms.

              A damped frequency-response study, one integral per parameter set.

              SciPy ÷ FrankenSciPy = 5.784, 95% interval 5.651 to 5.9412026-09-10perf_ledger_cc.md, line 1,719

            8. normaltest, jarque_bera, shapiroBatched API2,048 channels × 4,096 samples4.9×faster, FrankenSciPy faster. Open for the setup.

              Batched normality screening against a persistent 32-worker process pool: 83.8 ms against 17.0 ms.

              Re-measured in September after the ledger retired the earlier 74–2,267× claims.

              SciPy ÷ FrankenSciPy = 4.914, 95% interval 4.892 to 4.9232026-09-10perf_ledger_cc.md, line 1,866

            9. gmresIterativen = 1,0244.9×faster, FrankenSciPy faster. Open for the setup.

              Nonsymmetric convection-diffusion, rtol = 1e-5. Both sides did the same 127 inner iterations: 2.36 ms against 11.55 ms.

              Same algorithm, same iteration count; the difference is per-iteration cost.

              SciPy ÷ FrankenSciPy = 4.885, 95% interval 4.870 to 4.8942026-07-29NEGATIVE_EVIDENCE.md, line 67

            10. dblquad_manyBatched API128 double integrals3.5×faster, FrankenSciPy faster. Open for the setup.

              Against vectorized cubature on a 32-worker process pool: 4.19 ms against 1.20 ms.

              Just above the project's 3× bar for calling a win durable.

              SciPy ÷ FrankenSciPy = 3.467, 95% interval 3.420 to 3.6182026-09-10perf_ledger_cc.md, line 1,754

            11. newton_manyBatched API65,536 implied volatilities1.99×faster, FrankenSciPy faster. Open for the setup.

              Against array newton on a 32-worker process pool: 13.07 ms against 6.56 ms.

              Faster, but under the 3× bar, so the ledger does not call it a durable win.

              SciPy ÷ FrankenSciPy = 1.991, 95% interval 1.969 to 2.0392026-09-10perf_ledger_cc.md, line 1,821

            12. gmresIterativen = 4,0961.57×faster, FrankenSciPy faster. Open for the setup.

              The same problem on a larger grid, 163 inner iterations each: 13.90 ms against 20.79 ms.

              The lead shrinks as the problem grows.

              SciPy ÷ FrankenSciPy = 1.573, 95% interval 1.568 to 1.5912026-07-29NEGATIVE_EVIDENCE.md, line 68

            13. gmresIterativen = 9,2161.06×slower, SciPy faster. Open for the setup.

              Larger still, 227 inner iterations each: 38.33 ms against 36.06 ms.

              Here SciPy is ahead, by 6%.

              SciPy ÷ FrankenSciPy = 0.940, 95% interval 0.938 to 0.9412026-07-29NEGATIVE_EVIDENCE.md, line 69

            14. choleskyDensen = 8321.61×slower, SciPy faster. Open for the setup.

              A = MMᵀ + nI, FrankenSciPy on all 64 threads against SciPy's threaded LAPACK.

              One cell of a measured loss band from n ≈ 576 to 1,280. FrankenSciPy wins again at n = 2,048.

              SciPy ÷ FrankenSciPy = 0.6212026-08-19NEGATIVE_EVIDENCE.md, line 38,709

            15. solve_ivp, BDFDensen = 512, dense Jacobian2.1×slower, SciPy faster. Open for the setup.

              The BDF experiment above with no exploitable structure: 1,086.7 ms against 513.5 ms. 129 LU factorizations against LAPACK's dgetrf, and 1.9× as many right-hand-side evaluations.

              On a dense stiff problem FrankenSciPy is 2.1× slower. Its BDF wins only where structure lets it.

              SciPy ÷ FrankenSciPy = 0.472, 95% interval 0.464 to 0.4792026-07-28perf_ledger_cc.md, line 3,910

            16. splu, solve stageSparse directn = 16,384, 16 right-hand sides2.3×slower, SciPy faster. Open for the setup.

              Convection-diffusion against SuperLU, one thread each, default settings: 52.0 ms for the 16 solves.

              Declaring the 16 solves up front makes the solve stage 1.61× faster than SuperLU, at a cost of 1.29× on the factorization.

              SciPy ÷ FrankenSciPy = 0.442, 95% interval 0.435 to 0.4492026-08-30NEGATIVE_EVIDENCE.md, line 42,621

            17. eighDensen = 7683.6×slower, SciPy faster. Open for the setup.

              Dense symmetric eigendecomposition against SciPy with one BLAS thread: 3.63× slower.

              The worst dense cell. 61.5% of the time is the eigenvector back-transform; a blocked rewrite of it was measured slower and rejected.

              SciPy ÷ FrankenSciPy = 0.2762026-08-27commit 932bd498a

            18. COO additionSparse direct28,672², two 1-million-entry operands16×slower, SciPy faster. Open for the setup.

              192.5 ms against SciPy's 12.0 ms.

              The shipped path is still the slow one: a faster merge reached only 0.49× of SciPy and was reverted (see below).

              SciPy ÷ FrankenSciPy = 0.06232026-08-02perf_ledger_cc.md, line 13,866

            Each bar is SciPy’s time over FrankenSciPy’s on a log scale from 0.04 to 250, with a whisker for the bootstrap 95% interval where the ledger gives one. Rows come from different machines and harnesses, so compare them by direction and rough size.
            Which rows are here, and which are not

            A row qualifies only if FrankenSciPy and SciPy 1.17.1 were timed in the same invocation on the same machine; beating FrankenSciPy’s own older code does not count. The ledger marks some older fsci-stats, signal, cluster, interpolate, io and fft rows as unverified at the current commit, and they are left out, as is root_many, whose SciPy timing failed its own noise check.

            Because the rows were measured on different days, machines and thread counts, the board is a map of where each side is strong, not one benchmark. A single scoreboard re-measured at one commit is in progress, tracked as frankenscipy-sw4p0.2.

            The optimization loop

            A speedup counts when it beats SciPy.

            Every claimed speedup goes through the same five steps, and the ledger keeps failures as carefully as wins. Two real changes: one kept, one reverted after making the code 7.8× faster, because it still lost to SciPy.

            The negative-evidence log

            Follow two real changes through the same five steps

            repositoryWorked example

            KeptPeriodic sparse solvethe ledger entry

            1. 1Baseline124.7×slower than SciPy
            2. 2ProfileLUon every call; the periodic Fourier path sat unused
            3. 3One leverFFTreuse the periodic recognizer and Fourier plan
            4. 4Prove32 / 32calls took the new route; 0 components differ
            5. 5Re-measure84.2×faster than SciPy: 6.08 ms against 510.1 ms
            6. ✓DecideKeepthe 67.6× over the old code is logged as maintenance

            RevertedSparse additionthe ledger entry

            1. 1Baseline16×slower than SciPy: 192.5 ms against 12.0 ms
            2. 2Profiletreeboth operands cloned, merged through an ordered tree
            3. 3One lever1 passmerge the two sorted operands linearly
            4. 4Provebit for bitsame matrix as SciPy: pointers, indices, floats
            5. 5Re-measure2.05×still slower than SciPy, though 7.8× faster than before
            6. ✓DecideRevertrestored byte for byte; the result stays in the ledger
            The kept change is in NEGATIVE_EVIDENCE.md (2026-08-19), the reverted one in perf_ledger_cc.md (2026-08-02). In both, SciPy 1.17.1 was timed in the same run as the candidate and the old code.
            Every step as the ledger records it

            Kept · Periodic sparse solve

            1. Baseline. Public spsolve on a shifted periodic cuboid, one factor and solve per right-hand side: 124.7× slower than SciPy.
            2. Profile. The one-shot call took the general sparse factorization every time. The crate already had a recognizer for periodic grids and a Fourier plan; this path never used them.
            3. One lever. Reuse the periodic recognizer and Fourier plan inside spsolve, falling back to LU when the true residual is too large.
            4. Prove. The new route fired on 32 of 32 calls. Largest relative residual 2.1 × 10⁻¹², against SciPy’s 1.5 × 10⁻¹²; no component disagreed.
            5. Re-measure. 6.08 ms against SciPy’s 510.1 ms: 84.2× faster. The 67.6× over the old code is recorded separately, as maintenance.
            6. Decide. Kept: the route ships, and the row joins the scoreboard above.

            Reverted · Sparse addition

            1. Baseline. Adding two 1-million-entry COO matrices, 28,672 square: 192.5 ms, against SciPy’s 12.0 ms.
            2. Profile. The public addition cloned both operands and merged their entries through an ordered tree.
            3. One lever. Merge the two sorted operands in one linear pass instead of through the tree.
            4. Prove. The candidate, the old path and SciPy produced the same sparse matrix, every pointer, index and float bit for bit.
            5. Re-measure. 24.6 ms: 7.8× faster than the old code, and still 2.05× slower than SciPy’s 12.0 ms. The gate requires beating SciPy.
            6. Decide. Reverted: the code is restored byte for byte in a new commit, so the attempt stays in the history and the result stays in the ledger.

            The decision is taken on the bootstrap-median interval, which must clear twice the noise of timing each side against itself. The kept change’s parity is in the same entry, and the loss it closed here; the reverted change’s timings are here.

            07Get started

            Add a crate. Keep your Rust.

            Every fsci-* crate is on crates.io at version 0.5.2. Add the ones you need: each brings in only the fsci crates it depends on, and none of them brings in Python, a BLAS or a LAPACK.

            Version 0.5.2

            Pick the crates, copy one line.

            Tick the crates you need and copy one cargo add line, or copy any crate on its own. Eleven of the eighteen need nightly Rust; the repository pins nightly-2026-08-31.

            Installation in the README

            Tick the crates you need, then copy the command or the Cargo.toml lines

            repositorysymbol censusFrom the repository

            Your command

            cargo add fsci-linalg fsci-stats

            Cargo also builds fsci-fft, fsci-integrate, fsci-opt, fsci-runtime, fsci-sparse, fsci-special, which they depend on.

            Or in Cargo.toml

            [dependencies]
            fsci-linalg = "0.5"
            fsci-stats = "0.5"

            Toolchain: rustup toolchain install nightly-2026-08-31, then a rust-toolchain.toml naming it in your project.

            • Linear algebra decompositions, solvers, and eigenvalues.

              79 of 103 SciPy names compared live

              linalglinalg.interpolative

              80k lines · 920 tests

              crates.io

            • Probability distributions and statistical tests.

              262 of 358 SciPy names compared live

              statsstats.contingencystats.mstatsstats.qmcstats.sampling

              156k lines · 2,654 tests

              crates.io

            • Special mathematical functions.

              211 of 358 SciPy names compared live

              special

              85k lines · 1,407 tests

              crates.io

            • Optimization and root-finding solvers.

              34 of 77 SciPy names compared live

              differentiateoptimizeoptimize.elementwise

              84k lines · 937 tests

              crates.io

            • Numerical integration and ODE/IVP solvers.

              15 of 32 SciPy names compared live

              integrate

              57k lines · 690 tests

              crates.io

            • Sparse matrices and iterative solvers.

              78 of 114 SciPy names compared live, 2 missing

              sparsesparse.csgraphsparse.linalg

              98k lines · 1,004 tests

              crates.io

            • Signal processing, filter design, and spectral analysis.

              92 of 182 SciPy names compared live

              signalsignal.windows

              46k lines · 831 tests

              crates.io

            • Fast Fourier Transform routines.

              30 of 47 SciPy names compared live

              fftfftpack

              14k lines · 266 tests

              crates.io

            • Interpolation and spline routines.

              15 of 56 SciPy names compared live

              interpolate

              30k lines · 318 tests

              crates.io

            • Spatial data structures and distance computations.

              30 of 49 SciPy names compared live

              spatialspatial.distancespatial.transform

              20k lines · 329 tests

              crates.io

            • Vector quantization and hierarchical clustering.

              12 of 35 SciPy names compared live

              cluster.hierarchycluster.vq

              18k lines · 224 tests

              crates.io

            • Multi-dimensional image processing routines.

              39 of 75 SciPy names compared live

              ndimage

              33k lines · 373 tests

              crates.io

            • File format I/O (MATLAB, Matrix Market, WAV).

              12 of 30 SciPy names compared live, 4 missing

              ioio.arffio.matlabio.wavfile

              14k lines · 162 tests

              crates.io

            • Orthogonal Distance Regression.

              2 of 10 SciPy names compared live

              odr

              5.8k lines · 39 tests

              crates.io

            • Physical and mathematical constants.

              5 of 7 SciPy names compared live

              constants

              1.7k lines · 25 tests

              crates.io

            • Standard sample fixtures and datasets.

              0 of 5 SciPy names compared live

              datasets

              669 lines · 9 tests

              crates.io

            • Condition-Aware Solver Portfolio (CASP) runtime.

              CASP, the audit ledger and the Strict and Hardened modes. Add it to pass your own SolverPortfolio or AuditLedger to a call.

              9.5k lines · 414 tests

              crates.io

            • Reference Array API abstraction layer.

              The reference Array API backend and broadcasting rules the conformance suite checks against.

              5.1k lines · 64 tests

              crates.io

            Lines are wc -l over each crate’s src/ with inline tests, tests count #[test] functions, and the bar counts the SciPy names the census assigns to each crate. fsci-conformance (36,535 lines, 1,638 tests) is on crates.io too, but it is the test harness that drives a live SciPy; leave it out of your dependencies.
            Why most crates need nightly Rust

            fsci-cluster, fsci-linalg, fsci-ndimage, fsci-spatial, fsci-special, fsci-stats enable the unstable portable_simd feature for their vector kernels, so they and every crate that depends on them build only on a nightly toolchain. A crate is marked nightly when it, or one of the fsci crates it pulls in, enables an unstable feature.

            The repository pins nightly-2026-08-31 in its rust-toolchain.toml, and CI checks that the pin and the toolchain it installs agree. Pin the same one in your project to build exactly what the tests ran against.

            From Python

            The same call, spelled in Rust.

            Names and defaults follow SciPy, so most ports are mechanical. Pick an area to see everyday calls beside their Rust, with the use line to start from.

            The full migration table

            Pick an area of SciPy to see its calls next to their Rust equivalents

            repositoryWorked example

            Linear algebra

            use fsci_linalg::{eigh, expm, lstsq, solve, DecompOptions, LstsqOptions, SolveOptions};
            • x = scipy.linalg.solve(a, b)
              let x = solve(&a, &b, SolveOptions::default())?.x;

              a is a Vec<Vec<f64>>, one inner vector per row. The result also carries the CASP certificate and the backward_error.

            • x, res, rank, sv = scipy.linalg.lstsq(a, b)
              let r = lstsq(&a, &b, LstsqOptions::default())?;

              One struct instead of a four-tuple: r.x, r.residuals, r.rank, r.singular_values.

            • w, v = scipy.linalg.eigh(a)
              let r = eigh(&a, DecompOptions::default())?;

              r.eigenvalues in ascending order and r.eigenvectors as columns, as SciPy returns them.

            • e = scipy.linalg.expm(a)
              let e = expm(&a, DecompOptions::default())?;

              Padé approximation with scaling and squaring, the algorithm SciPy uses.

            Sparse

            use fsci_sparse::{cg, spsolve, CsrMatrix, IterativeSolveOptions, Shape2D, SolveOptions};
            • a = csr_matrix((data, indices, indptr), shape=(m, n))
              let a = CsrMatrix::from_components(Shape2D::new(m, n), data, indices, indptr, true)?;

              The last argument asks for sorted indices with duplicate entries summed.

            • x = spsolve(a, b)
              let x = spsolve(&a, &b, SolveOptions::default())?.solution;

              The result also names the backend and the fill-reducing ordering that were used.

            • x, info = cg(a, b)
              let r = cg(&a, &b, None, IterativeSolveOptions::default())?;

              info becomes r.converged, with r.iterations and r.residual_norm beside it. The third argument is the starting guess.

            Optimize

            use fsci_opt::{bfgs, brentq, lbfgsb, MinimizeOptions, RootOptions};
            • res = minimize(f, x0, method="BFGS")
              let res = bfgs(&f, &x0, MinimizeOptions::default())?;

              f is any Fn(&[f64]) -> f64. minimize(f, &x0, options) with method: Some(OptimizeMethod::Bfgs) does the same.

            • res = minimize(f, x0, method="L-BFGS-B",
                             bounds=[(0, None)] * n)
              let bounds = vec![(Some(0.0), None); n];
              let res = lbfgsb(&f, &x0, MinimizeOptions::default(), Some(&bounds))?;

              A bound is an (Option<f64>, Option<f64>) pair, and None leaves that side open.

            • root = brentq(f, a, b)
              let root = brentq(f, (a, b), RootOptions::default())?.root;

              The result also reports converged, iterations and function_calls.

            Integrate

            use fsci_integrate::{quad, solve_ivp, QuadOptions, SolveIvpOptions, SolverKind};
            • sol = solve_ivp(f, (0, 10), y0,
                              method="LSODA")
              let sol = solve_ivp(&mut f, &SolveIvpOptions {
                  t_span: (0.0, 10.0),
                  y0: &y0,
                  method: SolverKind::Lsoda,
                  ..Default::default()
              })?;

              f is an FnMut(f64, &[f64]) -> Vec<f64>. RK23, RK45, DOP853, Radau, BDF and LSODA are all there, with SciPy’s defaults.

            • val, err = quad(f, a, b)
              let r = quad(f, a, b, QuadOptions::default())?;

              r.integral and r.error, from a port of QUADPACK’s qagse, the routine SciPy calls.

            Signal and FFT

            use fsci_fft::{rfft, FftOptions};
            use fsci_signal::{butter, filtfilt, FilterType};
            • spec = scipy.fft.rfft(x)
              let spec = rfft(&x, &FftOptions::default())?;

              Each bin comes back as an (re, im) pair. SciPy’s normalization is the default.

            • b, a = butter(4, [lo, hi], btype="bandpass")
              let ba = butter(4, &[lo, hi], FilterType::Bandpass)?;

              Frequencies are normalized to Nyquist, as in SciPy. The coefficients are ba.b and ba.a.

            • y = filtfilt(b, a, x)
              let y = filtfilt(&ba.b, &ba.a, &x)?;

              Zero-phase filtering, forward then backward, with SciPy’s default padding.

            Statistics

            use fsci_stats::{ttest_ind_welch, BetaDist, ContinuousDistribution, Normal};
            • p = scipy.stats.norm.pdf(x, loc, scale)
              let p = Normal::new(loc, scale).pdf(x);

              The ContinuousDistribution trait has to be in scope for pdf, cdf, ppf and the moments.

            • q = scipy.stats.beta(2, 5).ppf(0.5)
              let q = BetaDist::new(2.0, 5.0).ppf(0.5);

              Distribution constructors panic on invalid parameters, the one documented exception to typed errors.

            • t, p = ttest_ind(a, b, equal_var=False)
              let t = ttest_ind_welch(&a, &b);

              Welch’s test is its own function; ttest_ind is the pooled-variance test, SciPy’s default.

            Special

            use fsci_runtime::RuntimeMode;
            use fsci_special::{elliprf, gamma, SpecialTensor};
            • g = scipy.special.gamma(x)
              let g = gamma(&SpecialTensor::RealScalar(x), RuntimeMode::Strict)?;

              Tensor functions take a scalar, a vector or complex values, plus a mode. RealVec evaluates a whole array in one call.

            • rf = scipy.special.elliprf(x, y, z)
              let rf = elliprf(x, y, z);

              The Carlson elliptic integrals are plain f64 functions.

            Spatial

            use fsci_spatial::KDTree;
            • d, i = KDTree(points).query(q)
              let (i, d) = KDTree::new(&points)?.query(&q)?;

              Index first, then distance: the reverse of SciPy’s tuple.

            Every Rust signature here was checked against the crate source at commit d2b206d3d. Functions returning Result are shown with ?; the error types are LinalgError, SparseError, OptError and so on, one per crate.
            1. 1

              Keyword arguments become an options struct

              Set the fields you would pass by keyword; Default holds SciPy’s defaults.

              # SciPy
              minimize(f, x0, tol=1e-10, options={"maxiter": 500})
              // FrankenSciPy
              MinimizeOptions {
                  tol: Some(1e-10),
                  maxiter: Some(500),
                  ..Default::default()
              }
            2. 2

              Tuples become named result structs

              Read fields by name instead of unpacking a tuple by position.

              # SciPy
              w, v = scipy.linalg.eigh(a)
              // FrankenSciPy
              let r = eigh(&a, opts)?;
              // r.eigenvalues, r.eigenvectors
            3. 3

              Portfolios and ledgers are explicit

              Plain solve keeps a portfolio per thread; pass your own, or a ledger, when you need one.

              # SciPy
              x = scipy.linalg.solve(a, b)
              // FrankenSciPy
              solve_with_audit(&a, &b, opts,
                               &mut portfolio, &ledger)?

            Honest scope

            When it fits, and when it doesn’t.

            FrankenSciPy is for Rust programs that need SciPy’s numerics. It does not replace SciPy for interactive work, and it does not try to beat vendor BLAS on large dense matrices.

            When to reach for it, in the README

            Reach for it when

            • A Rust service needs SciPy’s numerics without embedding Python.

            • An audit or a postmortem must show which algorithm produced a number.

            • No BLAS, LAPACK or Fortran in the build, and forbid(unsafe_code) in every fsci crate.

            • SciPy’s names and defaults in a synchronous, deterministic API.

            • An agent or a pipeline needs a record of every decision and refusal.

            Look elsewhere for

            • Exploring data in a notebook: SciPy, pandas and matplotlib fit better.

            • Calling it from Python: there is no Python binding today.

            • The fastest big dense linear algebra: a BLAS-backed stack wins there.

            • A GPU or a cluster: every routine runs on one machine’s CPU.

            • One of the six missing names, or a stable API: the crates are pre-1.0.

            Check a specific name in the lookup, the losses on the scoreboard, and the open defects in the README’s limitations.

            Open source · version 0.5.2

            Read the code. Run the tests.

            Everything on this page can be checked from a clone: the 783 differential tests, the 1,167 tolerance contracts, the census of SciPy’s public names and the CASP calibration corpus. The README separates what is implemented from what is planned, and lists the places where FrankenSciPy is still slower than SciPy. Bug reports with a failing input are the most useful thing you can send.

            git clone https://github.com/Dicklesworthstone/frankenscipy
            cd frankenscipy
            cargo test -p fsci-conformance   # the live-SciPy tests need SciPy 1.17.1 and NumPy 2.4.3