
(FPCore (x) :precision binary32 (atanh x))
float code(float x) {
return atanhf(x);
}
function code(x) return atanh(x) end
function tmp = code(x) tmp = atanh(x); end
\begin{array}{l}
\\
\tanh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))
float code(float x) {
return 0.5f * log1pf(((2.0f * x) / (1.0f - x)));
}
function code(x) return Float32(Float32(0.5) * log1p(Float32(Float32(Float32(2.0) * x) / Float32(Float32(1.0) - x)))) end
\begin{array}{l}
\\
0.5 \cdot \mathsf{log1p}\left(\frac{2 \cdot x}{1 - x}\right)
\end{array}
(FPCore (x) :precision binary32 (* (* x 2.0) 0.5))
float code(float x) {
return (x * 2.0f) * 0.5f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = (x * 2.0e0) * 0.5e0
end function
function code(x) return Float32(Float32(x * Float32(2.0)) * Float32(0.5)) end
function tmp = code(x) tmp = (x * single(2.0)) * single(0.5); end
\begin{array}{l}
\\
\left(x \cdot 2\right) \cdot 0.5
\end{array}
Initial program 82.9%
Taylor expanded in x around 0
lower-*.f3296.5
Applied rewrites96.5%
Final simplification96.5%
herbie shell --seed 2024331
(FPCore (x)
:name "Rust f32::atanh"
:precision binary32
(* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))