
(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 8 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 2.0) (- (log x) (/ 0.25 (* x x)))))
float code(float x) {
return logf(2.0f) + (logf(x) - (0.25f / (x * x)));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log(2.0e0) + (log(x) - (0.25e0 / (x * x)))
end function
function code(x) return Float32(log(Float32(2.0)) + Float32(log(x) - Float32(Float32(0.25) / Float32(x * x)))) end
function tmp = code(x) tmp = log(single(2.0)) + (log(x) - (single(0.25) / (x * x))); end
\begin{array}{l}
\\
\log 2 + \left(\log x - \frac{0.25}{x \cdot x}\right)
\end{array}
Initial program 47.0%
Taylor expanded in x around inf 97.5%
associate--l+97.5%
mul-1-neg97.5%
log-rec97.5%
remove-double-neg97.5%
unpow297.5%
associate-*r/97.5%
metadata-eval97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (x) :precision binary32 (log1p (+ (- (* 2.0 x) (+ (/ 0.5 x) (* (/ 0.25 (* x x)) (/ 0.5 x)))) -1.0)))
float code(float x) {
return log1pf((((2.0f * x) - ((0.5f / x) + ((0.25f / (x * x)) * (0.5f / x)))) + -1.0f));
}
function code(x) return log1p(Float32(Float32(Float32(Float32(2.0) * x) - Float32(Float32(Float32(0.5) / x) + Float32(Float32(Float32(0.25) / Float32(x * x)) * Float32(Float32(0.5) / x)))) + Float32(-1.0))) end
\begin{array}{l}
\\
\mathsf{log1p}\left(\left(2 \cdot x - \left(\frac{0.5}{x} + \frac{0.25}{x \cdot x} \cdot \frac{0.5}{x}\right)\right) + -1\right)
\end{array}
Initial program 47.0%
log1p-expm1-u47.0%
expm1-udef47.0%
add-exp-log47.0%
fma-neg47.0%
metadata-eval47.0%
Applied egg-rr47.0%
Taylor expanded in x around inf 97.4%
*-commutative97.4%
+-commutative97.4%
associate-*r/97.4%
metadata-eval97.4%
associate-*r/97.4%
metadata-eval97.4%
Simplified97.4%
metadata-eval97.4%
cube-div97.4%
cube-mult97.4%
frac-times97.4%
metadata-eval97.4%
Applied egg-rr97.4%
Final simplification97.4%
(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 47.0%
Taylor expanded in x around inf 97.0%
associate-*r/97.0%
metadata-eval97.0%
Simplified97.0%
Final simplification97.0%
(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 47.0%
Taylor expanded in x around inf 95.6%
Final simplification95.6%
(FPCore (x) :precision binary32 (log 2.0))
float code(float x) {
return logf(2.0f);
}
real(4) function code(x)
real(4), intent (in) :: x
code = log(2.0e0)
end function
function code(x) return log(Float32(2.0)) end
function tmp = code(x) tmp = log(single(2.0)); end
\begin{array}{l}
\\
\log 2
\end{array}
Initial program 47.0%
Taylor expanded in x around inf 97.5%
associate--l+97.5%
mul-1-neg97.5%
log-rec97.5%
remove-double-neg97.5%
unpow297.5%
associate-*r/97.5%
metadata-eval97.5%
Simplified97.5%
expm1-log1p-u95.7%
metadata-eval95.7%
frac-times95.7%
cancel-sign-sub-inv95.7%
distribute-lft-neg-in95.7%
frac-times95.7%
metadata-eval95.7%
associate-/r*95.7%
associate-/r*95.7%
clear-num95.7%
div-inv95.7%
metadata-eval95.7%
metadata-eval95.7%
swap-sqr95.7%
*-commutative95.7%
count-295.7%
flip-+-0.0%
+-inverses-0.0%
+-inverses-0.0%
associate-*r/-0.0%
*-commutative-0.0%
count-2-0.0%
+-inverses-0.0%
+-inverses-0.0%
difference-of-squares-0.0%
+-inverses-0.0%
+-inverses-0.0%
Applied egg-rr91.7%
Taylor expanded in x around 0 20.5%
Taylor expanded in x around inf 20.6%
Final simplification20.6%
(FPCore (x) :precision binary32 (/ -0.25 (* x x)))
float code(float x) {
return -0.25f / (x * x);
}
real(4) function code(x)
real(4), intent (in) :: x
code = (-0.25e0) / (x * x)
end function
function code(x) return Float32(Float32(-0.25) / Float32(x * x)) end
function tmp = code(x) tmp = single(-0.25) / (x * x); end
\begin{array}{l}
\\
\frac{-0.25}{x \cdot x}
\end{array}
Initial program 47.0%
log1p-expm1-u47.0%
expm1-udef47.0%
add-exp-log47.0%
fma-neg47.0%
metadata-eval47.0%
Applied egg-rr47.0%
Taylor expanded in x around inf 97.5%
+-commutative97.5%
mul-1-neg97.5%
log-rec97.5%
remove-double-neg97.5%
log-prod96.9%
unpow296.9%
associate-*r/96.9%
metadata-eval96.9%
associate-/r*96.9%
Simplified96.9%
Taylor expanded in x around 0 5.4%
unpow25.4%
Simplified5.4%
Final simplification5.4%
(FPCore (x) :precision binary32 (/ -0.5 x))
float code(float x) {
return -0.5f / x;
}
real(4) function code(x)
real(4), intent (in) :: x
code = (-0.5e0) / x
end function
function code(x) return Float32(Float32(-0.5) / x) end
function tmp = code(x) tmp = single(-0.5) / x; end
\begin{array}{l}
\\
\frac{-0.5}{x}
\end{array}
Initial program 47.0%
Taylor expanded in x around inf 97.5%
associate--l+97.5%
mul-1-neg97.5%
log-rec97.5%
remove-double-neg97.5%
unpow297.5%
associate-*r/97.5%
metadata-eval97.5%
Simplified97.5%
expm1-log1p-u95.7%
metadata-eval95.7%
frac-times95.7%
cancel-sign-sub-inv95.7%
distribute-lft-neg-in95.7%
frac-times95.7%
metadata-eval95.7%
associate-/r*95.7%
associate-/r*95.7%
clear-num95.7%
div-inv95.7%
metadata-eval95.7%
metadata-eval95.7%
swap-sqr95.7%
*-commutative95.7%
count-295.7%
flip-+-0.0%
+-inverses-0.0%
+-inverses-0.0%
associate-*r/-0.0%
*-commutative-0.0%
count-2-0.0%
+-inverses-0.0%
+-inverses-0.0%
difference-of-squares-0.0%
+-inverses-0.0%
+-inverses-0.0%
Applied egg-rr91.7%
Taylor expanded in x around 0 20.5%
Taylor expanded in x around 0 4.5%
Final simplification4.5%
(FPCore (x) :precision binary32 -0.03125)
float code(float x) {
return -0.03125f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = -0.03125e0
end function
function code(x) return Float32(-0.03125) end
function tmp = code(x) tmp = single(-0.03125); end
\begin{array}{l}
\\
-0.03125
\end{array}
Initial program 47.0%
Taylor expanded in x around inf 97.0%
associate-*r/97.0%
metadata-eval97.0%
Simplified97.0%
Taylor expanded in x around inf 97.6%
Simplified3.2%
Final simplification3.2%
(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 2023275
(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)))))