
(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 13 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 (cast (! :precision binary64 (log (+ x (sqrt (+ (* x x) -1.0)))))))
float code(float x) {
double tmp = log((((double) x) + sqrt(((((double) x) * ((double) x)) + -1.0))));
return (float) tmp;
}
real(4) function code(x)
real(4), intent (in) :: x
real(8) :: tmp
tmp = log((real(x, 8) + sqrt(((real(x, 8) * real(x, 8)) + (-1.0d0)))))
code = real(tmp, 4)
end function
function code(x) tmp = log(Float64(Float64(x) + sqrt(Float64(Float64(Float64(x) * Float64(x)) + -1.0)))) return Float32(tmp) end
function tmp_2 = code(x) tmp = log((double(x) + sqrt(((double(x) * double(x)) + -1.0)))); tmp_2 = single(tmp); end
\begin{array}{l}
\\
\langle \left( \log \left(x + \sqrt{x \cdot x + -1}\right) \right)_{\text{binary64}} \rangle_{\text{binary32}}
\end{array}
Initial program 56.8%
rewrite-binary32/binary64100.0%
Applied rewrite-once100.0%
Final simplification100.0%
(FPCore (x) :precision binary32 (- (log (+ (/ 0.5 x) (/ (/ (/ 0.125 x) x) x)))))
float code(float x) {
return -logf(((0.5f / x) + (((0.125f / x) / x) / x)));
}
real(4) function code(x)
real(4), intent (in) :: x
code = -log(((0.5e0 / x) + (((0.125e0 / x) / x) / x)))
end function
function code(x) return Float32(-log(Float32(Float32(Float32(0.5) / x) + Float32(Float32(Float32(Float32(0.125) / x) / x) / x)))) end
function tmp = code(x) tmp = -log(((single(0.5) / x) + (((single(0.125) / x) / x) / x))); end
\begin{array}{l}
\\
-\log \left(\frac{0.5}{x} + \frac{\frac{\frac{0.125}{x}}{x}}{x}\right)
\end{array}
Initial program 56.8%
flip-+7.8%
clear-num7.8%
log-rec7.8%
clear-num7.8%
flip-+56.8%
fma-neg56.8%
metadata-eval56.8%
Applied egg-rr56.8%
Taylor expanded in x around inf 99.1%
associate-*r/99.1%
metadata-eval99.1%
associate-*r/99.1%
metadata-eval99.1%
Simplified99.1%
metadata-eval99.1%
cube-div99.1%
unpow399.1%
associate-*l/99.1%
associate-*r/99.1%
metadata-eval99.1%
Applied egg-rr99.1%
associate-*l/99.1%
associate-*r/99.1%
associate-*l/99.1%
metadata-eval99.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (x) :precision binary32 (log (- (* x 2.0) (/ 0.5 x))))
float code(float x) {
return logf(((x * 2.0f) - (0.5f / x)));
}
real(4) function code(x)
real(4), intent (in) :: x
code = log(((x * 2.0e0) - (0.5e0 / x)))
end function
function code(x) return log(Float32(Float32(x * Float32(2.0)) - Float32(Float32(0.5) / x))) end
function tmp = code(x) tmp = log(((x * single(2.0)) - (single(0.5) / x))); end
\begin{array}{l}
\\
\log \left(x \cdot 2 - \frac{0.5}{x}\right)
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 98.8%
*-commutative98.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
Final simplification98.8%
(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 56.8%
flip-+7.8%
clear-num7.8%
log-rec7.8%
clear-num7.8%
flip-+56.8%
fma-neg56.8%
metadata-eval56.8%
Applied egg-rr56.8%
Taylor expanded in x around inf 97.4%
Final simplification97.4%
(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.8%
Taylor expanded in x around inf 97.0%
Final simplification97.0%
(FPCore (x) :precision binary32 0.75)
float code(float x) {
return 0.75f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 0.75e0
end function
function code(x) return Float32(0.75) end
function tmp = code(x) tmp = single(0.75); end
\begin{array}{l}
\\
0.75
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 97.0%
Applied egg-rr20.7%
Final simplification20.7%
(FPCore (x) :precision binary32 1.5)
float code(float x) {
return 1.5f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 1.5e0
end function
function code(x) return Float32(1.5) end
function tmp = code(x) tmp = single(1.5); end
\begin{array}{l}
\\
1.5
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 97.0%
Applied egg-rr21.7%
Final simplification21.7%
(FPCore (x) :precision binary32 2.0)
float code(float x) {
return 2.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 2.0e0
end function
function code(x) return Float32(2.0) end
function tmp = code(x) tmp = single(2.0); end
\begin{array}{l}
\\
2
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 97.0%
Applied egg-rr22.3%
Final simplification22.3%
(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 56.8%
Taylor expanded in x around inf 97.0%
Applied egg-rr23.1%
Final simplification23.1%
(FPCore (x) :precision binary32 4.0)
float code(float x) {
return 4.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 4.0e0
end function
function code(x) return Float32(4.0) end
function tmp = code(x) tmp = single(4.0); end
\begin{array}{l}
\\
4
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 97.0%
Applied egg-rr24.0%
Final simplification24.0%
(FPCore (x) :precision binary32 6.0)
float code(float x) {
return 6.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 6.0e0
end function
function code(x) return Float32(6.0) end
function tmp = code(x) tmp = single(6.0); end
\begin{array}{l}
\\
6
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 97.0%
Applied egg-rr24.8%
Final simplification24.8%
(FPCore (x) :precision binary32 8.0)
float code(float x) {
return 8.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 8.0e0
end function
function code(x) return Float32(8.0) end
function tmp = code(x) tmp = single(8.0); end
\begin{array}{l}
\\
8
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 97.0%
Applied egg-rr25.6%
Final simplification25.6%
(FPCore (x) :precision binary32 16.0)
float code(float x) {
return 16.0f;
}
real(4) function code(x)
real(4), intent (in) :: x
code = 16.0e0
end function
function code(x) return Float32(16.0) end
function tmp = code(x) tmp = single(16.0); end
\begin{array}{l}
\\
16
\end{array}
Initial program 56.8%
Taylor expanded in x around inf 97.0%
Applied egg-rr27.6%
Final simplification27.6%
(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 2023297
(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)))))