You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ad02ebb
Browse filesBrowse the repository at this point in the historyBrowse files
* A sum over a set: sum(f, x in S)
sum took a range and nothing else, so a sum over a set had no spelling:
sum(f, x in S) was a parse error asking for the range form's four
arguments. SumOverSetf reads the second argument as `variable in set` and
binds the variable over the term and the set, as max(f, t in S) does; it
prints \sum_{x \in S} f, and MathS.Sum(f, x, S) builds it. The range form
is untouched. A sum over the roots of a polynomial is a sum over its set
of roots, sum(f(w), w in { w : p(w) = 0 }), with no index and no order.
The terms are added up where the set is finite and its members are known:
a listed set of numbers, distinct by value, and the roots of a polynomial
where the solver writes all of them -- counted against the degree of the
square-free part, so a root the solver missed leaves the sum as written
rather than a term short. The solver is asked only where every
irreducible factor has degree at most four or is a binomial. Evaluated
to a number, the roots it cannot write are found to the working
precision by Durand-Kerner, one square-free factor at a time, all of
them or none; the polynomial is read off the tree, so that holds with
downcasting off. A set whose members may coincide, and one that is not
finite, are left as written.
Termwise differentiation where the set does not depend on the variable,
zero in the bound name; SymPy export as a sum of substitutions or a
RootSum of the square-free part.
Part of #1285.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
* Roots are written out only where they read as simply as the sum
Rational roots, the roots of a quadratic and the roots of a binomial are
written and added; the roots of an irreducible cubic or quartic are not.
In radicals they read no more simply than the sum over them, and for a
real cubic with three real roots Cardano's formula writes them with
complex radicals, so sum(w^2, w in { w : w^3 + w + 1 = 0 }) is kept as it
is and evaluates to -2.
A numeric value goes to the numeric roots at once rather than asking the
solver first, since a check evaluates at many points and the roots do not
depend on them. SquareFreeParts and NumericRoots are internal, for the
interval evaluation that reads them next.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`sum` took a range and nothing else, so a sum over a set had no spelling: `sum(f, x in S)` was a
1614
+
parse error asking for the four arguments of the range form. `SumOverSetf` reads the second
1615
+
argument as `variable in set` and binds the variable over the term and the set, as `max(f, t in S)`
1616
+
does: spelt `sum(f, x in S)`, printed `\sum_{x \in S} f` in LaTeX, and built by
1617
+
`MathS.Sum(f, x, S)`. The range form `sum(f, k, from, to)` is untouched. A sum over the roots of a
1618
+
polynomial is a sum over its set of roots, `sum(f(w), w in { w : p(w) = 0 })`, with no index and no
1619
+
order.
1620
+
1621
+
The terms are added up where the set is finite and its members are known: a listed set of numbers,
1622
+
distinct by value, and the roots of a polynomial where every one is rational, a root of a quadratic
1623
+
or a root of a binomial. That is checked by counting them against the degree of the square-free
1624
+
part, so a root the solver missed leaves the sum as written rather than one term short. The roots of
1625
+
an irreducible cubic or quartic are not written out in radicals, which read no more simply than the
1626
+
sum. Evaluated to a number, the roots it cannot
1627
+
write are found to the working precision by the Durand–Kerner iteration, all of them or none. A set
1628
+
with a symbol among its members, whose members may coincide, and a set that is not finite are left
1629
+
as written. [#1285](https://github.com/asc-community/AngouriMath/issues/1285). Both columns
1630
+
measured on a build, `v2.5.0` against this change.
1631
+
1632
+
| | Was (2.5.0) | Is |
1633
+
|---|---|---|
1634
+
| `"sum(x^2, x in {1, 2, 3})".ToEntity()` | `FunctionArgumentCountException`: *sum should have exactly 4 arguments but 2 arguments are provided* | `14` once simplified |
1635
+
| `"sum(w^2, w in { w : w^3 - 2w + 1 = 0 })".ToEntity().Simplify()` | the same exception | `4` |
1636
+
| `"sum(w^5, w in { w : w^5 + w + 3 = 0 })".ToEntity().Evaled` | the same exception | `-15`, from the five roots found numerically |
1637
+
| `"sum(k, k in ZZ intersect [1; 10])".ToEntity().Simplify()` | the same exception | `55`, as `sum(k, k, 1, 10)` is |
1638
+
| `"sum(x, x in {a, b})".ToEntity().Simplify()` | the same exception | `sum(x, x in { a, b })`, since `a` and `b` may be equal |
1639
+
| `"sum(k, k, 1, 10)".ToEntity().Simplify()` | `55` | the same |
1640
+
1611
1641
### `(a + b asech(c x))/(d + e x)^2` is integrated, and a root written apart with `|x|` no longer needs a parity
1612
1642
1613
1643
Rubi's 7.5.1 with a symbolic linear below the bar ran for ten minutes without an answer. By
0 commit comments