Commit 894e7f1
committed
Improve handling of large values by inverse hyperbolic and trigonometric functions (#2928)
The `dpnp.tensor.acosh` function was returning incorrect results
(infinity) for complex numbers with large negative real parts (see
#2924, #2896).
The issue was caused by the threshold used `1/epsilon` to decide when to
switch from acos in SYCL's experimental complex extension
(`exprm_ns::acos()`) to a log-based formula.
The SYCL `exprm_ns::acos()` returns incorrect results for large negative
real parts, due to used formula `z + sqrt(z² - 1)`, which leads to
`log(0) = -infinity`.
The PR proposes to change the threshold from `1/epsilon` to
`sqrt(1/epsilon)/2` for all inverse trig/hyperbolic functions. This is
the precision loss point where `sqrt(z² ± 1)` calculations become
unstable.
Also the PR reduces code duplication by creating shared `casinh()`,
`casin()`, `catanh()`, `catan()` functions in new `complex_math.hpp`
header. 9154e641 parent 70e7f67 commit 894e7f1
2 files changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
1043 | | - | |
| 1043 | + | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | 1046 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments