
(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 10 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 x) (+ (log 2.0) (/ -0.25 (pow x 2.0)))))
float code(float x) {
return logf(x) + (logf(2.0f) + (-0.25f / powf(x, 2.0f)));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log(x) + (log(2.0e0) + ((-0.25e0) / (x ** 2.0e0)))
end function
function code(x) return Float32(log(x) + Float32(log(Float32(2.0)) + Float32(Float32(-0.25) / (x ^ Float32(2.0))))) end
function tmp = code(x) tmp = log(x) + (log(single(2.0)) + (single(-0.25) / (x ^ single(2.0)))); end
\begin{array}{l}
\\
\log x + \left(\log 2 + \frac{-0.25}{{x}^{2}}\right)
\end{array}
Initial program 50.3%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
+-commutative98.2%
associate-+l+98.2%
mul-1-neg98.2%
log-rec98.2%
remove-double-neg98.2%
associate-*r/98.2%
metadata-eval98.2%
distribute-neg-frac98.2%
metadata-eval98.2%
Simplified98.2%
(FPCore (x) :precision binary32 (log1p (* x (+ 2.0 (/ (- -1.0 (/ 0.5 x)) x)))))
float code(float x) {
return log1pf((x * (2.0f + ((-1.0f - (0.5f / x)) / x))));
}
function code(x) return log1p(Float32(x * Float32(Float32(2.0) + Float32(Float32(Float32(-1.0) - Float32(Float32(0.5) / x)) / x)))) end
\begin{array}{l}
\\
\mathsf{log1p}\left(x \cdot \left(2 + \frac{-1 - \frac{0.5}{x}}{x}\right)\right)
\end{array}
Initial program 50.3%
log1p-expm1-u50.3%
expm1-undefine50.3%
add-exp-log50.3%
fmm-def50.3%
metadata-eval50.3%
Applied egg-rr50.3%
Taylor expanded in x around inf 97.8%
mul-1-neg97.8%
unsub-neg97.8%
associate-*r/97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification97.8%
(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 50.3%
flip-+5.9%
div-inv5.9%
log-prod5.9%
pow25.9%
add-sqr-sqrt5.7%
fmm-def5.7%
metadata-eval5.7%
fmm-def5.7%
metadata-eval5.7%
Applied egg-rr5.7%
log-rec5.7%
sub-neg5.7%
fma-undefine5.7%
unpow25.7%
associate--r+8.2%
+-inverses8.2%
metadata-eval8.2%
metadata-eval8.2%
neg-sub08.2%
Simplified8.2%
Taylor expanded in x around inf 97.8%
(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 50.3%
Taylor expanded in x around inf 96.7%
(FPCore (x) :precision binary32 8.0)
float code(float x) {
return 8.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 8.0e0
end function
function code(x) return Float32(8.0) end
function tmp = code(x) tmp = single(8.0); end
\begin{array}{l}
\\
8
\end{array}
Initial program 50.3%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
+-commutative98.2%
associate-+l+98.2%
mul-1-neg98.2%
log-rec98.2%
remove-double-neg98.2%
associate-*r/98.2%
metadata-eval98.2%
distribute-neg-frac98.2%
metadata-eval98.2%
Simplified98.2%
Applied egg-rr25.0%
(FPCore (x) :precision binary32 4.0)
float code(float x) {
return 4.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 4.0e0
end function
function code(x) return Float32(4.0) end
function tmp = code(x) tmp = single(4.0); end
\begin{array}{l}
\\
4
\end{array}
Initial program 50.3%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
+-commutative98.2%
associate-+l+98.2%
mul-1-neg98.2%
log-rec98.2%
remove-double-neg98.2%
associate-*r/98.2%
metadata-eval98.2%
distribute-neg-frac98.2%
metadata-eval98.2%
Simplified98.2%
Applied egg-rr23.4%
(FPCore (x) :precision binary32 3.0)
float code(float x) {
return 3.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 3.0e0
end function
function code(x) return Float32(3.0) end
function tmp = code(x) tmp = single(3.0); end
\begin{array}{l}
\\
3
\end{array}
Initial program 50.3%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
+-commutative98.2%
associate-+l+98.2%
mul-1-neg98.2%
log-rec98.2%
remove-double-neg98.2%
associate-*r/98.2%
metadata-eval98.2%
distribute-neg-frac98.2%
metadata-eval98.2%
Simplified98.2%
Applied egg-rr22.6%
(FPCore (x) :precision binary32 2.0)
float code(float x) {
return 2.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 2.0e0
end function
function code(x) return Float32(2.0) end
function tmp = code(x) tmp = single(2.0); end
\begin{array}{l}
\\
2
\end{array}
Initial program 50.3%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
+-commutative98.2%
associate-+l+98.2%
mul-1-neg98.2%
log-rec98.2%
remove-double-neg98.2%
associate-*r/98.2%
metadata-eval98.2%
distribute-neg-frac98.2%
metadata-eval98.2%
Simplified98.2%
Applied egg-rr22.0%
(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 50.3%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
+-commutative98.2%
associate-+l+98.2%
mul-1-neg98.2%
log-rec98.2%
remove-double-neg98.2%
associate-*r/98.2%
metadata-eval98.2%
distribute-neg-frac98.2%
metadata-eval98.2%
Simplified98.2%
Applied egg-rr20.9%
(FPCore (x) :precision binary32 0.25)
float code(float x) {
return 0.25f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 0.25e0
end function
function code(x) return Float32(0.25) end
function tmp = code(x) tmp = single(0.25); end
\begin{array}{l}
\\
0.25
\end{array}
Initial program 50.3%
Taylor expanded in x around inf 98.2%
sub-neg98.2%
+-commutative98.2%
associate-+l+98.2%
mul-1-neg98.2%
log-rec98.2%
remove-double-neg98.2%
associate-*r/98.2%
metadata-eval98.2%
distribute-neg-frac98.2%
metadata-eval98.2%
Simplified98.2%
Applied egg-rr19.4%
(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 2024188
(FPCore (x)
:name "Rust f32::acosh"
:precision binary32
:pre (>= x 1.0)
:alt
(! :herbie-platform default (log (+ x (* (sqrt (- x 1)) (sqrt (+ x 1))))))
(log (+ x (sqrt (- (* x x) 1.0)))))