Skip to content

Commit e733977

Browse files
authored
math: fix acosh(), add tests (#25923)
1 parent af0ced0 commit e733977

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎vlib/math/invhyp.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub fn acosh(x f64) f64 {
77
if x == 0.0 {
88
return 0.0
99
} else if x > 1.0 / internal.sqrt_f64_epsilon {
10-
return log(x) + pi * 2
10+
return log(x) + ln2
1111
} else if x > 2.0 {
1212
return log(2.0 * x - 1.0 / (sqrt(x * x - 1.0) + x))
1313
} else if x > 1.0 {

‎vlib/math/invhyp_test.v‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import math
2+
3+
fn test_acosh() {
4+
assert math.close(math.acosh(1234567890.12345), 21.627134039822003)
5+
assert math.close(math.acosh(12.123456789), 3.1865840454481904)
6+
}

0 commit comments

Comments
 (0)