
(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 8 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) 0.125)) (t_1 (tanh (* (* f 0.25) (PI))))) (* (fma t_0 (log t_1) (log (pow t_1 t_0))) (/ 4.0 (* (* (PI) (PI)) 0.25)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot 0.125\\
t_1 := \tanh \left(\left(f \cdot 0.25\right) \cdot \mathsf{PI}\left(\right)\right)\\
\mathsf{fma}\left(t\_0, \log t\_1, \log \left({t\_1}^{t\_0}\right)\right) \cdot \frac{4}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot 0.25}
\end{array}
\end{array}
Initial program 5.4%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
clear-numN/A
lower-/.f64N/A
Applied rewrites98.7%
Applied rewrites98.9%
lift-neg.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift--.f64N/A
sub0-negN/A
frac-2neg-revN/A
Applied rewrites99.1%
lift-log.f64N/A
lift-pow.f64N/A
sqr-powN/A
log-prodN/A
log-powN/A
lift-log.f64N/A
lower-fma.f64N/A
Applied rewrites99.1%
(FPCore (f) :precision binary64 (* (* 2.0 (log (pow (tanh (* (* f 0.25) (PI))) (* (PI) 0.125)))) (/ 4.0 (* (* (PI) (PI)) 0.25))))
\begin{array}{l}
\\
\left(2 \cdot \log \left({\tanh \left(\left(f \cdot 0.25\right) \cdot \mathsf{PI}\left(\right)\right)}^{\left(\mathsf{PI}\left(\right) \cdot 0.125\right)}\right)\right) \cdot \frac{4}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot 0.25}
\end{array}
Initial program 5.4%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
clear-numN/A
lower-/.f64N/A
Applied rewrites98.7%
Applied rewrites98.9%
lift-neg.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift--.f64N/A
sub0-negN/A
frac-2neg-revN/A
Applied rewrites99.1%
lift-log.f64N/A
lift-pow.f64N/A
sqr-powN/A
pow2N/A
log-powN/A
lower-*.f64N/A
lower-log.f64N/A
lower-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
Applied rewrites99.1%
(FPCore (f) :precision binary64 (let* ((t_0 (* 0.25 (PI)))) (* (log (pow (tanh (* t_0 f)) t_0)) (/ 4.0 (* (* (PI) (PI)) 0.25)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.25 \cdot \mathsf{PI}\left(\right)\\
\log \left({\tanh \left(t\_0 \cdot f\right)}^{t\_0}\right) \cdot \frac{4}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot 0.25}
\end{array}
\end{array}
Initial program 5.4%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
clear-numN/A
lower-/.f64N/A
Applied rewrites98.7%
Applied rewrites98.9%
lift-neg.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift--.f64N/A
sub0-negN/A
frac-2neg-revN/A
Applied rewrites99.1%
(FPCore (f) :precision binary64 (* (* -0.25 (PI)) (* (log (tanh (* (* f 0.25) (PI)))) (/ -16.0 (* (PI) (PI))))))
\begin{array}{l}
\\
\left(-0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\log \tanh \left(\left(f \cdot 0.25\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{-16}{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}\right)
\end{array}
Initial program 5.4%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
clear-numN/A
lower-/.f64N/A
Applied rewrites98.7%
Applied rewrites98.9%
lift-neg.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift--.f64N/A
sub0-negN/A
frac-2neg-revN/A
Applied rewrites99.1%
Applied rewrites99.0%
(FPCore (f) :precision binary64 (/ (* 4.0 (log (tanh (* f (* 0.25 (PI)))))) (PI)))
\begin{array}{l}
\\
\frac{4 \cdot \log \tanh \left(f \cdot \left(0.25 \cdot \mathsf{PI}\left(\right)\right)\right)}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 5.4%
lift-neg.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lift-/.f64N/A
lift-/.f64N/A
clear-num-revN/A
Applied rewrites99.0%
(FPCore (f) :precision binary64 (/ (* 4.0 (+ (log (* 0.25 (PI))) (log f))) (PI)))
\begin{array}{l}
\\
\frac{4 \cdot \left(\log \left(0.25 \cdot \mathsf{PI}\left(\right)\right) + \log f\right)}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 5.4%
lift-neg.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lift-/.f64N/A
lift-/.f64N/A
clear-num-revN/A
Applied rewrites99.0%
Taylor expanded in f around 0
+-commutativeN/A
lower-+.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-log.f6495.5
Applied rewrites95.5%
(FPCore (f) :precision binary64 (/ (* 4.0 (log (* (* (PI) f) 0.25))) (PI)))
\begin{array}{l}
\\
\frac{4 \cdot \log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot 0.25\right)}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 5.4%
lift-neg.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lift-/.f64N/A
lift-/.f64N/A
clear-num-revN/A
Applied rewrites99.0%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6495.4
Applied rewrites95.4%
(FPCore (f) :precision binary64 (* (log (* (* 0.25 (PI)) f)) (/ 4.0 (PI))))
\begin{array}{l}
\\
\log \left(\left(0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot f\right) \cdot \frac{4}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 5.4%
lift-neg.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lift-/.f64N/A
lift-/.f64N/A
clear-num-revN/A
Applied rewrites99.0%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6495.4
Applied rewrites95.4%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
clear-num-revN/A
lift-/.f64N/A
lift-/.f64N/A
lower-*.f6495.2
Applied rewrites95.2%
herbie shell --seed 2024305
(FPCore (f)
:name "VandenBroeck and Keller, Equation (20)"
:precision binary64
(- (* (/ 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)))))))))