Skip to content

Check Tan's precision ceiling against the requested digits [patch] - #160

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/tan-guard-digits-125
Oct 6, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/tan-guard-digits-125

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #125

Before: Tan(x, n) called the public SinCos(x, n + 10). That counted its 10 guard digits against the π reduction ceiling. As a result, Tan(1, 140), Tan(1, 145) and Tan(0.3, 145) threw, even though Sin and Cos deliver those precisions.

After: SinCos(x, n) is now a checked public wrapper around a private, unchecked SinCosCore. Tan calls RequireReducibleArgument against the n digits it reports, then gets sin and cos from the core at the wider working precision. This follows the RequireReducibleArgument remarks and CLAUDE.md: guard margin is allowed to be unavailable. Tan's docs now list the ceiling exception.

Tests:

  • TestTanDeliversEveryDigitUpToTheReductionCeiling: Tan(1000000, ConstantPrecision - 7) succeeds and matches sin/cos, and one digit more is still refused.
  • TestTanAcceptsThePrecisionsSinAndCosAccept: the repro from the issue. Tan(1, 145) returns 145 digits and starts with the published tan(1) digits. Tan(0.3, 145) and Tan(0.3, 150) also succeed.
  • Both tests fail on main and pass with the change. Full suite: 442 passed, 0 failed.

This PR is independent of #159 (#124), which clamps the default-precision overloads. I merged the two branches locally to check them together: Tan(Pi / 4) agrees with 1 to 140 digits, and Tan(Pi) and Tan(E) no longer throw. Each change alone isn't enough for those.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VL7qukbkUpkVRArT45bBFb


Generated by Claude Code

Tan called the public SinCos at its widened working precision, so its
ten guard digits were counted against the pi reduction ceiling and it
refused precisions Sin and Cos deliver. SinCos is now a checked public
wrapper over an unchecked SinCosCore; Tan checks the ceiling against the
digits it reports and computes sin and cos through the core.

Fixes #125

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VL7qukbkUpkVRArT45bBFb
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 6d92f92 into main Oct 6, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/tan-guard-digits-125 branch October 6, 2026 23:03
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.

Tan refuses precisions that Sin/Cos accept: its 10 internal guard digits are counted against the π reduction ceiling

2 participants