Skip to content

Commit 4fc74e0

Browse files
authored
math: fix asinh(), add tests (#25925)
1 parent 68576a2 commit 4fc74e0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

vlib/math/invhyp.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn asinh(x f64) f64 {
2525
a := abs(x)
2626
s := if x < 0 { -1.0 } else { 1.0 }
2727
if a > 1.0 / internal.sqrt_f64_epsilon {
28-
return s * (log(a) + pi * 2.0)
28+
return s * (log(a) + ln2)
2929
} else if a > 2.0 {
3030
return s * log(2.0 * a + 1.0 / (a + sqrt(a * a + 1.0)))
3131
} else if a > internal.sqrt_f64_epsilon {

vlib/math/invhyp_test.v

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ fn test_acosh() {
44
assert math.close(math.acosh(1234567890.12345), 21.627134039822003)
55
assert math.close(math.acosh(12.123456789), 3.1865840454481904)
66
}
7+
8+
fn test_asinh() {
9+
assert math.close(math.asinh(1234567890.12345), 21.627134039822003)
10+
assert math.close(math.asinh(12.123456789), 3.1899859431901603)
11+
}

0 commit comments

Comments
 (0)