
(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 2 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)
float code(float x) {
return x;
}
real(4) function code(x)
real(4), intent (in) :: x
code = x
end function
function code(x) return x end
function tmp = code(x) tmp = x; end
\begin{array}{l}
\\
x
\end{array}
Initial program 91.4%
Applied rewrites62.9%
lift-/.f32N/A
lift--.f32N/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
lift-+.f32N/A
un-div-invN/A
metadata-evalN/A
frac-2negN/A
associate-*r/N/A
*-commutativeN/A
neg-mul-1N/A
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
distribute-rgt-neg-inN/A
lift-+.f32N/A
+-commutativeN/A
lift-pow.f32N/A
sqr-powN/A
Applied rewrites22.2%
Taylor expanded in x around 0
distribute-rgt-inN/A
*-lft-identityN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
Applied rewrites97.1%
(FPCore (x) :precision binary32 1.0)
float code(float x) {
return 1.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 1.0e0
end function
function code(x) return Float32(1.0) end
function tmp = code(x) tmp = single(1.0); end
\begin{array}{l}
\\
1
\end{array}
Initial program 92.2%
Applied rewrites63.3%
lift-/.f32N/A
lift--.f32N/A
sub-negN/A
metadata-evalN/A
distribute-neg-inN/A
lift-+.f32N/A
un-div-invN/A
metadata-evalN/A
frac-2negN/A
associate-*r/N/A
*-commutativeN/A
neg-mul-1N/A
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
distribute-rgt-neg-inN/A
lift-+.f32N/A
+-commutativeN/A
lift-pow.f32N/A
sqr-powN/A
Applied rewrites21.2%
Taylor expanded in x around -inf
unpow2N/A
rem-square-sqrtN/A
metadata-eval7.5
Applied rewrites7.5%
herbie shell --seed 2024298
(FPCore (x)
:name "Rust f32::atanh"
:precision binary32
(* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))