From 4fc74e00fcd55ec0c5ae8e67c1ebf28b624eb0c7 Mon Sep 17 00:00:00 2001 From: Mike <45243121+tankf33der@users.noreply.github.com> Date: Tue, 9 Dec 2025 11:06:49 +0200 Subject: [PATCH] math: fix asinh(), add tests (#25925) --- vlib/math/invhyp.v | 2 +- vlib/math/invhyp_test.v | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/vlib/math/invhyp.v b/vlib/math/invhyp.v index f320f428a..24c6d7f67 100644 --- a/vlib/math/invhyp.v +++ b/vlib/math/invhyp.v @@ -25,7 +25,7 @@ pub fn asinh(x f64) f64 { a := abs(x) s := if x < 0 { -1.0 } else { 1.0 } if a > 1.0 / internal.sqrt_f64_epsilon { - return s * (log(a) + pi * 2.0) + return s * (log(a) + ln2) } else if a > 2.0 { return s * log(2.0 * a + 1.0 / (a + sqrt(a * a + 1.0))) } else if a > internal.sqrt_f64_epsilon { diff --git a/vlib/math/invhyp_test.v b/vlib/math/invhyp_test.v index 27326890f..687636053 100644 --- a/vlib/math/invhyp_test.v +++ b/vlib/math/invhyp_test.v @@ -4,3 +4,8 @@ fn test_acosh() { assert math.close(math.acosh(1234567890.12345), 21.627134039822003) assert math.close(math.acosh(12.123456789), 3.1865840454481904) } + +fn test_asinh() { + assert math.close(math.asinh(1234567890.12345), 21.627134039822003) + assert math.close(math.asinh(12.123456789), 3.1899859431901603) +} -- 2.39.5