
(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 (+ (/ -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 56.1%
Taylor expanded in x around inf 98.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
unpow298.8%
Applied egg-rr98.8%
*-un-lft-identity98.8%
*-commutative98.8%
log-prod98.8%
Applied egg-rr98.8%
+-rgt-identity98.8%
fma-define98.8%
+-commutative98.8%
distribute-lft-out98.8%
fma-define98.8%
*-commutative98.8%
associate-*l*98.8%
metadata-eval98.8%
pow-plus98.8%
metadata-eval98.8%
unpow-198.8%
distribute-lft-neg-in98.8%
associate-*r/98.8%
metadata-eval98.8%
distribute-neg-frac98.8%
metadata-eval98.8%
Simplified98.8%
fma-undefine98.8%
add-exp-log98.8%
sum-log97.9%
add-sqr-sqrt97.0%
unpow297.0%
+-commutative97.0%
+-commutative97.0%
+-commutative97.0%
unpow297.0%
add-sqr-sqrt97.9%
sum-log98.8%
add-exp-log98.8%
Applied egg-rr98.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 56.1%
Taylor expanded in x around inf 97.5%
(FPCore (x) :precision binary32 (log (+ x 2.125)))
float code(float x) {
return logf((x + 2.125f));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log((x + 2.125e0))
end function
function code(x) return log(Float32(x + Float32(2.125))) end
function tmp = code(x) tmp = log((x + single(2.125))); end
\begin{array}{l}
\\
\log \left(x + 2.125\right)
\end{array}
Initial program 56.1%
add-exp-log55.9%
expm1-define55.9%
pow255.9%
log-pow55.9%
Applied egg-rr55.9%
Taylor expanded in x around -inf 1.4%
Simplified44.0%
(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 56.1%
add-exp-log55.9%
expm1-define55.9%
pow255.9%
log-pow55.9%
Applied egg-rr55.9%
Taylor expanded in x around -inf 1.4%
Simplified44.0%
Taylor expanded in x around inf 43.9%
log-rec43.9%
distribute-rgt-neg-in43.9%
mul-1-neg43.9%
remove-double-neg43.9%
Simplified43.9%
(FPCore (x) :precision binary32 2.09375)
float code(float x) {
return 2.09375f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 2.09375e0
end function
function code(x) return Float32(2.09375) end
function tmp = code(x) tmp = single(2.09375); end
\begin{array}{l}
\\
2.09375
\end{array}
Initial program 56.1%
add-exp-log55.9%
expm1-define55.9%
pow255.9%
log-pow55.9%
Applied egg-rr55.9%
Taylor expanded in x around inf 98.6%
Simplified22.4%
(FPCore (x) :precision binary32 2.03125)
float code(float x) {
return 2.03125f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 2.03125e0
end function
function code(x) return Float32(2.03125) end
function tmp = code(x) tmp = single(2.03125); end
\begin{array}{l}
\\
2.03125
\end{array}
Initial program 56.1%
Taylor expanded in x around inf 98.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in x around inf 98.3%
Simplified22.4%
(FPCore (x) :precision binary32 1.1458333333333333)
float code(float x) {
return 1.1458333333333333f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 1.1458333333333333e0
end function
function code(x) return Float32(1.1458333333333333) end
function tmp = code(x) tmp = single(1.1458333333333333); end
\begin{array}{l}
\\
1.1458333333333333
\end{array}
Initial program 56.1%
add-exp-log55.9%
expm1-define55.9%
pow255.9%
log-pow55.9%
Applied egg-rr55.9%
Taylor expanded in x around inf 98.8%
Simplified21.3%
(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 2024147
(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)))))