
(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 6 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 (* (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}
Initial program 52.4%
difference-of-sqr-152.4%
sqrt-prod99.6%
sub-neg99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x) :precision binary32 (log (+ x (- x (/ 0.5 x)))))
float code(float x) {
return logf((x + (x - (0.5f / x))));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log((x + (x - (0.5e0 / x))))
end function
function code(x) return log(Float32(x + Float32(x - Float32(Float32(0.5) / x)))) end
function tmp = code(x) tmp = log((x + (x - (single(0.5) / x)))); end
\begin{array}{l}
\\
\log \left(x + \left(x - \frac{0.5}{x}\right)\right)
\end{array}
Initial program 52.4%
Taylor expanded in x around inf 97.5%
associate-*r/97.5%
metadata-eval97.5%
Simplified97.5%
Final simplification97.5%
(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 52.4%
difference-of-sqr-152.4%
sqrt-prod99.6%
sub-neg99.6%
metadata-eval99.6%
Applied egg-rr99.6%
sqrt-unprod52.4%
metadata-eval52.4%
sub-neg52.4%
difference-of-sqr-152.4%
fma-neg52.4%
metadata-eval52.4%
flip-+9.2%
log-div9.2%
add-sqr-sqrt9.1%
fma-udef9.1%
associate--r+11.4%
+-inverses11.4%
metadata-eval11.4%
metadata-eval11.4%
Applied egg-rr11.4%
Taylor expanded in x around inf 96.1%
Final simplification96.1%
(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 52.4%
Taylor expanded in x around inf 95.7%
Final simplification95.7%
(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 52.4%
add-cbrt-cube39.3%
cbrt-prod52.4%
associate-*r*52.4%
fma-neg52.4%
add-cube-cbrt52.4%
pow352.4%
cbrt-prod52.4%
pow252.4%
pow-prod-up52.4%
metadata-eval52.4%
metadata-eval52.4%
Applied egg-rr52.4%
fma-udef52.4%
+-commutative52.4%
pow-plus52.4%
metadata-eval52.4%
Simplified52.4%
Taylor expanded in x around inf 43.9%
mul-1-neg43.9%
log-rec43.9%
remove-double-neg43.9%
Simplified43.9%
Final simplification43.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 52.4%
difference-of-sqr-152.4%
sqrt-prod99.6%
sub-neg99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 -0.0%
Simplified2.1%
Taylor expanded in x around 0 3.0%
Final simplification3.0%
(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 2023334
(FPCore (x)
:name "Rust f32::acosh"
:precision binary32
:pre (>= x 1.0)
:herbie-target
(log (+ x (* (sqrt (- x 1.0)) (sqrt (+ x 1.0)))))
(log (+ x (sqrt (- (* x x) 1.0)))))