
(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 5 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 (- 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 49.9%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification98.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 49.9%
Taylor expanded in x around inf 97.3%
Final simplification97.3%
(FPCore (x) :precision binary32 (log 9.0))
float code(float x) {
return logf(9.0f);
}
real(4) function code(x)
real(4), intent (in) :: x
code = log(9.0e0)
end function
function code(x) return log(Float32(9.0)) end
function tmp = code(x) tmp = log(single(9.0)); end
\begin{array}{l}
\\
\log 9
\end{array}
Initial program 49.9%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
associate-+r-98.5%
flip-+-0.0%
+-inverses-0.0%
metadata-eval-0.0%
+-inverses-0.0%
+-inverses-0.0%
metadata-eval-0.0%
+-inverses-0.0%
cube-div-0.0%
flip-+12.0%
count-212.0%
unpow-prod-down12.0%
metadata-eval12.0%
metadata-eval12.0%
metadata-eval12.0%
clear-num12.0%
div-inv12.0%
metadata-eval12.0%
*-commutative12.0%
count-212.0%
flip-+-0.0%
+-inverses-0.0%
+-inverses-0.0%
+-inverses-0.0%
+-inverses-0.0%
clear-num-0.0%
flip-+12.0%
count-212.0%
*-commutative12.0%
Applied egg-rr12.0%
Simplified22.2%
Final simplification22.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 49.9%
pow249.9%
pow-to-exp49.7%
expm1-def49.7%
Applied egg-rr49.7%
Taylor expanded in x around inf 44.3%
Final simplification44.3%
(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 49.9%
pow249.9%
pow-to-exp49.7%
expm1-def49.7%
Applied egg-rr49.7%
Taylor expanded in x around 0 13.4%
Simplified21.3%
Final simplification21.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 2023171
(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)))))