
(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 7 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 (- 2.0 (/ 0.5 (pow x 2.0))))))
float code(float x) {
return logf((x * (2.0f - (0.5f / powf(x, 2.0f)))));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log((x * (2.0e0 - (0.5e0 / (x ** 2.0e0)))))
end function
function code(x) return log(Float32(x * Float32(Float32(2.0) - Float32(Float32(0.5) / (x ^ Float32(2.0)))))) end
function tmp = code(x) tmp = log((x * (single(2.0) - (single(0.5) / (x ^ single(2.0)))))); end
\begin{array}{l}
\\
\log \left(x \cdot \left(2 - \frac{0.5}{{x}^{2}}\right)\right)
\end{array}
Initial program 54.7%
Taylor expanded in x around inf 98.7%
associate-*r/98.7%
metadata-eval98.7%
Simplified98.7%
(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.7%
Taylor expanded in x around inf 97.2%
(FPCore (x) :precision binary32 (log x))
float code(float x) {
return logf(x);
}
real(4) function code(x)
real(4), intent (in) :: x
code = log(x)
end function
function code(x) return log(x) end
function tmp = code(x) tmp = log(x); end
\begin{array}{l}
\\
\log x
\end{array}
Initial program 54.7%
Taylor expanded in x around inf 98.7%
associate-*r/98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in x around 0 -0.0%
Simplified44.0%
(FPCore (x) :precision binary32 63.75)
float code(float x) {
return 63.75f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 63.75e0
end function
function code(x) return Float32(63.75) end
function tmp = code(x) tmp = single(63.75); end
\begin{array}{l}
\\
63.75
\end{array}
Initial program 54.7%
add-sqr-sqrt54.6%
pow254.6%
log-pow54.6%
fma-neg54.6%
metadata-eval54.6%
Applied egg-rr54.6%
Taylor expanded in x around 0 -0.0%
Simplified2.2%
flip-+2.0%
div-inv2.0%
metadata-eval2.0%
pow22.0%
div-inv2.0%
unpow-prod-down1.9%
metadata-eval1.9%
metadata-eval1.9%
div-inv1.9%
metadata-eval1.9%
Applied egg-rr1.9%
Simplified30.9%
(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 54.7%
add-sqr-sqrt54.6%
pow254.6%
log-pow54.6%
fma-neg54.6%
metadata-eval54.6%
Applied egg-rr54.6%
Taylor expanded in x around inf 97.2%
pow1/297.2%
flip-+-0.0%
difference-of-squares-0.0%
+-inverses-0.0%
+-inverses-0.0%
+-inverses-0.0%
+-inverses-0.0%
associate-*r/-0.0%
difference-of-squares-0.0%
+-inverses-0.0%
+-inverses-0.0%
associate-*r/-0.0%
+-inverses-0.0%
+-inverses-0.0%
flip-+12.9%
associate-*l*12.9%
pow312.9%
pow-pow19.9%
metadata-eval19.9%
metadata-eval19.9%
Applied egg-rr-0.0%
Simplified22.9%
metadata-eval22.9%
Applied egg-rr22.9%
(FPCore (x) :precision binary32 1.3333333333333333)
float code(float x) {
return 1.3333333333333333f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 1.3333333333333333e0
end function
function code(x) return Float32(1.3333333333333333) end
function tmp = code(x) tmp = single(1.3333333333333333); end
\begin{array}{l}
\\
1.3333333333333333
\end{array}
Initial program 54.7%
add-sqr-sqrt54.6%
pow254.6%
log-pow54.6%
fma-neg54.6%
metadata-eval54.6%
Applied egg-rr54.6%
Taylor expanded in x around inf 97.2%
pow197.2%
pow197.2%
flip-+-0.0%
difference-of-squares-0.0%
+-inverses-0.0%
+-inverses-0.0%
+-inverses-0.0%
+-inverses-0.0%
associate-*r/-0.0%
+-inverses-0.0%
+-inverses-0.0%
flip-+17.4%
sqrt-unprod28.0%
add-sqr-sqrt28.0%
add-cbrt-cube13.6%
pow1/313.6%
Applied egg-rr-0.0%
Simplified21.5%
metadata-eval21.5%
Applied egg-rr21.5%
(FPCore (x) :precision binary32 1.25)
float code(float x) {
return 1.25f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 1.25e0
end function
function code(x) return Float32(1.25) end
function tmp = code(x) tmp = single(1.25); end
\begin{array}{l}
\\
1.25
\end{array}
Initial program 54.7%
add-sqr-sqrt54.6%
pow254.6%
log-pow54.6%
fma-neg54.6%
metadata-eval54.6%
Applied egg-rr54.6%
Taylor expanded in x around 0 -0.0%
Simplified2.2%
Taylor expanded in x around inf 2.2%
Simplified21.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 2024137
(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)))))