
(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 5 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 (* 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}
Initial program 99.7%
Final simplification99.7%
(FPCore (x) :precision binary32 (* 0.5 (log1p (* 2.0 (+ x (* x x))))))
float code(float x) {
return 0.5f * log1pf((2.0f * (x + (x * x))));
}
function code(x) return Float32(Float32(0.5) * log1p(Float32(Float32(2.0) * Float32(x + Float32(x * x))))) end
\begin{array}{l}
\\
0.5 \cdot \mathsf{log1p}\left(2 \cdot \left(x + x \cdot x\right)\right)
\end{array}
Initial program 99.7%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in x around 0 96.6%
distribute-lft-out96.6%
unpow296.6%
Simplified96.6%
Final simplification96.6%
(FPCore (x) :precision binary32 (* 0.5 (log1p (* x (/ 2.0 (- 1.0 x))))))
float code(float x) {
return 0.5f * log1pf((x * (2.0f / (1.0f - x))));
}
function code(x) return Float32(Float32(0.5) * log1p(Float32(x * Float32(Float32(2.0) / Float32(Float32(1.0) - x))))) end
\begin{array}{l}
\\
0.5 \cdot \mathsf{log1p}\left(x \cdot \frac{2}{1 - x}\right)
\end{array}
Initial program 99.7%
associate-/l*99.4%
Simplified99.4%
associate-/r/99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x) :precision binary32 (* 0.5 (log1p (+ x x))))
float code(float x) {
return 0.5f * log1pf((x + x));
}
function code(x) return Float32(Float32(0.5) * log1p(Float32(x + x))) end
\begin{array}{l}
\\
0.5 \cdot \mathsf{log1p}\left(x + x\right)
\end{array}
Initial program 99.7%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in x around 0 93.2%
count-293.2%
Simplified93.2%
Final simplification93.2%
(FPCore (x) :precision binary32 (* 0.5 (/ 0.5 x)))
float code(float x) {
return 0.5f * (0.5f / x);
}
real(4) function code(x)
real(4), intent (in) :: x
code = 0.5e0 * (0.5e0 / x)
end function
function code(x) return Float32(Float32(0.5) * Float32(Float32(0.5) / x)) end
function tmp = code(x) tmp = single(0.5) * (single(0.5) / x); end
\begin{array}{l}
\\
0.5 \cdot \frac{0.5}{x}
\end{array}
Initial program 99.7%
associate-/l*99.4%
Simplified99.4%
Taylor expanded in x around 0 92.9%
associate-/r/93.2%
metadata-eval93.2%
count-293.2%
flip-+-0.0%
clear-num-0.0%
+-inverses-0.0%
+-inverses-0.0%
+-inverses-0.0%
+-inverses-0.0%
flip-+5.3%
count-25.3%
metadata-eval5.3%
associate-/r/5.3%
clear-num5.3%
div-inv5.3%
metadata-eval5.3%
Applied egg-rr5.3%
Simplified5.3%
Taylor expanded in x around inf 7.8%
Final simplification7.8%
herbie shell --seed 2023196
(FPCore (x)
:name "Rust f32::atanh"
:precision binary32
(* 0.5 (log1p (/ (* 2.0 x) (- 1.0 x)))))