Repository navigation
Write an expression with floors and ceilings over a bounded range as the piecewise it is there - #2102
Merged
Rafael-SOWNet merged 2 commits intoOct 23, 2026
Conversation
…the piecewise it is there MathS.ExperimentalFeatures.PiecewiseOver(expr, x, from, to) gives expr over [from, to] as a piecewise with each floor and ceiling of x replaced by its value on each piece: the pieces partition the range, their ends are exact, and an end belongs to the piece whose value it has, which the closedness of each piece's interval says. floor(x^2) over [0, 2] is 0 on [0, 1), 1 on [1, sqrt(2)), 2 on [sqrt(2), sqrt(3)), 3 on [sqrt(3), 2) and 4 at 2. The ends are the roots of g(x) = k for each whole k in a step argument g's range there, from the solver, each checked to be one exactly. That they are all the ends is proved: between two consecutive ends g reaches no whole number, by bisection, each part settled by intervals that hold every value there -- g inside one (k, k + 1), or g strictly monotone with no whole number between its values at the part's ends, or, beside an end where g = k, the first derivative that does not vanish there of one sign throughout, so that g - k has one sign beside the end by Taylor's theorem. The last is what the turning points of a sine need: floor(sin(pi x (4 - x)/2)) over [0, 4] reaches 1, -1 and 0 where its argument's derivative is 0. Where the proof does not go through -- a root the solver does not give, an argument with a pole in the range or an infinite slope at an end, a step inside a step, another jump in x -- the answer is null, and never a partition with a piece missing. Experimental, because the issue asks for the contract to be designed and none has been agreed. The interval evaluator takes a variable bound to a range, which every one of its operations already encloses. Part of #1807. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
integral(floor(x^2), x, 0, 2) stayed as written: a floor or a ceiling was a break only where its argument was x itself. Between two numeric bounds it is now the sum of the integrals of the pieces StepPieces proves, each with the step a constant, which is 5 - sqrt(2) - sqrt(3); a piece that is a point adds nothing. Where the pieces are not proved complete, or a bound is symbolic, the integral is left as written as before. WhatCannotBeSplitIsLeftAsWritten pinned floor(x^2) from 0 to 2 as one that could not be split, which is what changed. Part of #1807. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 3 of #1807: a caller can now ask for the proven pieces of a composed floor or ceiling over a bounded range, and definite integrals use them.
MathS.ExperimentalFeatures.PiecewiseOver(expr, x, from, to)givesexprover[from, to]as the piecewise it is there. Each floor and ceiling ofxis replaced by its value on each piece. The pieces partition the range and their ends are exact. An end belongs to the piece whose value it has, which the closedness of each interval says. It returnsnullwherever the partition cannot be proved complete. It is experimental because the issue asked for the contract to be designed, and no design has been agreed yet.exprover the rangefloor(x^2)over[0, 2]0on[0; 1),1on[1; sqrt(2)),2on[sqrt(2); sqrt(3)),3on[sqrt(3); 2),4atx = 2floor(sin(pi*x*(4 - x)/2))over[0, 4]0on[0; 2 - sqrt(3)),1atx = 2 - sqrt(3),0on(2 - sqrt(3); 2 - sqrt(2)],-1on(2 - sqrt(2); 2),0atx = 2,-1on(2; 2 + sqrt(2)),0on[2 + sqrt(2); 2 + sqrt(3)),1atx = 2 + sqrt(3),0on(2 + sqrt(3); 4]floor(x^2) + ceil(x)over[-1, 2]0on[-1; 0],1on(0; 1),2atx = 1,3on(1; sqrt(2)), …floor(1/x)over[-1, 1]null: a pole inside the rangeHow the pieces are proved complete. The ends are the roots of
g(x) = kfor each wholekin a step argumentg's range, taken from the solver and each checked to be exact. Then, between two consecutive ends,gmust be shown to reach no whole number. That is done by bisection with intervals that hold every value there (the interval evaluator, now with a variable bound to a range). Each part is settled by one of three tests:glies inside one(k, k + 1);gis strictly monotone, with no whole number between its values at the part's ends;g = k, and the first derivative that does not vanish there has one sign throughout the part. Theng - khas one sign beside the end, by Taylor's theorem.The third test is what the sine above needs: its argument touches 1, −1 and 0 at turning points, where
g' = 0. A root the solver misses leaves a part that none of the three settles, so the whole answer is declined.What it declines. A step inside a step's argument, another jump in
x, a pole of an argument in the range, and an end where the slope is infinite:floor(sqrt(x))from 0 declines, while from 1 it gives its pieces.Definite integrals of a floor or ceiling of something in
x, between numeric bounds, are now the sum over the pieces, with an entry in BREAKING-CHANGES.md measured on the 2.6.0 package:integral(floor(x^2), x, 0, 2)5 - sqrt(2) - sqrt(3)integral(floor(2*x), x, 0, 3)15/2integral(floor(sin(pi*x*(4-x)/2)), x, 0, 4)(-2) * sqrt(2)integral(floor(1/x), x, 1/4, 1)13/12BreakpointIntegrationTest.WhatCannotBeSplitIsLeftAsWrittenpinnedfloor(x^2)from 0 to 2 as unsplittable, and that row is removed. The new tests arePiecewiseOverTest(15) and two theories inBreakpointIntegrationTest. The full suite and the MCP tests pass. Indefinite integration is untouched, so the Rubi corpus was not re-run.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura