Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions scaling-check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Scaling exponents without logarithms

A check for the sentence "the exponent between two scales lies between p/q and r/s", made on the numbers a table prints.
Exploration, not peer reviewed, no new result claimed. `node scaling-check/table.mjs` prints the verdicts below in an
instant. `node scaling-check/table.mjs verify` (about 45 s) runs the two scripts that print the series and finds every
number again. `npm test` (`tests/scaling-check.mjs`) checks the comparison itself and the verdicts. Integers only, no
dependencies, Node 18 or later (it uses BigInt).

## What it does

A series is a list of scales x and values y, such as box sizes L and a magnetisation at each. The slope between two
scales a < b is the exponent in y ~ x^slope, taken over that stretch: ln(y_b / y_a) divided by ln(x_b / x_a).

For positive rationals and a rational p/q with q > 0:

> the slope between a and b is at least p/q exactly when (y_b / y_a)^q >= (x_b / x_a)^p.

Take natural logarithms of both sides and divide by the positive ln(x_b / x_a) to see it. Each side is a fraction raised
to an integer power, so the test is a comparison of two integers. No logarithm is taken, no float is made, nothing is
rounded, and a slope that equals p/q exactly counts as at least p/q. (For negative p the powers move to the other side.)
That powers can stand in for logarithms in a comparison of this kind is elementary. The same move is stated for a
bound on an entropy in Krohn-Grimberghe (2026, arXiv 2608.17376, section 6): "a claimed bound m/n on a rational power is
an integer inequality". Two web searches found no tool that applies it to scaling brackets. That is all this study
claims about prior work.

`check.mjs` asks whether the slope lies in a closed bracket [p1/q1, p2/q2], in three modes:

| Mode | What must lie in the bracket |
|---|---|
| window | the slope from the first scale to the last |
| steps | every slope between neighbouring scales |
| all pairs | every slope between any two scales |

Window is the loosest. Steps and all pairs are stricter, so they reject series that a fit over the whole range accepts:
they ask whether the exponent is steady along the range, not whether its average is right.

On exact values steps and all pairs always give the same verdict. The slope over a longer stretch is an average of the
step slopes inside it, weighted by ln(x_b / x_a), so it stays in any bracket that holds every step. All pairs is kept as
a cross-check of steps.

With error bars they can differ. Every step can fit the bracket while a longer stretch does not. Give each value a box
[L, U] with 0 < L <= U, and take a bracket [p1/q1, p2/q2] with q1, q2 > 0 and p1/q1 <= p2/q2. The question is whether
values inside the boxes exist with every step slope in the bracket.

The interval form of all pairs decides it exactly: for every i < j, (U_j / L_i)^q1 >= (x_j / x_i)^p1 and
(L_j / U_i)^q2 <= (x_j / x_i)^p2. This is the consistency test for a chain of difference constraints, the simple temporal
problem of Dechter, Meiri and Pearl (1991). Foundation-0/fractals draft pull request 60 states it and applies it.

The interval form is not a mode of `check.mjs`, which takes point values. `tests/scaling-check.mjs` pins a smallest case.
It has three scales, the fewest that can differ, since with two scales the only pair is the one step. The scales are 1,
2, 4, the bracket is [1, 1] and the boxes are [1, 1], [3/2, 5/2] and [9/2, 5]. Each step alone admits slope 1, and the
pair of the first and last scales does not.

`exponentInLog2` is the same test for a printed column that already holds base-2 logarithms of y at x = 2^n, such as
log2 <|u_n|^2> against shell n. The test then reads q (L_b - L_a) >= p (n_b - n_a), a comparison of decimals.

## What it certifies, and what it does not

It certifies a statement about the printed numbers: that the slopes the mode looks at, computed from exactly the
digits printed, lie in the bracket. The printed digits are rounded, and the verdict is about them as printed.

It says nothing about measurement error. A table with an error bar of 0.5% on each value gives a slope uncertain by about
as much, and the check does not know that. A bracket chosen narrower than that uncertainty can reject a correct
exponent, which is why steps and all pairs reject some series here. It says nothing about the physics: whether the
exponent should be there, whether the range is long enough, or whether a model is right.

## The series, and the verdict on each

Every number is printed by a script in this repository, and `series.mjs` pins the commit and the place. The brackets are
the published exponent plus and minus 1/100, 3/100 and 1/10. The last line of each block is the smallest half-width,
on a grid of 0.001, that each mode accepts. `node scaling-check/table.mjs` prints all of this, and `npm test` checks
the verdicts.

| Series (source: `node critical/table.mjs`, "At T_c", commit 48b923b) | Published | window | steps | all pairs |
|---|---|---|---|---|
| 2D Ising magnetisation, L = 8 to 128 | slope -1/8 (exact) | accepts at 0.001 | rejects at 1/100, accepts at 3/100 (0.023) | same as steps (0.023) |
| 2D Ising susceptibility, L = 8 to 128 | slope 7/4 (exact) | accepts at 0.001 | rejects at 1/100 and 3/100, accepts at 1/10 (0.032) | same as steps (0.032) |
| 2D Ising correlation G(L/2), L = 8 to 128 | slope -1/4 (exact) | accepts at 0.003 | rejects at 1/100 and 3/100, accepts at 1/10 (0.039) | same as steps (0.039) |
| Site percolation, spanning-cluster mass, L = 32 to 256, seed 401 (`node critical/table.mjs`, percolation table) | 91/48 | **rejects at 1/100**, accepts at 3/100 (0.024) | rejects at 3/100, accepts at 1/10 (0.039) | same as steps (0.039) |
| Sabra shell model, plain moment <\|u_n\|^2> against k_n = 2^n, shells 3 to 8 (`node turbulence/table.mjs quick`, last column, printed as log2) | zeta_2 = 0.720 | **rejects at 1/100 and 3/100**, accepts at 1/10 (slope 0.756, 0.036) | rejects at 1/10 (0.370) | same as steps (0.370) |

How to read the rows that reject:

- **Percolation, one seed.** The printed masses 398, 1442, 5308, 19546 give a window slope of 1.8727, below 91/48 = 1.8958
by 0.023. (The percolation table's own least-squares fit over the same four sizes prints 1.8735.) Two things bear on
it. This is the study seed alone, and the series starts at L = 32. `critical/README.md` quotes the nine-seed mean,
1.880 ± 0.002, 0.8% below 91/48, and explains it as a finite-size shortfall. From L = 64 on, this seed's window slope
is 1.8804, still 0.015 below 91/48 and still outside plus and minus 1/100. The check does not test the finite-size
explanation. And a bracket of plus and minus 1/100 is narrower than the shortfall the README already reports.
- **Sabra, plain moment.** The printed column gives a window slope of 0.756 over shells 3 to 8. It lies outside
0.720 ± 0.008 and outside the Kolmogorov value 2/3 ± 1/30. `turbulence/README.md` says the plain moments ripple from
shell to shell and are "printed but not used": its exponents come from the flux-based moments against the third one
(extended self-similarity), and its own table prints the plain-moment ζ₂ as 0.760. So the rejection restates a
difference the turbulence study already prints. L'vov et al.'s Table I gives ζ₂ = 0.720 for the plain moments
⟨|u_n|^q⟩ and 0.719 for the flux-based ones. They fitted both with a power law that bends into the dissipative range
(their eq. 44), over 34 shells, not with a straight slope over a few shells. So this row measures how far the straight
slope of the printed column is from 0.720. It is not a test of the model against their table.
- **Ising, steps and all pairs.** Each value is a Monte Carlo average with an error of 0.4% to 1.4%, and slopes between
neighbouring sizes (a factor of 2) move by a few hundredths. Rejection at 1/100 by these two modes is expected and
says the bracket is narrower than the noise.

## What is checked and what is not

- Checked by `npm test`: the comparison against 80-digit logarithms on 3,000 random cases, exact ties, the printed-log2
form against the ratio form, four must-fail controls, the verdict and the smallest half-width in the table for every
series, and that `scaling-check/table.mjs` runs and prints the same half-widths.
- Also checked by `npm test`: the three-scale case with error bars where steps pass and all pairs fail, its widened
twin, and two brackets that guard the interval inequality itself.
- Checked by `node scaling-check/table.mjs verify`, not by `npm test` (it runs the Monte Carlo): that every pinned number
is in what the two scripts print in the current checkout. At the pinned commit every one of them is.
- Not checked: that a different seed or a longer run gives the same verdicts.
108 changes: 108 additions & 0 deletions scaling-check/check.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Exponent brackets without logarithms or floats. For positive rationals, the slope between scales a < b is at least
// p/q exactly when (y_b / y_a)^q >= (x_b / x_a)^p (q > 0, p any integer). Both sides are rationals raised to integer
// powers, so the comparison is a comparison of BigInt integers: no rounding, and a tie is a tie.
// A rational is a pair [num, den] of positive integers (BigInt, or Number holding a safe integer).
// Used by scaling-check/table.mjs and tests/scaling-check.mjs. No dependencies.

const big = v => {
if (typeof v === 'bigint') return v;
if (typeof v === 'number' && Number.isSafeInteger(v)) return BigInt(v);
throw new TypeError(`expected an integer, got ${String(v)}`);
};
const rat = r => {
const n = big(r[0]), d = big(r[1]);
if (n <= 0n || d <= 0n) throw new RangeError('positive rationals only');
return [n, d];
};

// A decimal string such as "0.7819" or "-12.71" as [num, den] (num may be negative; den > 0). No float is made.
export function dec(s) {
const m = /^(-?)(\d+)(?:\.(\d+))?$/.exec(String(s).trim());
if (!m) throw new SyntaxError(`not a decimal: ${s}`);
const frac = m[3] || '';
const num = BigInt(m[2] + frac) * (m[1] ? -1n : 1n);
return [num, 10n ** BigInt(frac.length)];
}

// Sign (+1, 0, -1) of (y_b/y_a)^q - (x_b/x_a)^p, in integers only.
export function cmpPower(xa, xb, ya, yb, p, q) {
const Q = big(q), P = big(p);
if (Q <= 0n) throw new RangeError('q must be positive');
const [xan, xad] = rat(xa), [xbn, xbd] = rat(xb), [yan, yad] = rat(ya), [ybn, ybd] = rat(yb);
const ryn = ybn * yad, ryd = ybd * yan; // y_b / y_a
const rxn = xbn * xad, rxd = xbd * xan; // x_b / x_a
const lhs = P >= 0n ? ryn ** Q * rxd ** P : ryn ** Q * rxn ** -P;
const rhs = P >= 0n ? rxn ** P * ryd ** Q : rxd ** -P * ryd ** Q;
return lhs > rhs ? 1 : lhs < rhs ? -1 : 0;
}

// The pairs of points a mode looks at: 'window' the first and last, 'steps' each consecutive pair, 'pairs' every pair.
export function pairsFor(n, mode) {
if (mode === 'window') return [[0, n - 1]];
const out = [];
if (mode === 'steps') { for (let i = 0; i + 1 < n; i++) out.push([i, i + 1]); return out; }
if (mode === 'pairs') { for (let i = 0; i < n; i++) for (let j = i + 1; j < n; j++) out.push([i, j]); return out; }
throw new RangeError(`unknown mode: ${mode}`);
}

// True when every slope the mode looks at lies in the closed bracket [lo, hi]; lo and hi are [p, q] with q > 0.
export function exponentIn(xs, ys, lo, hi, mode = 'window') {
if (xs.length !== ys.length || xs.length < 2) throw new RangeError('need two or more points, xs and ys the same length');
for (const [i, j] of pairsFor(xs.length, mode)) {
if (cmpPower(xs[i], xs[j], ys[i], ys[j], lo[0], lo[1]) < 0) return false;
if (cmpPower(xs[i], xs[j], ys[i], ys[j], hi[0], hi[1]) > 0) return false;
}
return true;
}

// Same test when the printed values are base-2 logarithms of y at x = 2^n (a column such as log2 <|u_n|^2> against shell
// n). Then (y_b/y_a)^q >= (x_b/x_a)^p reads 2^(q dL) >= 2^(p dn), that is q dL >= p dn, with dL a difference of decimals.
// ns are integers, ls are [num, den] decimals (den > 0, num any sign). Integers only.
export function exponentInLog2(ns, ls, lo, hi, mode = 'window') {
if (ns.length !== ls.length || ns.length < 2) throw new RangeError('need two or more points, ns and ls the same length');
for (const [i, j] of pairsFor(ns.length, mode)) {
const dn = big(ns[j]) - big(ns[i]);
const [an, ad] = ls[i], [bn, bd] = ls[j];
const dLn = bn * ad - an * bd, dLd = ad * bd; // L_b - L_a = dLn / dLd, dLd > 0
// slope = dLn / (dLd dn); compare q * dLn against p * dLd * dn (dn > 0)
if (big(lo[1]) * dLn < big(lo[0]) * dLd * dn) return false;
if (big(hi[1]) * dLn > big(hi[0]) * dLd * dn) return false;
}
return true;
}

// Smallest half-width w = k/step, k = 0, 1, 2, ..., kMax, for which accepts(lo, hi, mode) holds on the bracket
// [e - w, e + w], or null if none up to kMax/step. e is [p, q]. accepts is exponentIn or exponentInLog2 with its data bound.
// Each trial is exact; the grid is the only coarseness.
export function tightestHalfWidth(accepts, e, mode, step = 1000, kMax = 1000) {
const p = big(e[0]), q = big(e[1]), st = BigInt(step);
for (let k = 0; k <= kMax; k++) {
const den = q * st;
if (accepts([p * st - BigInt(k) * q, den], [p * st + BigInt(k) * q, den], mode)) return [k, step];
}
return null;
}

// ---- reference used by the tests: natural logarithm of a positive rational to about 70 decimal digits, BigInt only.
const SCALE_DIGITS = 80n, S = 10n ** SCALE_DIGITS;
function atanhFixed(zn, zd) { // atanh(zn/zd) as fixed point, |zn/zd| < 1/5
const z = zn * S / zd, z2 = z * z / S;
let term = z, sum = 0n, k = 1n;
while (term !== 0n) { sum += term / k; term = term * z2 / S; k += 2n; }
return sum;
}
const LN2 = 2n * atanhFixed(1n, 3n);
export function lnFixed(num, den) { // ln(num/den) times 10^80, truncated
let n = big(num), d = big(den), k = 0n;
if (n <= 0n || d <= 0n) throw new RangeError('positive rationals only');
while (n * n > 2n * d * d) { d *= 2n; k += 1n; }
while (2n * n * n < d * d) { n *= 2n; k -= 1n; }
return k * LN2 + 2n * atanhFixed(n - d, n + d);
}
// Sign of q ln(y_b/y_a) - p ln(x_b/x_a), or 0 when its size is under 10^(-60) (a tie or too close to call).
export function cmpPowerByLogs(xa, xb, ya, yb, p, q) {
const [xan, xad] = rat(xa), [xbn, xbd] = rat(xb), [yan, yad] = rat(ya), [ybn, ybd] = rat(yb);
const v = big(q) * lnFixed(ybn * yad, ybd * yan) - big(p) * lnFixed(xbn * xad, xbd * xan);
const tiny = 10n ** (SCALE_DIGITS - 60n);
return v > tiny ? 1 : v < -tiny ? -1 : 0;
}
41 changes: 41 additions & 0 deletions scaling-check/series.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// The series the checker is applied to: numbers printed by this repository's own scripts, copied here as the strings the
// scripts print (rounded, as printed). Each series says which script prints it, at which commit, and where in the output,
// so `node scaling-check/table.mjs verify` can run the script and find every number again.
// Source commit for every number below: 48b923bd25dbcfef7fa8e8399d4144592145f0ef (main when this study was added).
import { dec, exponentIn, exponentInLog2 } from './check.mjs';
export const SOURCE_COMMIT = '48b923bd25dbcfef7fa8e8399d4144592145f0ef';

// 'critical' prints the Ising table "At T_c" (columns <|m|>, chi, G(L/2)) and the percolation table (spanning cluster).
// 'turbulence' is `node turbulence/table.mjs quick`, the cascade table's last column, log2 <|u_n|^2>.
export const SERIES = [
{ id: 'ising-m', kind: 'ratio', what: '2D Ising at T_c, magnetisation <|m|> against box size L', command: 'critical/table.mjs',
after: /^At T_c \(runs at/, col: 2, rows: [8, 16, 32, 64, 128],
x: [8, 16, 32, 64, 128], y: ['0.7819', '0.7060', '0.6537', '0.5975', '0.5520'],
published: [-1, 8], publishedLabel: 'beta/nu = 1/8, so slope -1/8 (Onsager, Yang: exact)' },
{ id: 'ising-chi', kind: 'ratio', what: '2D Ising at T_c, susceptibility chi = N<m^2> against L', command: 'critical/table.mjs',
after: /^At T_c \(runs at/, col: 5, rows: [8, 16, 32, 64, 128],
x: [8, 16, 32, 64, 128], y: ['41.8', '137.6', '469.2', '1572', '5337'],
published: [7, 4], publishedLabel: 'gamma/nu = 7/4 (exact)' },
{ id: 'ising-g', kind: 'ratio', what: '2D Ising at T_c, correlation G(L/2) against L', command: 'critical/table.mjs',
after: /^At T_c \(runs at/, col: 8, rows: [8, 16, 32, 64, 128],
x: [8, 16, 32, 64, 128], y: ['0.6324', '0.5177', '0.4421', '0.3706', '0.3139'],
published: [-1, 4], publishedLabel: 'eta = 1/4, so slope -1/4 (exact)' },
{ id: 'perc-mass', kind: 'ratio', what: 'site percolation at p_c, spanning-cluster mass against L (study seed 401, one seed)', command: 'critical/table.mjs',
after: /^Site percolation, open edges, spanning top to bottom/, col: 8, rows: [32, 64, 128, 256],
x: [32, 64, 128, 256], y: ['398', '1442', '5308', '19546'],
published: [91, 48], publishedLabel: 'D = 91/48 (den Nijs, Nienhuis et al.; proved for the triangular lattice)' },
{ id: 'sabra-u2', kind: 'log2', what: 'Sabra shell model (CI run), plain moment <|u_n|^2> against k_n = 2^n, shells 3 to 8, printed as log2', command: 'turbulence/table.mjs quick',
after: /^ {2}n {3}Pi_n\/eps/, col: 4, rows: [3, 4, 5, 6, 7, 8],
x: [3, 4, 5, 6, 7, 8], y: ['-8.93', '-9.43', '-10.52', '-10.94', '-11.85', '-12.71'],
published: [-18, 25], publishedLabel: "zeta_2 = 0.720 +- 0.008 (L'vov et al. 1998, moments of u); slope -0.720" },
];

// The check bound to a series: (lo, hi, mode) -> true when every slope the mode looks at lies in [lo, hi], lo and hi [p, q].
export function acceptor(s) {
if (s.kind === 'log2') {
const ls = s.y.map(dec);
return (lo, hi, mode) => exponentInLog2(s.x, ls, lo, hi, mode);
}
const xs = s.x.map(v => [BigInt(v), 1n]), ys = s.y.map(v => { const [n, d] = dec(v); return [n, d]; });
return (lo, hi, mode) => exponentIn(xs, ys, lo, hi, mode);
}
Loading