Repository navigation
An integral across a jump is split at the jumps, never taken through an antiderivative - #1215
Conversation
|
This is really about continuity, right? Instead of special casing floor and ceil, you should use a generalized approach that also handles piecewises (they can be continuous or not!) |
61d0773 to
2d7dc90
Compare
|
Agreed — the invariant underneath is that |
…an antiderivative integral(x - floor(x), x, 0, 3) answered 0: the rules find an antiderivative of an integrand with floor(x) in it by taking the floor for a constant, right between two of its jumps and wrong across one, and the definite integral evaluated that at the bounds. (x - floor(x))^2 from 0 to 4 was 0 where it is 4/3, and from 0 to a symbolic n was (n - floor(n))^3 / 3, wrong for every whole n but 0. An integrand with floor(x) or ceil(x) of the variable no longer goes through an antiderivative between two bounds. Between whole bounds it is split into unit intervals -- on each the floor is n, the ceiling n + 1 and x is n + t -- and the integral is a sum over n of an integral over t with no step in it, which the summation's closed forms then answer; a numeric bound that is not whole contributes the piece up to the nearest whole number, on which the step is one known constant; a symbolic bound is left as written. Offered only where every piece resolves. The fractional part is substituted as a unit, since written out it arrives as n + t - n, which is a conditional zero and not nothing (#1174); and the series reader accepts the condition a division by a factorial of the index carries, which holds for every whole index in range. Question I.2 of #1212: integral((x - floor(x)) / floor(x)!, x, 1, +oo) is (e - 1) / 2. BREAKING-CHANGES.md has the rows, measured on both builds. Part of #1212. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
…an antiderivative F(b) - F(a) is the integral only where F is continuous on [a, b], and the definite integral evaluated an antiderivative at its bounds whatever the integrand did in between. Three shapes jump. A piecewise whose conditions mention the variable: the generic argument expansion built the antiderivative case by case and handed it back with the integration variable still inside it -- the tent map over [0, 1] answered 1, and piecewise(x provided x < 1, x^2) over [0, 2] answered piecewise(2 provided x < 1, 8/3). A provided on the variable, distributed the same way. And floor(x) or ceil(x), taken for constants across their jumps: x - floor(x) from 0 to 3 answered 0, (x - floor(x))^2 from 0 to 4 answered 0 where it is 4/3, and from 0 to a symbolic n answered (n - floor(n))^3 / 3. An integrand that can jump never goes through an antiderivative between two bounds now (BreakpointIntegration, and a guard at the integral node so that a declined split stays an integral rather than being handed to the expansion). Finitely many breakpoints -- a piecewise or a provided whose conditions compare the variable with numbers -- cut the range, and on each piece the case that holds at the midpoint is integrated through the antiderivative and added; a provided that fails on a piece leaves the integral as written. Infinitely many, evenly spaced -- a floor or a ceiling -- are the same split as a sum over unit intervals, which the summation's closed forms answer, with the pieces up to the nearest whole number for a numeric bound that is not whole. A condition against a symbol or a symbolic bound is left as written. Offered only where every piece resolves. The fractional part is substituted as a unit, since written out it arrives as n + t - n, which is a conditional zero and not nothing (#1174); and the series reader accepts the condition a division by a factorial of the index carries, which holds for every whole index in range. Question I.2 of #1212 -- integral((x - floor(x)) / floor(x)!, x, 1, +oo) is (e - 1) / 2 -- generalised on the review of #1215. BREAKING-CHANGES.md has the rows, measured on both builds. Part of #1212. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
2d7dc90 to
8d31234
Compare
|
Generalised, and retitled: the PR is now the breakpoint split, with the floor as one instance of it. What it reads as a break, in What it fixed beyond the floor, measured on master: the tent map Not in this PR: the same expansion distributes Rebased onto master with #1216 and #1217; one expectation moved with the perfect-power rule ( |
|
Measured the summation side I said was next, on this branch. It is not wrong: a numeric range expands term by term before the argument expansion sees it, so One thing the measurement did turn up, a size rather than a value: |
* A geometric series is summed in closed form sum(x^k, k, 0, +oo) was left as written, and so was every other sum of a power with the index in the exponent: sum(2^(-k), k, 0, +oo), sum(x^k, k, 0, n), and sum(2^k, k, 0, 200), whose range is past the hundred terms that are expanded one by one. A summand that is C * b^(m k + s) -- a base free of the index, an exponent that is the index times a whole number plus something free of it, every other factor free of the index -- is summed as a geometric series with the ratio b^m. Between two bounds the sum is C b^s (r^a - r^(b + 1)) / (1 - r) where the range is not empty and the ratio is not 1, the number of terms times the constant where the ratio is 1, and 0 for an empty range; a numeric ratio picks its branch and a symbolic one is offered all three as a piecewise, the way a polynomial summand is offered the empty range. To +oo the series converges exactly when |r| < 1: a numeric ratio outside that is left as written, and a symbolic ratio carries provided abs(r) < 1. A polynomial factor in the index is not this family and stays as written. r^0 is written as 1 rather than built, since a power carries `provided not r = 0` and the sum at r = 0 is its first term. Three tests that pinned sum(2^k, k, 1, n) as an example of a sum without a closed form now use k^k; the step integral of 2^(-floor(x)) over [0, +oo), which #1215 left as written for want of this sum, is 2. The sum question I.2 of #1212 leaves. BREAKING-CHANGES.md has the rows, measured on both builds. Part of #1212. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * The declined step integral is a TODO, not a verdict: sum(n^n) diverges to +oo The test pinned integral(floor(x)^floor(x), x, 1, +oo) staying as written with a comment that said the sum cannot be answered. It can: its terms do not tend to zero, so the series diverges, and with positive terms the answer is +oo. What is missing is a divergence test, and the comment now says so. From the review of #1218. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Part of #1212 — item 3 of the plan in my comment there, generalised on the review here: the mechanism is continuity, not the floor.
The wrong answers
F(b) - F(a)is the integral only whereFis continuous on[a, b], and the definite integral evaluated an antiderivative at its bounds whatever the integrand did in between. Measured on master:integral(piecewise(2x provided x <= 1/2, 2 - 2x), x, 0, 1)— the tent map,1/21— the first case's antiderivative at both endsintegral(piecewise(x provided x < 1, x^2), x, 0, 2)—17/6piecewise(2 provided x < 1, 8/3)— the integration variable still in the answerintegral(x - floor(x), x, 0, 3)—3/20integral((x - floor(x))^2, x, 0, n)(n - floor(n))^3 / 3— wrong for every wholenbut 0The piecewise ones come from the generic argument expansion in
Integralf.InnerSimplify, which distributes the integral into the cases of a piecewise, and under aprovided, whether or not their conditions mention the integration variable. The floor ones come from the rules taking the floor for a constant.What changes
BreakpointIntegration(renamed from the first version'sUnitIntervalIntegration): an integrand that can jump never goes through an antiderivative between two bounds.providedwhose conditions compare the variable with numbers: the range is cut at the breakpoints inside it; on each piece the case that holds at the piece's midpoint replaces the piecewise (exact, since the condition has no other place to change), and the piece integrates through the antiderivative; the pieces add. Aprovidedwhose condition fails on a piece makes the integral undefined there, and it is left as written.floor(x)orceil(x): the same split written as a sum over unit intervals, which the summation's closed forms (A polynomial summand is summed in closed form (#717) #1152, A series in a power over a factorial is summed in closed form #1213) answer;+ooallowed; a numeric bound that is not whole contributes the piece up to the nearest whole number.sgnandabshave continuous antiderivatives and are untouched.Two details that cost a round each: the fractional part is substituted as a unit, because written out it arrives as
n + t - n, which since #1174 is a conditional zero rather than nothing; andExponentialSeriessees through the condition a division by a factorial of the index carries, which holds for every whole index in the range.Measured
Both columns on builds —
4fd6dda5/60545afaagainst this branch:[0, 1]11/2piecewise(x provided x < 1, x^2)over[0, 2]; three cases over[-1, 2]x; a piecewise inx17/6;6piecewise(x provided x < a, 0)over[0, 2]; the tent map over[0, t]xx provided x > 0over[0, 1]; over[-1, 1]1/2 provided x > 0;0 provided x > 01/2; left as writtenx - floor(x)over[0, 3];(x - floor(x))^2over[0, 4]; over[0, n]0;0;(n - floor(n))^3 / 33/2;4/3; left as written (2oncen = 6)(x - floor(x)) / floor(x)!over[1, +oo)— question I.2(e - 1) / 2floor(x)over[0, 5],floor(x) * xover[0, 3],floor(x) / (floor(x) + 1)!over[0, +oo)10,13/2,1floor(x)over[1/2, 2],x - floor(x)over[0, 5/2],ceil(x) - xover[1/2, 2]1,9/8,5/8sgn(x)over[-1, 2],abs(x - 1)over[0, 3], the rational integral of I.51,5/2, its valueWhat this does not do yet
The same expansion distributes
sum,product,derivativeandlimitinto a piecewise's cases with the bound variable in the conditions; a summation over an index-dependent condition is the next one worth measuring. And a piecewise nested inside another's condition (what composing the tent map five times produces, question I.3) is not read as breakpoints yet.Checks
BreakpointIntegrationTest: seven piecewise integrals, theprovidedcase, the constant-condition case, the two declines, the sheet's integral, five whole-bound and six non-whole-bound step integrals, the symbolic bound, two non-shapes, three unaffected integrands. Full suite in two chunks: 8344 and 1386 pass.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura