feat: add log2 log10 sinh cosh tanh asinh acosh atanh to the formula language#41
Draft
hozblok wants to merge 1 commit into
Draft
feat: add log2 log10 sinh cosh tanh asinh acosh atanh to the formula language#41hozblok wants to merge 1 commit into
hozblok wants to merge 1 commit into
Conversation
…language
Eight new one-arg math functions wired through the standard pipeline:
csconstants.hpp — using boost::multiprecision::{log2, log10,
sinh, cosh, tanh, asinh, acosh, atanh}
cseval.hpp — _X static + _X_d derivative for each (real path)
cseval_complex.hpp — same for the complex path
cseval.cpp — entries in functionsOneArg + functionsTwoArgsDLeft
cseval_complex.cpp — same
Complex log2 / log10: Boost's cpp_complex_backend does not provide
native log2/log10. Implemented as `_log(z) / _log(base)` (the standard
change-of-base identity); derivative uses the same identity for the
constant denominator.
acosh / atanh derivatives diverge at |x|==1; they throw a clear
ValueError naming the function (matching the existing _asin_d /
_tan_d convention).
Per-function tests under tests/functions/one_arg/test_X.py for each new
function: basic value at convenient input, derivative at convenient
input, divergence on the singular cases for acosh/atanh.
Full suite 410/410 (+22 new), 3 xfailed unchanged.
Closes TODO src/cpp/csconstants.hpp:222.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes TODO
src/cpp/csconstants.hpp:222(// TODO add log2 log10 sinh cosh tanh asinh acosh atanh).Scope
Eight new one-arg math functions exposed in the formula language, both on the real and complex evaluation paths, with chain-rule derivatives where applicable.
log2(x)1 / (x · ln 2)x = 0log10(x)1 / (x · ln 10)x = 0sinh(x)cosh(x)cosh(x)sinh(x)tanh(x)1 / cosh(x)²asinh(x)1 / √(1 + x²)acosh(x)1 / √(x² − 1)atanh(x)1 / (1 − x²)Wiring
csconstants.hpp—using boost::multiprecision::{log2, log10, sinh, cosh, tanh, asinh, acosh, atanh};cseval.hpp/cseval_complex.hpp—static _X(value) +static _X_d(derivative) per function.cseval.cpp/cseval_complex.cpp— new entries infunctionsOneArgandfunctionsTwoArgsDLeftfor each.Complex log2 / log10
Boost's
cpp_complex_backenddoes not provide nativelog2/log10. Implemented manually via the change-of-base identitylog_b(z) = ln(z) / ln(b), using the existing_logprimitive. Derivative uses the same identity for the constant denominator. Reallog2/log10go through Boost's native overloads oncpp_dec_float.Divergences
acosh/atanhderivatives are singular atx = ±1. They throwstd::invalid_argument(Python-sideValueError) with the function name in the message, matching the existing_asin_d/_tan_d/_log_dconvention.Tests
Eight new files under
tests/functions/one_arg/, one per function (test_log2.py…test_atanh.py). Each covers:log2(8) → 3,sinh(0) → 0)|x| = 1foracosh/atanhMatches the existing terse
test_X.pyshape (without the long precision-256 golden values — those are easy to add later if desired).Full suite 410/410 (+22 new), 3 xfailed unchanged.