
(FPCore (f) :precision binary64 (let* ((t_0 (/ (PI) 4.0)) (t_1 (* t_0 f)) (t_2 (exp t_1)) (t_3 (exp (- t_1)))) (- (* (/ 1.0 t_0) (log (/ (+ t_2 t_3) (- t_2 t_3)))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4}\\
t_1 := t\_0 \cdot f\\
t_2 := e^{t\_1}\\
t_3 := e^{-t\_1}\\
-\frac{1}{t\_0} \cdot \log \left(\frac{t\_2 + t\_3}{t\_2 - t\_3}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (f) :precision binary64 (let* ((t_0 (/ (PI) 4.0)) (t_1 (* t_0 f)) (t_2 (exp t_1)) (t_3 (exp (- t_1)))) (- (* (/ 1.0 t_0) (log (/ (+ t_2 t_3) (- t_2 t_3)))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4}\\
t_1 := t\_0 \cdot f\\
t_2 := e^{t\_1}\\
t_3 := e^{-t\_1}\\
-\frac{1}{t\_0} \cdot \log \left(\frac{t\_2 + t\_3}{t\_2 - t\_3}\right)
\end{array}
\end{array}
(FPCore (f)
:precision binary64
(let* ((t_0 (/ (PI) 4.0))
(t_1 (* t_0 f))
(t_2 (exp t_1))
(t_3 (exp (- t_1)))
(t_4 (/ (+ t_2 t_3) (- t_2 t_3))))
(if (<= t_4 2e+16)
(- (* (/ 1.0 t_0) (log t_4)))
(- (+ t_2 (- (log t_1)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4}\\
t_1 := t\_0 \cdot f\\
t_2 := e^{t\_1}\\
t_3 := e^{-t\_1}\\
t_4 := \frac{t\_2 + t\_3}{t\_2 - t\_3}\\
\mathbf{if}\;t\_4 \leq 2 \cdot 10^{+16}:\\
\;\;\;\;-\frac{1}{t\_0} \cdot \log t\_4\\
\mathbf{else}:\\
\;\;\;\;-\left(t\_2 + \left(-\log t\_1\right)\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f))))) < 2e16Initial program 58.7%
if 2e16 < (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f))))) Initial program 3.1%
Taylor expanded in f around 0
Applied rewrites3.1%
Taylor expanded in f around 0
Applied rewrites14.0%
Taylor expanded in f around 0
Applied rewrites21.0%
(FPCore (f) :precision binary64 (let* ((t_0 (* (/ (PI) 4.0) f))) (- (+ (exp t_0) (- (log t_0))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4} \cdot f\\
-\left(e^{t\_0} + \left(-\log t\_0\right)\right)
\end{array}
\end{array}
Initial program 7.9%
Taylor expanded in f around 0
Applied rewrites3.8%
Taylor expanded in f around 0
Applied rewrites14.1%
Taylor expanded in f around 0
Applied rewrites20.7%
(FPCore (f) :precision binary64 (- (- (log (* (/ (PI) 4.0) f)))))
\begin{array}{l}
\\
-\left(-\log \left(\frac{\mathsf{PI}\left(\right)}{4} \cdot f\right)\right)
\end{array}
Initial program 7.9%
Taylor expanded in f around 0
Applied rewrites3.8%
Taylor expanded in f around 0
Applied rewrites15.0%
Taylor expanded in f around 0
Applied rewrites20.5%
(FPCore (f) :precision binary64 (- (PI)))
\begin{array}{l}
\\
-\mathsf{PI}\left(\right)
\end{array}
Initial program 7.9%
Taylor expanded in f around 0
Applied rewrites3.8%
Taylor expanded in f around 0
Applied rewrites15.0%
Taylor expanded in f around 0
Applied rewrites14.3%
(FPCore (f) :precision binary64 (PI))
\begin{array}{l}
\\
\mathsf{PI}\left(\right)
\end{array}
Initial program 7.9%
Taylor expanded in f around 0
Applied rewrites1.6%
Taylor expanded in f around 0
Applied rewrites1.6%
herbie shell --seed 2024321
(FPCore (f)
:name "VandenBroeck and Keller, Equation (20)"
:precision binary64
:pre (TRUE)
(- (* (/ 1.0 (/ (PI) 4.0)) (log (/ (+ (exp (* (/ (PI) 4.0) f)) (exp (- (* (/ (PI) 4.0) f)))) (- (exp (* (/ (PI) 4.0) f)) (exp (- (* (/ (PI) 4.0) f)))))))))