Skip to content

Implement log2#8

Merged
timschmidt merged 2 commits into
timschmidt:mainfrom
TimTheBig:log2
May 24, 2026
Merged

Implement log2#8
timschmidt merged 2 commits into
timschmidt:mainfrom
TimTheBig:log2

Conversation

@TimTheBig
Copy link
Copy Markdown

This patch implements log2 in the style of log10

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements the base-2 logarithm (log2) for the Real type, introducing a new Log2 symbolic class and the Real::log2 method. The implementation includes optimizations for rational powers of two and a division shortcut that folds ln(x) / ln(2) into a Log2 certificate. Support for log2 and lg was also added to the expression parser, along with comprehensive tests and benchmarks. A critical issue was identified in the division folding logic where cloning the original Real object incorrectly preserves a stale approximation cache, which could lead to incorrect numerical results.

Comment thread src/real/arithmetic.rs
Comment thread src/real/arithmetic.rs Outdated
@timschmidt timschmidt merged commit 794a4cf into timschmidt:main May 24, 2026
1 check failed
@TimTheBig
Copy link
Copy Markdown
Author

thanks

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.

2 participants