Skip to content

An interval under a function monotone on it is the interval between the images of its ends, and a product or quotient of two intervals is an interval - #1423

Merged
Rafael-SOWNet merged 2 commits into
masterfrom
interval-images
Sep 18, 2026
Merged

Rafael-SOWNet merged 2 commits into
masterfrom
interval-images

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

What #322 has left after #1117 (subtraction reflects) and #1118 (scaling): a function applied to an interval, and an interval times an interval. Per the comment there, "just do it".

Images. A function monotone on an interval maps it to the interval between the images of its ends — same order when increasing, reversed when decreasing — each end attained exactly when the end it comes from is, and an infinite image never attained: ln((0; 1)) is (-oo; 0), and so is ln([0; 1)). Answered for the nodes the library has, on the intervals where they are monotone, and declined elsewhere:

now
ln((0; 1)), ln([1; e]), log(1/2, (0; 1]) (-oo; 0), [0; 1], [0; +oo)
e^[0; 1], 2^(-oo; 0), (1/2)^[0; 2] [1; e], (0; 1), [1/4; 1]
[1; 2]^2, (-2; 1]^2, (-3; -1)^2, [-2; 3)^3 [1; 4], [0; 4) (folded across zero), (1; 9), [-8; 27)
[1; 2]^(-1), (0; 1]^(-1), 1 / (0; 1], 2 / (0; 1) [1/2; 1], [1; +oo), [1; +oo), (2; +oo)
sqrt([0; 4]), sqrt((1; 9)) [0; 2], (1; 3)
abs((-1; 2]), abs((-5; -1]) [0; 2], [1; 5)
arctan((-oo; +oo)), arcsin([-1; 1]), arccos([0; 1]) (-pi/2; pi/2), [-pi/2; pi/2], [0; pi/2]
ln((-1; 1)), (-1; 4)^(1/2), [-8; 8]^(1/3), 1 / [-1; 1], arcsin([0; 2]), sin([0; 1]), (0; 1) * k, [a; b]^2 left as written — not monotone, not real on the interval (the principal cube root of a negative number is complex), zero inside a divisor, a symbolic end or factor

Products. (1; 2) * (3; 4) is (3; 8), [1; 2] * [-1; 1] is [-2; 2], [-2; 3] * [-1; 4] is [-8; 12]: the interval between the least and the greatest of the four products of ends, an end attained where both its factors are. A quotient is the product by the reciprocal, which is an interval exactly when the divisor does not contain zero — (1; 2) / (3; 4) is (1/4; 2/3), [1; 2] / [-1; 1] stays. The reciprocal also answers a constant over such an interval, which #1118 left with a note (2 / (0; 1) → (2; +oo); 2 / [-1; 1] still stays, and IntervalScalingTest now pins that pair).

All in Functions/IntervalArithmetic.cs; the arms in Mulf, Divf, Powf, Logf, Absf, Arctanf, Arcsinf, Arccosf are one pattern each. Only numeric ends are read. IntervalImageTest has the rows above; BREAKING-CHANGES.md rows measured on a v2.5.0 build, where every one was left as written. Full suite 11775 passed, 0 failed; benchmark gate PASSED (SimplifyHard 183,758,496 B against the 182,240,824 B of the congruence PR, +0.8%; ParseHard identical).

Closes #322.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

…he images of its ends, and a product or quotient of two intervals is an interval

What #322 has left after #1117 and #1118: a function applied to an interval, and an interval
times an interval. A function monotone on an interval maps it to the interval between the
images of its ends -- in the same order when increasing, reversed when decreasing -- each end
attained exactly when the end it comes from is, and an infinite image never attained:
ln((0; 1)) is (-oo; 0), and so is ln([0; 1)), since ln(0) is not a value. Answered for the
functions the library has nodes for on the intervals where they are monotone: ln and log for
any positive base but 1 on the positives, b^I for such a base everywhere, I^n for a whole n
(odd everywhere; even on either side of zero and folded across it; negative through the
reciprocal where zero is outside), I^(1/n) from zero on, abs, arctan everywhere, arcsin and
arccos on [-1; 1]. A product of two intervals with finite numeric ends is the interval between
the least and the greatest of the four products of ends, an end attained where both its
factors are; a quotient is the product by the reciprocal, which is an interval exactly when
the divisor does not contain zero, and that also answers a constant over such an interval,
which #1118 left. Symbolic ends and factors, a sine over an interval, a root of a negative
interval and a divisor around zero are left as written.

Recorded in BREAKING-CHANGES.md against a v2.5.0 build, where every one of these was left as
written. Full suite green; benchmark gate PASSED.

Closes #322.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet
Rafael-SOWNet merged commit 89d3b0a into master Sep 18, 2026
31 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the interval-images branch September 18, 2026 21:54
Rafael-SOWNet added a commit that referenced this pull request Sep 21, 2026
Item 6 of the reference's docket (#1409), the half that needs no pair. image(f(x), x in A)
is { f(x) : x in A }, which is union({f(x)}, x in A): listed over a listed A, an interval by
interval arithmetic where x occurs once in f -- exact for one occurrence and the operations
that have images (#1423); the reference's 9c/5 + 32 on (0, 100) is (32, 212) -- and
otherwise the family, which answers membership through the quantifiers. preimage(f(x), x in A, Y)
is { x in A : f(x) in Y }, and a set builder of that shape is solved on evaluation where
the statement solver reads the membership (a listed Y, an interval; #1440), the solutions
cut by A: the pre-images of x^2 (Ex 7.3.10), with the one of (0, 1) excluding 0 where the
book prints (-1, 1). That shape only: a set builder is not solved on evaluation in general,
that being a search on every evaluation.

The performance baseline moves to this run. ParseHard reached +3.2% over the baseline
recorded at 86af577, and it is the ten function tokens added to the grammar since --
about 12 KB/op each, whatever the input, measured by removing the two of this change and
nothing else (3,727,130 to 3,703,015 B/op): a cost in the ANTLR runtime's per-parse work,
filed as #1441. Every other row is within 1% of the old baseline.

#1409


Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Applying a transformation to all elements of a set

1 participant