
(FPCore (x) :precision binary32 (acosh x))
float code(float x) {
return acoshf(x);
}
function code(x) return acosh(x) end
function tmp = code(x) tmp = acosh(x); end
\begin{array}{l}
\\
\cosh^{-1} x
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary32 (log (+ x (sqrt (- (* x x) 1.0)))))
float code(float x) {
return logf((x + sqrtf(((x * x) - 1.0f))));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log((x + sqrt(((x * x) - 1.0e0))))
end function
function code(x) return log(Float32(x + sqrt(Float32(Float32(x * x) - Float32(1.0))))) end
function tmp = code(x) tmp = log((x + sqrt(((x * x) - single(1.0))))); end
\begin{array}{l}
\\
\log \left(x + \sqrt{x \cdot x - 1}\right)
\end{array}
(FPCore (x) :precision binary32 (log (+ (/ -0.5 x) (* x 2.0))))
float code(float x) {
return logf(((-0.5f / x) + (x * 2.0f)));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log((((-0.5e0) / x) + (x * 2.0e0)))
end function
function code(x) return log(Float32(Float32(Float32(-0.5) / x) + Float32(x * Float32(2.0)))) end
function tmp = code(x) tmp = log(((single(-0.5) / x) + (x * single(2.0)))); end
\begin{array}{l}
\\
\log \left(\frac{-0.5}{x} + x \cdot 2\right)
\end{array}
Initial program 54.3%
log1p-expm1-u54.3%
expm1-undefine54.3%
add-exp-log54.3%
fma-neg54.3%
metadata-eval54.3%
Applied egg-rr54.3%
Taylor expanded in x around inf 98.6%
mul-1-neg98.6%
unsub-neg98.6%
associate-*r/98.6%
metadata-eval98.6%
Simplified98.6%
sub-neg98.6%
distribute-lft-in98.6%
distribute-neg-frac298.6%
Applied egg-rr98.6%
Taylor expanded in x around 0 98.6%
div-sub98.6%
sub-neg98.6%
associate-/l*98.6%
*-inverses98.6%
metadata-eval98.6%
distribute-neg-frac98.6%
metadata-eval98.6%
Simplified98.6%
add-log-exp98.6%
*-un-lft-identity98.6%
log-prod98.6%
metadata-eval98.6%
add-log-exp98.6%
+-commutative98.6%
+-commutative98.6%
associate-+l+98.6%
+-commutative98.6%
fma-define98.6%
Applied egg-rr98.6%
+-lft-identity98.6%
log1p-undefine98.7%
+-commutative98.7%
associate-+l+98.7%
fma-undefine98.7%
associate-+l+98.7%
metadata-eval98.7%
+-rgt-identity98.7%
Simplified98.7%
(FPCore (x) :precision binary32 (- (log (/ 0.5 x))))
float code(float x) {
return -logf((0.5f / x));
}
real(4) function code(x)
real(4), intent (in) :: x
code = -log((0.5e0 / x))
end function
function code(x) return Float32(-log(Float32(Float32(0.5) / x))) end
function tmp = code(x) tmp = -log((single(0.5) / x)); end
\begin{array}{l}
\\
-\log \left(\frac{0.5}{x}\right)
\end{array}
Initial program 54.3%
fma-neg54.3%
metadata-eval54.3%
flip-+9.5%
metadata-eval9.5%
fma-neg9.5%
div-inv9.5%
log-prod9.5%
pow29.5%
add-sqr-sqrt9.3%
fma-neg9.3%
metadata-eval9.3%
Applied egg-rr9.3%
log-rec9.3%
sub-neg9.3%
fma-undefine9.2%
unpow29.2%
associate--r+11.7%
+-inverses11.7%
metadata-eval11.7%
metadata-eval11.7%
neg-sub011.7%
Simplified11.7%
Taylor expanded in x around inf 96.5%
(FPCore (x) :precision binary32 (log (+ x x)))
float code(float x) {
return logf((x + x));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log((x + x))
end function
function code(x) return log(Float32(x + x)) end
function tmp = code(x) tmp = log((x + x)); end
\begin{array}{l}
\\
\log \left(x + x\right)
\end{array}
Initial program 54.3%
Taylor expanded in x around inf 96.5%
(FPCore (x) :precision binary32 (log (+ x (* (sqrt (- x 1.0)) (sqrt (+ x 1.0))))))
float code(float x) {
return logf((x + (sqrtf((x - 1.0f)) * sqrtf((x + 1.0f)))));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log((x + (sqrt((x - 1.0e0)) * sqrt((x + 1.0e0)))))
end function
function code(x) return log(Float32(x + Float32(sqrt(Float32(x - Float32(1.0))) * sqrt(Float32(x + Float32(1.0)))))) end
function tmp = code(x) tmp = log((x + (sqrt((x - single(1.0))) * sqrt((x + single(1.0)))))); end
\begin{array}{l}
\\
\log \left(x + \sqrt{x - 1} \cdot \sqrt{x + 1}\right)
\end{array}
herbie shell --seed 2024107
(FPCore (x)
:name "Rust f32::acosh"
:precision binary32
:pre (>= x 1.0)
:alt
(log (+ x (* (sqrt (- x 1.0)) (sqrt (+ x 1.0)))))
(log (+ x (sqrt (- (* x x) 1.0)))))