Repository navigation
A geometric series is summed in closed form - #1218
Conversation
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
|
Can you really assume that |
|
No — and the example is worse than "missing a solver": it has a value. What the test pins is the fallback, which is right as far as it goes: when the split leaves a sum nothing here answers yet, the integral stays as written rather than becoming an unevaluated sum, and it never says NaN. But the comment said "cannot", and I have reworded it to say "not yet, and this one is |
…s 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
sum(2^k, k, 0, +oo) and sum(k, k, 1, +oo) were left as written. They have no finite value, and saying nothing was the only thing missing: the nth-term test settles them. Terms that do not tend to zero mean the series diverges, and the sign of the limit says which infinity -- where the terms tend to a positive L they are eventually all above L / 2, so the partial sums pass every bound. A negative limit gives -oo the same way, and the finitely many terms before that point are finite and cannot change it. A limit of zero is declined, and that is the point of the test rather than a gap in it: sum(1/k) diverges and sum(1/k^2) converges and the terms of both tend to 0. A limit that does not exist is declined too, since telling "does not exist" apart from "was not computed" is not something to infer from a failed computation. And a summand that can fail to exist at some index is declined, because one undefined term makes the sum undefined rather than infinite -- sum(k / (k - 5), k, 0, +oo) has terms tending to 1 and no term at k = 5. Rather than hunt for poles the index is allowed only where none can arise, which also keeps this cheap: the structural check runs first, so a summand it cannot speak about never reaches the limit engine. A condition that holds over the whole range is dropped, which is what lets the step split hand over n ^ n provided not n = 0 or n > 0. Last in the chain, so a series that converges is summed rather than tested. Asked for on the review of #1218, where integral(floor(x)^floor(x), x, 1, +oo) splits into sum(n^n, n, 1, +oo) and was left as written for want of it -- that test carried a comment saying it would move to the value the day this existed, and it has. Three other pinned examples move with it, each having used an infinite range as its illustration of a sum that stays. BREAKING-CHANGES.md has the rows, measured on both builds. Part of #1212. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Delivered: #1224 merged, so To close the loop on the question you asked: it was missing a solver, and the nth-term test is it. The parts I deliberately kept it from answering are a vanishing limit (the case the test genuinely says nothing about — |
Part of #1212 — the sum that question I.2's step integral leaves once #1215 splits it, and the last of the summation closed forms the plan there named (polynomial #1152, exponential #1213, binomial #1214).
What was left as written
Measured on
27ed5b53:sum(2^(-k), k, 0, +oo),sum(1 / 2^k, k, 1, +oo),sum((-1/2)^k, k, 0, +oo)sum(x^k, k, 0, +oo),sum(x^k, k, 0, n),sum(2^k, k, a, n)sum(2^k, k, 0, 200)— past the hundred terms expanded one by oneintegral(2^(-floor(x)), x, 0, +oo)What changes
GeometricSeries.ClosedForm, last in theSummationfchain. The summand is read structurally asC * b^(m k + s): one power whose base is free of the index and whose exponent is the index times a whole number plus something free of it, every other factor free of the index. The ratio isr = b^m.C b^s (r^a - r^(b + 1)) / (1 - r)holds where the range is not empty andr ≠ 1; atr = 1the sum is the number of terms times the constant; belowb = a - 1the range is empty and this library answers0. A numeric ratio picks its branch; a symbolic one is offered all three as a piecewise, the wayPolynomialSummationoffers the empty range —sum(x^k, k, 0, n)ispiecewise((n + 1) provided (x = 1 and n >= -1), ((1 - x^(n + 1)) / (1 - x)) provided (n >= -1), 0).+oo: converges exactly when|r| < 1. A numeric ratio outside that is left as written — the sum is infinite or has no value, and which of the two is not this reader's to say. A symbolic ratio carries the condition:sum(x^k, k, 0, +oo)is1 / (1 - x) provided abs(x) < 1.k x^k), an exponent that is not linear in the index, a base with the index in it, a bound that is a number and not whole. All stay as written.r^0is written as the number 1 rather than built, since a power carriesprovided not r = 0and the sum atr = 0is its first term — the first cut answeredsum(x^k, k, 0, +oo)withand not x = 0attached, which is false at a point where the sum is 1.Three tests pinned
sum(2^k, k, 1, n)as their example of a sum without a closed form; they usek^know. The #1215 test that recordedintegral(2^(-floor(x)), x, 0, +oo)staying as written for want of this sum now records2.Measured
Both columns on builds —
27ed5b53against this branch:sum(2^(-k), k, 0, +oo),sum(1 / 2^k, k, 1, +oo),sum((-1/2)^k, k, 0, +oo)2,1,2/3sum(x^k, k, 0, +oo); from 11 / (1 - x) provided abs(x) < 1;x / (1 - x) provided abs(x) < 1sum(x^k, k, 0, n)sum(2^k, k, a, n);sum(2^k, k, 0, 200)piecewise((2^(n + 1) - 2^a) provided (n >= a - 1), 0);2^201 - 1as a numberintegral(2^(-floor(x)), x, 0, +oo)2sum(2^k, k, 0, +oo),sum((-1)^k, k, 0, +oo),sum(k * (1/2)^k, k, 0, +oo),sum(2^k, k, 0, 5)63Checks
GeometricSeriesTest: seven numeric series, the symbolic ratio with its condition and its value at 0, outside the disc, three finite ranges past a hundred terms, six symbolic-bound substitutions, two symbolic lower bounds, six non-shapes. Full suite in two chunks: 8359 and 1412 pass.One thing seen once and not reproduced, noted rather than hidden: in the first chunk run on this branch
FractionFreeDeterminantTest.EliminationAgreesWithLaplaceWhereverBothApplyreported one 4×4 whose Laplace determinant came back with two ninety-digit integers in it. It passes alone, passed on the rerun of the same chunk, and passes on master's build of the chunk; the test is seeded, so the input is fixed and the difference is scheduling. Nothing in this branch is on that path; filed as #1219.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura