From ae8af7edb0cb605c977e2ba9402280a54aa23ac3 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Sun, 9 Aug 2026 01:28:16 +0000 Subject: [PATCH 1/2] Bring Syntax.md up to date with the functions that now exist Syntax.md still listed floor, ceil, ceiling, round, min, max and gcd under "Refused by name". Six of them have existed since #827 and #828, so the document was telling a caller the opposite of what the parser does -- and AGENTS.md is explicit that a stale one of these is worse than none. I changed the grammar twice and did not update it either time. The entries say what each does rather than only that it parses, since the conventions are the part a caller cannot guess: rounding toward the infinities rather than zero, round going to the nearest even on a tie and so not being floor(x + 1/2), the componentwise reading of a complex argument, min and max leaving an unordered pair alone, and gcd covering rationals. Every claim in the new text was checked against a build rather than written from memory, including that the four still-refused names still raise and that re and im are still read as products. Co-Authored-By: Claude Opus 5 (1M context) --- Sources/AngouriMath/Docs/Usage/Syntax.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Sources/AngouriMath/Docs/Usage/Syntax.md b/Sources/AngouriMath/Docs/Usage/Syntax.md index b0f781cc9..738550a20 100644 --- a/Sources/AngouriMath/Docs/Usage/Syntax.md +++ b/Sources/AngouriMath/Docs/Usage/Syntax.md @@ -93,17 +93,28 @@ The same goes for `cbrt(x)`, which is `x ^ (1/3)`, and `sqr(x)`, which is `x ^ 2 **Other** — `sqrt` `cbrt` `sqr` `pow(a, b)` `ln` `log(base, x)` `abs` `signum` `sgn` `sign` `phi` `gamma` `factorial` (or postfix `!`). +**Rounding** — `floor` `ceil` (`ceiling` is accepted on the way in and prints as `ceil`) `round`. +All three round a complex argument componentwise. `floor` and `ceil` go toward the infinities +rather than toward zero, so `floor(-3/2)` is `-2`; `round` goes to the **nearest even** on a tie, +so `round(1/2)` is `0` and `round(5/2)` is `2`, which is what Python, SymPy, Mathematica and +IEEE 754 all mean by rounding — and is *not* `floor(x + 1/2)`. + +**Comparison and divisors** — `min(a, b, ...)` `max(a, b, ...)` `gcd(a, b, ...)`. All three take +any number of arguments and fold. `min` and `max` compare only where the arguments are ordered and +are otherwise left as written. `gcd` computes over integers and rationals — `gcd(1/2, 1/3)` is +`1/6` — and leaves the polynomial case alone. + **Calculus** — `derivative(expr, var, order)`, `integral(expr, var)`, `limit(expr, var, dest)`, `limitleft(...)`, `limitright(...)`. **Structural** — `piecewise(a provided p, b provided q)`, `lambda(param, body)`, `apply(f, arg, ...)`, `domain(expr, set)`. -**Refused by name** — `floor` `ceil` `ceiling` `round` `trunc` `min` `max` `gcd` `lcm` `erf` -`conjugate`. AngouriMath has none of these, and each is what some other CAS calls a function, so a -caller reaches for it. Left alone they would be read as products under the rule below and answer -silently and wrongly; they raise a parse error naming the function instead. `re` and `im` are the -same case and are *not* refused, being short enough to be somebody's variable. +**Refused by name** — `trunc` `lcm` `erf` `conjugate`. AngouriMath has none of these, and each is +what some other CAS calls a function, so a caller reaches for it. Left alone they would be read as +products under the rule below and answer silently and wrongly; they raise a parse error naming the +function instead. `re` and `im` are the same case and are *not* refused, being short enough to be +somebody's variable. ## Where it is easy to be caught out From 2e717c698cc5a817ccfd8e28802ef1b4ff57ab7b Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Sun, 9 Aug 2026 01:32:15 +0000 Subject: [PATCH 2/2] Say in Syntax.md too that LaTeX output is parsed elsewhere The same false claim #823 corrected in AGENTS.md -- "nothing parses LaTeX" -- was in Syntax.md as well, and I fixed only the one I had been pointed at. CSharpMath.Evaluation reads LaTeX back into an Entity and states the contract in its own source, so the sentence was wrong in both places. The point worth keeping is the one the correction adds: Latexise is still free to use \frac and the rest, but a change to what it emits can break a downstream project and nothing here will catch it. Co-Authored-By: Claude Opus 5 (1M context) --- Sources/AngouriMath/Docs/Usage/Syntax.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/AngouriMath/Docs/Usage/Syntax.md b/Sources/AngouriMath/Docs/Usage/Syntax.md index 738550a20..6ed53efcc 100644 --- a/Sources/AngouriMath/Docs/Usage/Syntax.md +++ b/Sources/AngouriMath/Docs/Usage/Syntax.md @@ -13,8 +13,12 @@ notation is not in the grammar prints as its function call instead: a lambda pri `lambda(x, x + 1)` and not `x -> x + 1`, because `->` is the implication operator and the arrow form would silently come back as something else. -LaTeX output is under no such obligation — nothing parses LaTeX — so `Latexise` is free to use -`\frac`, `\bmod` and the rest. +**LaTeX output has a round trip too, and it is checked in someone else's repository.** +[CSharpMath.Evaluation](https://github.com/verybadcat/CSharpMath/blob/master/CSharpMath.Evaluation/Evaluation.cs) +reads LaTeX back into an `Entity` and says so in its own source — *"CSharpMath must handle all +LaTeX coming from AngouriMath or a bug is present!"* — so `Latexise` is free to use `\frac`, +`\bmod` and the rest, but changing what it emits can break a downstream project and no test here +will say so ([#822](https://github.com/asc-community/AngouriMath/issues/822)). ## Operators, loosest first