Skip to content

Compiled max and min have no value off the real line - #2311

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
compiled-max-and-min-have-no-value-off-the-real-line
Nov 1, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
compiled-max-and-min-have-no-value-off-the-real-line

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

#2304 made max and min defined only where both arguments are real, so max(i, i), and max(x, x) at a complex x, have no value. The compiled forms didn't follow. FastExpression and the LINQ compiler over Complex share RealOnly.Ordered, which returned an argument equal to the other before it asked whether either was real. The interpreter used to do the same. The check for a non-real argument now comes first.

at x = 0.5 + 1.2i evaluated compiled, 2.6.0 and master now
max(x, x) NaN <0.5; 1.2> <NaN; NaN>
min(x, x) NaN <0.5; 1.2> <NaN; NaN>
max(x, x) * 2 NaN <1; 2.4> <NaN; NaN>
  • Found by work/compilesweep. On its default 3000 expressions it lists 112 findings on master and 93 here. The 19 that go are all max or min at a complex point, and none is added. The max/min findings that remain have other causes: a 1e-16 imaginary part left by rounding, Im of NaN, 0 mod x at a complex x.
  • Real arguments are unchanged. The BREAKING-CHANGES.md entry for DomainCondition disagrees with the value for five nodes #2256 gains the compiled row.
  • The three new cases fail on master. The suite, the trio, F#, AOT and the eight harnesses pass.

Follows #2304, for #2256.

🤖 Generated with Claude Code

#2304 made max and min defined only where both arguments are real, so max(i, i) and
max(x, x) at a complex x have no value. The compiled forms, FastExpression and LINQ over
Complex, share RealOnly.Ordered, which returned an argument equal to the other before it
asked whether either was real, as the interpreter once did. Compiled max(x, x) at
1/2 + 6/5 i was 1/2 + 6/5 i, and max(x, x) * 2 was 1 + 12/5 i, where evaluation says NaN.
The check for a non-real argument now comes first.

Found by work/compilesweep: 27 of its findings are max or min at a complex point.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Nov 1, 2026
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Nov 1, 2026
@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.76%. Comparing base (a1fb7ae) to head (54176ca).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2311      +/-   ##
==========================================
- Coverage   86.77%   86.76%   -0.01%     
==========================================
  Files         311      311              
  Lines       68199    68199              
  Branches    19821    19821              
==========================================
- Hits        59178    59175       -3     
- Misses       4880     4882       +2     
- Partials     4141     4142       +1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.31% <100.00%> (-0.01%) ⬇️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

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

Files with missing lines Coverage Δ
...rces/AngouriMath/Functions/Compilation/RealOnly.cs 100.00% <100.00%> (ø)

... and 6 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 3fc4022 into master Nov 1, 2026
36 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Nov 1, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the compiled-max-and-min-have-no-value-off-the-real-line branch November 1, 2026 15:13
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.

1 participant