Skip to content

Dimensional analysis of a formula: MathS.Dimensions.Of and DimensionlessGroups, with a page - #2490

Merged
Rafael-SOWNet merged 3 commits into
masterfrom
feat/dimensional-analysis-2
Nov 16, 2026
Merged

Rafael-SOWNet merged 3 commits into
masterfrom
feat/dimensional-analysis-2

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

MathS.Dimensions.Of(expr, dims) and MathS.Dimensions.DimensionlessGroups(vars, dims): given the dimension of each variable over the seven SI base dimensions, with rational exponents, say whether a formula is physically meaningful, what dimension it has, and where it stops making sense; and give the Buckingham π groups of a set of variables. The design as #2292 sets it out: the dimension map is passed, not attached to variables, so nothing about printing, parsing or simplification changes; the answer is Consistent (with the dimension), Inconsistent (with the subexpression and why) or Undetermined (an undeclared variable, a node it does not read, a dimensional base to a symbolic power), never a guess; nothing is simplified first; a literal 0 or oo fits any dimension where added or compared. Kernel placement per Packaging.md §4: no dependency, nothing on a default path.

Three commits, meant to be merged as they are (rebase, not squash):

  1. MathS.Dimensions.Of and DimensionlessGroups — from feat/dimensional-analysis, rebased onto master.
  2. The catalogue entries dimension and dimensionless_groups, not offered by the terminal or the MCP server yet (The MCP server and the terminal should offer dimensional analysis and shader source once #2292 and #2293 land #2298), as the shaders are not.
  3. Every node type there is, and a page. The walk read any function it did not name as a function of pure numbers, which made dot, cross, det, trace, transpose, an entry and norm count as transcendental: dot([h, d], [v, v]) came back inconsistent where it is L²T⁻¹. Every arm now names a concrete node type and the last one is Undetermined; EveryNodeTypeHasADecidedReading builds a sample of every concrete Entity type by reflection and checks its verdict, so a new node fails it by name.
reading nodes
sides agree, keep the dimension sum, difference, mod, max, min (a literal 0 or oo fits any)
dimensions multiply or divide product, quotient, dot, cross
power exponent pure, and rational on a dimensional base; symbolic is Undetermined
keep the argument's dimension abs, conjugate, re, im, trace, transpose, norm, an entry
pure arguments, pure result trigonometric, logarithm, erf…, zeta, beta, gamma functions, combinatorial and number-theoretic functions, statements
calculus a derivative (and partialderivative) divides by the variable's dimension to the n-th power; an integral multiplies by it and checks the bounds; a limit checks its point
a product over a range or a finite set D^count where the count is written, else Undetermined
not read sets on their own, argmax/argmin, lambda, application, and any future node: Undetermined

The π groups, each checked by hand, run back through Of (all Consistent: 1), and counted against n − rank: the pipe, mu / (rho * v * d), 1 group; the pendulum, g * t ^ 2 / l, 1; drag, F / (rho * v ^ 2 * d ^ 2) and mu / (rho * v * d), 2; water waves, k * A, k * h, k * g * t ^ 2, 3. omega^2 = g k tanh(k h) is Consistent: 1, and the shallow-water slip A sin(k x - sqrt(g k h) t) is inconsistent at the phase, L^(1/2) against 1.

Docs/Usage/Dimensions.md: the rules and the free-fall, Reynolds and water-wave examples; its 4 samples pass docsamples. BREAKING-CHANGES.md: a "Not silent: a new entry point" entry, as #2470's. No existing answer moves.

DimensionsTest: 63 cases. Full check on this commit: 21,102 unit tests, 0 failed; MCP 459, Terminal 69, F# 135, Interactive 19; AOT OK; BoundCheck 0 disagreements, RootCheck 596/596, CasBench 120/121 with 0 wrong, PropCheck clean, SimpSweep 10463/10463, RuleCheck clean, CanonCheck, Confluence and the Modenov corpus at their baselines.

Closes #2292.

🤖 Generated with Claude Code

Rafael-SOWNet and others added 3 commits November 16, 2026 12:16
Given the dimension of each variable over the seven SI base dimensions,
MathS.Dimensions.Of says whether a formula is physically meaningful, what
dimension it has, and which subexpression breaks it and why. The verdict is
three-valued: Undetermined, for an undeclared variable, a node the check does
not read, or a dimensional base raised to an unknown power, is not a guess.
Nothing is simplified first, and a literal 0 or oo fits any dimension where it
is added or compared.

MathS.Dimensions.DimensionlessGroups gives a basis of the Buckingham pi groups
from the exact null space of the dimension matrix, in smallest whole powers,
each checked to be dimensionless before it is returned.

The dimension map is passed rather than attached to variables, so printing,
parsing and simplification are unchanged and the type layer of #1237 is not
pre-empted. No clause of Packaging.md section 4 fires, so it is kernel code.
No existing answer changes.

Measured: UnitTests 18258 passed, 13 skipped, 0 failed (net10.0);
FSharpWrapperUnitTests 134 passed; kernel builds warning-free on
netstandard2.0, net8.0 and net10.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oups

AGENTS.md: an operation the library offers by name is an entry of the
catalogue. The two queries answer what MathS.Dimensions.Of and
DimensionlessGroups answer, which CatalogueTest checks on an input where
the two dimension answers differ. No surface offers them yet: the MCP
server's Tools.NotOffered and the terminal's OneShot.notOffered list them,
pointing at #2298, which proposes am_dimensions.

Part of #2292.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The walk named no node types added since it was written, and read any
Function it did not name as a function of pure numbers: dot, cross,
det, trace, transpose, a matrix entry and norm were each taken for
transcendental. Every arm now names a concrete node type and the last
one reports Undetermined, so a node added later is not read as a pure
number by default. DimensionsTest.EveryNodeTypeHasADecidedReading lists
the verdict on a sample of every concrete node type and fails, by name,
on one it does not list.

The new rules: dot and cross multiply dimensions; norm, trace,
transpose and a matrix entry keep the entries' dimension; a matrix is
read where its entries share one and is undetermined where they do not;
det of a written n by n matrix is D^n; partialderivative divides by the
slot's dimension; a product over 1..n of dimension D is D^n for written
bounds; zeta, beta, the exponential and error integrals, W, polygamma,
gcd/lcm and the rest of number theory, the connectives and iverson take
pure numbers. A variable ranging over a set (a sum or product over a
set, max/min, forall/exists, x in S, argmax, indexed unions) takes the
dimension the set's members share; a number set fits a declared
variable of any dimension and makes an undeclared one a pure number.
A set on its own, lambda and application stay undetermined.

Docs/Usage/Dimensions.md has the rules and the issue's examples, the
water wave among them; its four samples pass docsamples. A BREAKING
entry records the new entry point, as #2470 did for the shaders.

Part of #2292.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.98660% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.91%. Comparing base (ee728a4) to head (5e76939).

Files with missing lines Patch % Lines
...ouriMath/Functions/Dimensions/DimensionAnalysis.cs 82.92% 21 Missing and 21 partials ⚠️
...rces/AngouriMath/Functions/Dimensions/Dimension.cs 84.44% 4 Missing and 3 partials ⚠️
...riMath/Functions/Dimensions/DimensionlessGroups.cs 87.93% 4 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2490      +/-   ##
==========================================
- Coverage   86.92%   86.91%   -0.01%     
==========================================
  Files         331      336       +5     
  Lines       73195    73567     +372     
  Branches    21326    21411      +85     
==========================================
+ Hits        63622    63938     +316     
- Misses       5151     5180      +29     
- Partials     4422     4449      +27     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.42% <84.90%> (-0.02%) ⬇️
fsharp 32.79% <ø> (ø)
interactive 40.09% <100.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ources/AngouriMath/Convenience/MathS.Dimensions.cs 100.00% <100.00%> (ø)
Sources/AngouriMath/Core/Operations/Catalogue.cs 100.00% <100.00%> (ø)
...AngouriMath/Functions/Dimensions/DimensionCheck.cs 100.00% <100.00%> (ø)
...urces/Terminal/AngouriMath.Terminal.Lib/OneShot.fs 69.87% <100.00%> (+0.19%) ⬆️
...rces/AngouriMath/Functions/Dimensions/Dimension.cs 84.44% <84.44%> (ø)
...riMath/Functions/Dimensions/DimensionlessGroups.cs 87.93% <87.93%> (ø)
...ouriMath/Functions/Dimensions/DimensionAnalysis.cs 82.92% <82.92%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Rafael-SOWNet
Rafael-SOWNet merged commit d2eaa25 into master Nov 16, 2026
35 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the feat/dimensional-analysis-2 branch November 16, 2026 13:14
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Dimensional analysis of a formula: MathS.Dimensions.Of and DimensionlessGroups

1 participant