Skip to content

Add Math.log1p and Math.expm1#14087

Merged
mame merged 2 commits intoruby:masterfrom
mame:math-log1p-expm1
Aug 21, 2025
Merged

Add Math.log1p and Math.expm1#14087
mame merged 2 commits intoruby:masterfrom
mame:math-log1p-expm1

Conversation

@mame
Copy link
Copy Markdown
Member

@mame mame commented Aug 2, 2025

This commit adds two new methods to the Math module:

  • Math.log1p(x): Computes Math.log(x + 1)
  • Math.expm1(x): Computes Math.exp(x) - 1

These methods are often more accurate than the straightforward computation, especially when x is close to zero. The corresponding functions, log1p and expm1, are defined in the C99 standard math library.

@launchable-app

This comment has been minimized.

Comment thread math.c Outdated
Comment thread math.c
@mame mame marked this pull request as ready for review August 21, 2025 08:19
@mame mame force-pushed the math-log1p-expm1 branch from 1d7e626 to caac21d Compare August 21, 2025 10:17
@mame mame enabled auto-merge (rebase) August 21, 2025 10:18
@mame mame disabled auto-merge August 21, 2025 10:18
This commit adds two new methods to the `Math` module:

* `Math.log1p(x)`: Computes `Math.log(x + 1)`
* `Math.expm1(x)`: Computes `Math.exp(x) - 1`

These methods are often more accurate than the straightforward
computation, especially when `x` is close to zero.
The corresponding functions, `log1p` and `expm1`, are defined in the C99
standard math library.

[Feature #21527]
@mame mame force-pushed the math-log1p-expm1 branch from 2310f2f to 03edbae Compare August 21, 2025 10:18
@mame mame enabled auto-merge (rebase) August 21, 2025 10:18
@mame mame merged commit d318dc6 into ruby:master Aug 21, 2025
85 checks passed
@mame mame deleted the math-log1p-expm1 branch August 21, 2025 11:13
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.

3 participants