
(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 (- 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 58.3%
Taylor expanded in x around inf 96.8%
associate-*r/96.8%
metadata-eval96.8%
Simplified96.8%
Final simplification96.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 58.3%
Taylor expanded in x around inf 94.7%
Final simplification94.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 58.3%
Taylor expanded in x around inf 96.8%
associate-*r/96.8%
metadata-eval96.8%
Simplified96.8%
*-un-lft-identity96.8%
fma-def96.8%
sub-neg96.8%
distribute-neg-frac96.8%
metadata-eval96.8%
Applied egg-rr96.8%
Simplified43.0%
Taylor expanded in x around inf 43.7%
Final simplification43.7%
(FPCore (x) :precision binary32 1.1068793402777777)
float code(float x) {
return 1.1068793402777777f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 1.1068793402777777e0
end function
function code(x) return Float32(1.1068793402777777) end
function tmp = code(x) tmp = single(1.1068793402777777); end
\begin{array}{l}
\\
1.1068793402777777
\end{array}
Initial program 58.3%
add-sqr-sqrt57.4%
pow257.4%
fma-neg57.4%
metadata-eval57.4%
Applied egg-rr57.4%
Taylor expanded in x around -inf -0.0%
Simplified21.4%
metadata-eval21.4%
Applied egg-rr21.4%
Final simplification21.4%
(FPCore (x) :precision binary32 1.1614583333333333)
float code(float x) {
return 1.1614583333333333f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 1.1614583333333333e0
end function
function code(x) return Float32(1.1614583333333333) end
function tmp = code(x) tmp = single(1.1614583333333333); end
\begin{array}{l}
\\
1.1614583333333333
\end{array}
Initial program 58.3%
add-sqr-sqrt57.4%
pow257.4%
fma-neg57.4%
metadata-eval57.4%
Applied egg-rr57.4%
Taylor expanded in x around inf 98.2%
Simplified21.5%
Final simplification21.5%
(FPCore (x) :precision binary32 2.109375)
float code(float x) {
return 2.109375f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 2.109375e0
end function
function code(x) return Float32(2.109375) end
function tmp = code(x) tmp = single(2.109375); end
\begin{array}{l}
\\
2.109375
\end{array}
Initial program 58.3%
add-sqr-sqrt57.4%
pow257.4%
fma-neg57.4%
metadata-eval57.4%
Applied egg-rr57.4%
Taylor expanded in x around inf 98.0%
Simplified22.5%
Final simplification22.5%
(FPCore (x) :precision binary32 4.211046006944445)
float code(float x) {
return 4.211046006944445f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 4.211046006944445e0
end function
function code(x) return Float32(4.211046006944445) end
function tmp = code(x) tmp = single(4.211046006944445); end
\begin{array}{l}
\\
4.211046006944445
\end{array}
Initial program 58.3%
add-sqr-sqrt57.4%
pow257.4%
fma-neg57.4%
metadata-eval57.4%
Applied egg-rr57.4%
Taylor expanded in x around inf 97.1%
Simplified24.3%
metadata-eval24.3%
Applied egg-rr24.3%
Final simplification24.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 2023224
(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)))))