VandenBroeck and Keller, Equation (20)

Percentage Accurate: 7.2% → 99.1%
Time: 15.4s
Alternatives: 6
Speedup: 4.8×

Specification

?
\[\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))))
   (- (* (/ 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:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 7.2% accurate, 1.0× speedup?

\[\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))))
   (- (* (/ 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}

Alternative 1: 99.1% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.25 \cdot \mathsf{PI}\left(\right)\\ \frac{\log \tanh \left(f \cdot t\_0\right)}{t\_0} \end{array} \end{array} \]
(FPCore (f)
 :precision binary64
 (let* ((t_0 (* 0.25 (PI)))) (/ (log (tanh (* f t_0))) t_0)))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.25 \cdot \mathsf{PI}\left(\right)\\
\frac{\log \tanh \left(f \cdot t\_0\right)}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 7.4%

    \[-\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)}\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \cdot \frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
    4. lift-/.f64N/A

      \[\leadsto \mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \cdot \color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
    5. un-div-invN/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
  4. Applied rewrites98.3%

    \[\leadsto \color{blue}{\frac{\log \tanh \left(f \cdot \left(0.25 \cdot \mathsf{PI}\left(\right)\right)\right)}{0.25 \cdot \mathsf{PI}\left(\right)}} \]
  5. Add Preprocessing

Alternative 2: 98.9% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \frac{4}{\mathsf{PI}\left(\right)} \cdot \log \tanh \left(f \cdot \left(0.25 \cdot \mathsf{PI}\left(\right)\right)\right) \end{array} \]
(FPCore (f)
 :precision binary64
 (* (/ 4.0 (PI)) (log (tanh (* f (* 0.25 (PI)))))))
\begin{array}{l}

\\
\frac{4}{\mathsf{PI}\left(\right)} \cdot \log \tanh \left(f \cdot \left(0.25 \cdot \mathsf{PI}\left(\right)\right)\right)
\end{array}
Derivation
  1. Initial program 7.4%

    \[-\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)}\right) \]
    3. distribute-rgt-neg-inN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \left(\mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)\right)\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \left(\mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)\right)\right)} \]
  4. Applied rewrites98.2%

    \[\leadsto \color{blue}{\frac{4}{\mathsf{PI}\left(\right)} \cdot \log \tanh \left(f \cdot \left(0.25 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
  5. Add Preprocessing

Alternative 3: 96.4% accurate, 3.5× speedup?

\[\begin{array}{l} \\ \frac{-1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.010416666666666666, \mathsf{PI}\left(\right) \cdot 4, 0.125 \cdot \mathsf{PI}\left(\right)\right) \cdot f, f, \frac{4}{\mathsf{PI}\left(\right)}\right)}{f}\right) \end{array} \]
(FPCore (f)
 :precision binary64
 (*
  (/ -1.0 (/ (PI) 4.0))
  (log
   (/
    (fma
     (* (fma -0.010416666666666666 (* (PI) 4.0) (* 0.125 (PI))) f)
     f
     (/ 4.0 (PI)))
    f))))
\begin{array}{l}

\\
\frac{-1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.010416666666666666, \mathsf{PI}\left(\right) \cdot 4, 0.125 \cdot \mathsf{PI}\left(\right)\right) \cdot f, f, \frac{4}{\mathsf{PI}\left(\right)}\right)}{f}\right)
\end{array}
Derivation
  1. Initial program 7.4%

    \[-\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in f around 0

    \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \color{blue}{\left(\frac{2}{f \cdot \left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}\right)} \]
  4. Step-by-step derivation
    1. associate-/l/N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \color{blue}{\left(\frac{\frac{2}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}}{f}\right)} \]
    2. metadata-evalN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\frac{\color{blue}{2 \cdot 1}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}}{f}\right) \]
    3. associate-*r/N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\color{blue}{2 \cdot \frac{1}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}}}{f}\right) \]
    4. lower-/.f64N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \color{blue}{\left(\frac{2 \cdot \frac{1}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}}{f}\right)} \]
    5. associate-*r/N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\color{blue}{\frac{2 \cdot 1}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}}}{f}\right) \]
    6. metadata-evalN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\frac{\color{blue}{2}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}}{f}\right) \]
    7. distribute-rgt-out--N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\frac{2}{\color{blue}{\mathsf{PI}\left(\right) \cdot \left(\frac{1}{4} - \frac{-1}{4}\right)}}}{f}\right) \]
    8. metadata-evalN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\frac{2}{\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{1}{2}}}}{f}\right) \]
    9. *-commutativeN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\frac{2}{\color{blue}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}}}{f}\right) \]
    10. associate-/r*N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\color{blue}{\frac{\frac{2}{\frac{1}{2}}}{\mathsf{PI}\left(\right)}}}{f}\right) \]
    11. metadata-evalN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\frac{\color{blue}{4}}{\mathsf{PI}\left(\right)}}{f}\right) \]
    12. lower-/.f64N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\color{blue}{\frac{4}{\mathsf{PI}\left(\right)}}}{f}\right) \]
    13. lower-PI.f6494.0

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\frac{4}{\color{blue}{\mathsf{PI}\left(\right)}}}{f}\right) \]
  5. Applied rewrites94.0%

    \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \color{blue}{\left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right)} \]
  6. Step-by-step derivation
    1. *-lft-identityN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \color{blue}{\left(1 \cdot \log \left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right)\right)} \]
    2. *-commutativeN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \color{blue}{\left(\log \left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right) \cdot 1\right)} \]
    3. metadata-evalN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \left(\log \left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right) \cdot \color{blue}{\frac{1}{1}}\right) \]
    4. div-invN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \color{blue}{\frac{\log \left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right)}{1}} \]
    5. clear-numN/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \color{blue}{\frac{1}{\frac{1}{\log \left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right)}}} \]
    6. lower-/.f64N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \color{blue}{\frac{1}{\frac{1}{\log \left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right)}}} \]
  7. Applied rewrites93.9%

    \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \color{blue}{\frac{1}{\frac{1}{\log \left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right)}}} \]
  8. Taylor expanded in f around 0

    \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \frac{1}{\frac{1}{\log \color{blue}{\left(\frac{f \cdot \left(\frac{-1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} + \left(\frac{1}{4} \cdot \frac{\mathsf{PI}\left(\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} + f \cdot \left(\frac{1}{16} \cdot \frac{{\mathsf{PI}\left(\right)}^{2}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)} - 2 \cdot \frac{\frac{1}{384} \cdot {\mathsf{PI}\left(\right)}^{3} - \frac{-1}{384} \cdot {\mathsf{PI}\left(\right)}^{3}}{{\left(\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)\right)}^{2}}\right)\right)\right) + 2 \cdot \frac{1}{\frac{1}{4} \cdot \mathsf{PI}\left(\right) - \frac{-1}{4} \cdot \mathsf{PI}\left(\right)}}{f}\right)}}} \]
  9. Applied rewrites94.7%

    \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \frac{1}{\frac{1}{\log \color{blue}{\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.005208333333333333 \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot 2\right), -2, \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot 0.0625\right) \cdot f, f, \frac{2}{0.5 \cdot \mathsf{PI}\left(\right)}\right)}{f}\right)}}} \]
  10. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \color{blue}{\frac{1}{\frac{1}{\log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{192} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot 2\right), -2, \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot \frac{1}{16}\right) \cdot f, f, \frac{2}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}\right)}{f}\right)}}} \]
    2. lift-/.f64N/A

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \frac{1}{\color{blue}{\frac{1}{\log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(\frac{1}{192} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot 2\right), -2, \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot \frac{1}{16}\right) \cdot f, f, \frac{2}{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}\right)}{f}\right)}}} \]
    3. remove-double-div94.8

      \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \color{blue}{\log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.005208333333333333 \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot 2\right), -2, \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot 0.0625\right) \cdot f, f, \frac{2}{0.5 \cdot \mathsf{PI}\left(\right)}\right)}{f}\right)} \]
  11. Applied rewrites94.8%

    \[\leadsto -\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \color{blue}{\log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.010416666666666666, \mathsf{PI}\left(\right) \cdot 4, 0.125 \cdot \mathsf{PI}\left(\right)\right) \cdot f, f, \frac{4}{\mathsf{PI}\left(\right)}\right)}{f}\right)} \]
  12. Final simplification94.8%

    \[\leadsto \frac{-1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.010416666666666666, \mathsf{PI}\left(\right) \cdot 4, 0.125 \cdot \mathsf{PI}\left(\right)\right) \cdot f, f, \frac{4}{\mathsf{PI}\left(\right)}\right)}{f}\right) \]
  13. Add Preprocessing

Alternative 4: 95.9% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\mathsf{PI}\left(\right)}\\ \frac{\log \left(\left(\left(t\_0 \cdot t\_0\right) \cdot f\right) \cdot 0.25\right)}{0.25 \cdot \mathsf{PI}\left(\right)} \end{array} \end{array} \]
(FPCore (f)
 :precision binary64
 (let* ((t_0 (sqrt (PI)))) (/ (log (* (* (* t_0 t_0) f) 0.25)) (* 0.25 (PI)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\frac{\log \left(\left(\left(t\_0 \cdot t\_0\right) \cdot f\right) \cdot 0.25\right)}{0.25 \cdot \mathsf{PI}\left(\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 7.4%

    \[-\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-neg.f64N/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)}\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \cdot \frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
    4. lift-/.f64N/A

      \[\leadsto \mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \cdot \color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
    5. un-div-invN/A

      \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
  4. Applied rewrites98.3%

    \[\leadsto \color{blue}{\frac{\log \tanh \left(f \cdot \left(0.25 \cdot \mathsf{PI}\left(\right)\right)\right)}{0.25 \cdot \mathsf{PI}\left(\right)}} \]
  5. Taylor expanded in f around 0

    \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{4} \cdot \left(f \cdot \mathsf{PI}\left(\right)\right)\right)}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \frac{\log \color{blue}{\left(\left(f \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{4}\right)}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{\log \color{blue}{\left(\left(f \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{4}\right)}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\log \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot f\right)} \cdot \frac{1}{4}\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{\log \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot f\right)} \cdot \frac{1}{4}\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
    5. lower-PI.f6494.1

      \[\leadsto \frac{\log \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot f\right) \cdot 0.25\right)}{0.25 \cdot \mathsf{PI}\left(\right)} \]
  7. Applied rewrites94.1%

    \[\leadsto \frac{\log \color{blue}{\left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot 0.25\right)}}{0.25 \cdot \mathsf{PI}\left(\right)} \]
  8. Step-by-step derivation
    1. Applied rewrites94.1%

      \[\leadsto \frac{\log \left(\left(\left(\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}\right) \cdot f\right) \cdot 0.25\right)}{0.25 \cdot \mathsf{PI}\left(\right)} \]
    2. Add Preprocessing

    Alternative 5: 95.9% accurate, 4.8× speedup?

    \[\begin{array}{l} \\ \frac{\log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot 0.25\right)}{0.25 \cdot \mathsf{PI}\left(\right)} \end{array} \]
    (FPCore (f) :precision binary64 (/ (log (* (* (PI) f) 0.25)) (* 0.25 (PI))))
    \begin{array}{l}
    
    \\
    \frac{\log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot 0.25\right)}{0.25 \cdot \mathsf{PI}\left(\right)}
    \end{array}
    
    Derivation
    1. Initial program 7.4%

      \[-\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)}\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \cdot \frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \cdot \color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
      5. un-div-invN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
    4. Applied rewrites98.3%

      \[\leadsto \color{blue}{\frac{\log \tanh \left(f \cdot \left(0.25 \cdot \mathsf{PI}\left(\right)\right)\right)}{0.25 \cdot \mathsf{PI}\left(\right)}} \]
    5. Taylor expanded in f around 0

      \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{4} \cdot \left(f \cdot \mathsf{PI}\left(\right)\right)\right)}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{\log \color{blue}{\left(\left(f \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{4}\right)}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\log \color{blue}{\left(\left(f \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{4}\right)}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\log \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot f\right)} \cdot \frac{1}{4}\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\log \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot f\right)} \cdot \frac{1}{4}\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
      5. lower-PI.f6494.1

        \[\leadsto \frac{\log \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot f\right) \cdot 0.25\right)}{0.25 \cdot \mathsf{PI}\left(\right)} \]
    7. Applied rewrites94.1%

      \[\leadsto \frac{\log \color{blue}{\left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot 0.25\right)}}{0.25 \cdot \mathsf{PI}\left(\right)} \]
    8. Add Preprocessing

    Alternative 6: 95.8% accurate, 4.8× speedup?

    \[\begin{array}{l} \\ \frac{4}{\mathsf{PI}\left(\right)} \cdot \log \left(\left(0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot f\right) \end{array} \]
    (FPCore (f) :precision binary64 (* (/ 4.0 (PI)) (log (* (* 0.25 (PI)) f))))
    \begin{array}{l}
    
    \\
    \frac{4}{\mathsf{PI}\left(\right)} \cdot \log \left(\left(0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot f\right)
    \end{array}
    
    Derivation
    1. Initial program 7.4%

      \[-\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)}\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \cdot \frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
      4. lift-/.f64N/A

        \[\leadsto \mathsf{neg}\left(\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right) \cdot \color{blue}{\frac{1}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
      5. un-div-invN/A

        \[\leadsto \mathsf{neg}\left(\color{blue}{\frac{\log \left(\frac{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} + e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}{e^{\frac{\mathsf{PI}\left(\right)}{4} \cdot f} - e^{-\frac{\mathsf{PI}\left(\right)}{4} \cdot f}}\right)}{\frac{\mathsf{PI}\left(\right)}{4}}}\right) \]
    4. Applied rewrites98.3%

      \[\leadsto \color{blue}{\frac{\log \tanh \left(f \cdot \left(0.25 \cdot \mathsf{PI}\left(\right)\right)\right)}{0.25 \cdot \mathsf{PI}\left(\right)}} \]
    5. Taylor expanded in f around 0

      \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{4} \cdot \left(f \cdot \mathsf{PI}\left(\right)\right)\right)}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \frac{\log \color{blue}{\left(\left(f \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{4}\right)}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \frac{\log \color{blue}{\left(\left(f \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{1}{4}\right)}}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\log \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot f\right)} \cdot \frac{1}{4}\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\log \left(\color{blue}{\left(\mathsf{PI}\left(\right) \cdot f\right)} \cdot \frac{1}{4}\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)} \]
      5. lower-PI.f6494.1

        \[\leadsto \frac{\log \left(\left(\color{blue}{\mathsf{PI}\left(\right)} \cdot f\right) \cdot 0.25\right)}{0.25 \cdot \mathsf{PI}\left(\right)} \]
    7. Applied rewrites94.1%

      \[\leadsto \frac{\log \color{blue}{\left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot 0.25\right)}}{0.25 \cdot \mathsf{PI}\left(\right)} \]
    8. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot \frac{1}{4}\right)}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot \frac{1}{4}\right)}{\color{blue}{\frac{1}{4} \cdot \mathsf{PI}\left(\right)}} \]
      3. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{\log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot \frac{1}{4}\right)}{\frac{1}{4}}}{\mathsf{PI}\left(\right)}} \]
      4. div-invN/A

        \[\leadsto \frac{\color{blue}{\log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot \frac{1}{4}\right) \cdot \frac{1}{\frac{1}{4}}}}{\mathsf{PI}\left(\right)} \]
      5. metadata-evalN/A

        \[\leadsto \frac{\log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot \frac{1}{4}\right) \cdot \color{blue}{4}}{\mathsf{PI}\left(\right)} \]
      6. associate-*r/N/A

        \[\leadsto \color{blue}{\log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot \frac{1}{4}\right) \cdot \frac{4}{\mathsf{PI}\left(\right)}} \]
      7. lift-/.f64N/A

        \[\leadsto \log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot \frac{1}{4}\right) \cdot \color{blue}{\frac{4}{\mathsf{PI}\left(\right)}} \]
      8. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{4}{\mathsf{PI}\left(\right)} \cdot \log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot \frac{1}{4}\right)} \]
      9. lower-*.f6494.0

        \[\leadsto \color{blue}{\frac{4}{\mathsf{PI}\left(\right)} \cdot \log \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot 0.25\right)} \]
    9. Applied rewrites94.0%

      \[\leadsto \color{blue}{\frac{4}{\mathsf{PI}\left(\right)} \cdot \log \left(\left(0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot f\right)} \]
    10. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2024320 
    (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)))))))))