Skip to content

Base-10 Log and out-of-domain errors - #3

Open
yohanpainchaud-gg wants to merge 4 commits into
mainfrom
feature/GG-3824
Open

yohanpainchaud-gg wants to merge 4 commits into
mainfrom
feature/GG-3824

Conversation

@yohanpainchaud-gg

@yohanpainchaud-gg yohanpainchaud-gg commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Niveau : critique — moteur de calcul des règles de résultats diagnostiques dPCR
Contrat : https://app.clickup.com/t/1240ccep35e

Ce qui change

  • ["Log", x] calcule log₁₀ (avant : ln) ; ["Log", x, b] respecte enfin la base.
  • Argument hors domaine (log ≤ 0, racine paire d'un négatif) → MathJSONDomainError.
  • Dépassement ou résultat non fini → erreur au lieu d'un inf silencieux.
  • Racine d'indice entier impair d'un négatif : résultat réel (∛(-8) = -2).
  • Une racine exacte est rendue exacte sur toute plateforme (glibc : cbrt(27) = 3.0000000000000004).

À juger

  • Version du paquet 1.14.0.post4 pour le tag 1.10.0-4 : les tags précédents déclarent déjà 1.14.0.
  • Racines exactes rendues exactes pour toute base et tout indice entier : décision ajoutée au contrat le 29/10.
  • ["Log", x, 10] passe par math.log(x, 10) : -2.9999999999999996 au lieu de -3.0 (\lg le produit).
  • Power/Root/Sqrt via math.pow : résultats toujours flottants (Power(2,3) = 8.0).
  • Root(0, n<0) lève une erreur de domaine, alors que Power(0, -1) lève une division par zéro.
  • Le tag 1.10.0-4 doit viser 1ec1b9c ; la PR dPCR-back en dépend.

Échecs couverts

Cas Résultat Test
log(0), log(-5), base ≤ 0 ou = 1 MathJSONDomainError test_raises_domain_and_overflow
√(-4), ⁴√(-16), Root(-8, 2.5), Power(-8, 0.333) MathJSONDomainError test_raises_domain_and_overflow
10^400, 1e300 × 1e300 MathJSONException (OverflowError) test_raises_domain_and_overflow
Opération inconnue en mode strict MathJSONException (NotImplementedError) test_unknown_head_strict
Valeurs de référence log, 10^x, racines impaires valeurs exactes test_solver_log_power_root
cbrt décalé d'un ulp (glibc) racine entière exacte test_root_is_exact_when_cbrt_is_one_ulp_off
pow(x, 1/n) décalé d'un ulp (n ≠ 3) racine entière exacte test_root_is_exact_when_pow_is_one_ulp_off
Racine d'un paramètre NaN ou infini MathJSONDomainError / OverflowError test_root_of_a_non_finite_value

Lire dans cet ordre

  1. src/mathjson_solver/__main__.py — Log, Root et racines exactes, finitude, mode strict
  2. tests/test_with_pytest.py — valeurs de référence et erreurs
  3. CHANGELOG.md — correspondance tag / version du paquet
Preuves de revue

REVIEW_GATE: NEEDS_HUMAN
SCOPE: origin/main...feature/GG-3824
REVIEWERS: delivery-auditor, change-reviewer, finding-verifier
CHECKS: git diff --check : OK ; pytest tests Windows (Python 3.14.5) : 264 passed ; pytest tests Linux glibc 2.41 (Python 3.14) : 264 passed ; test NaN en échec sur 3451f68 (prouve le correctif)
REASON: tag 1.10.0-4 non publié ; fiche SOUP/SBOM absente ; non-régression prod non faite

🤖 Generated with Claude Code

yohanpainchaud-gg and others added 4 commits October 28, 2026 13:36
BREAKING CHANGE: ["Log", x] is now the base-10 logarithm, as in the
CortexJS Compute Engine used by the front end. Consumers must migrate
stored ["Log", x] expressions to ["Ln", x] to keep the previous result.

- ["Log", x, b] computes the logarithm in base b
- MathJSONDomainError (a ValueError) for logarithms of non-positive
  numbers, invalid bases, square or even roots of negative numbers and
  negative bases raised to non-integer powers
- odd roots of negative numbers are real (["Root", -8, 3] is -2)
- OverflowError is caught, and inf or nan results raise
- ExponentialE constant; parameters with the same name take precedence
- optional strict mode raising on unknown operators (off by default)
- version 1.10.0-4, Python >= 3.11, CI on Python 3.11 and 3.14

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tags 1.10.0-2 and 1.10.0-3 already declare version 1.14.0 (upstream 1.14.0
was merged before them). Declaring 1.10.0-4 (1.10.0.post4 for pip) would make
the installed version go down; 1.14.0.post4 keeps it increasing. The tag stays
1.10.0-4. The CHANGELOG records the tag / version mapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
glibc's cbrt is not correctly rounded: cbrt(27) is 3.0000000000000004,
so ["Root", 27, 3] and ["Root", -27, 3] failed the reference tests in
CI, and would compute the same off-by-one-ulp values in production
(Linux), where Windows' cbrt gives 3.0. A root with a positive integer
index now returns the nearest integer when its power gives x back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rounding a NaN root raised a bare ValueError, which the back classifies
as a generic error instead of a domain error, and rounding an infinite
one changed the overflow message. Only finite roots are rounded now.
Also pins the exact-root rounding on the pow path (n != 3), which was
only tested through cbrt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant