VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.9% → 82.7%
Time: 9.9s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \cdot \ell\\ t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0 \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (let* ((t_0 (* (PI) l))) (- t_0 (* (/ 1.0 (* F F)) (tan t_0)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \ell\\
t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0
\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 7 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: 76.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \cdot \ell\\ t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0 \end{array} \end{array} \]
(FPCore (F l)
 :precision binary64
 (let* ((t_0 (* (PI) l))) (- t_0 (* (/ 1.0 (* F F)) (tan t_0)))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \ell\\
t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0
\end{array}
\end{array}

Alternative 1: 82.7% accurate, 1.0× speedup?

\[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 10^{-13}:\\ \;\;\;\;t\_0 - \frac{l\_m}{F} \cdot \frac{\mathsf{PI}\left(\right)}{F}\\ \mathbf{else}:\\ \;\;\;\;t\_0 - \frac{\tan t\_0}{F \cdot F}\\ \end{array} \end{array} \end{array} \]
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
 :precision binary64
 (let* ((t_0 (* l_m (PI))))
   (*
    l_s
    (if (<= t_0 1e-13)
      (- t_0 (* (/ l_m F) (/ (PI) F)))
      (- t_0 (/ (tan t_0) (* F F)))))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
\begin{array}{l}
t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 10^{-13}:\\
\;\;\;\;t\_0 - \frac{l\_m}{F} \cdot \frac{\mathsf{PI}\left(\right)}{F}\\

\mathbf{else}:\\
\;\;\;\;t\_0 - \frac{\tan t\_0}{F \cdot F}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (PI.f64) l) < 1e-13

    1. Initial program 77.9%

      \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
    2. Add Preprocessing
    3. Taylor expanded in l around 0

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \ell}}{{F}^{2}} \]
      2. associate-*l/N/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}} \cdot \ell} \]
      3. lower-*.f64N/A

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}}} \cdot \ell \]
      5. lower-PI.f64N/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}} \cdot \ell \]
      6. unpow2N/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
      7. lower-*.f6474.8

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
    5. Applied rewrites74.8%

      \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell} \]
    6. Step-by-step derivation
      1. Applied rewrites83.9%

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{F} \cdot \color{blue}{\frac{\ell}{F}} \]

      if 1e-13 < (*.f64 (PI.f64) l)

      1. Initial program 67.9%

        \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-*.f64N/A

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
        3. lift-/.f64N/A

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F \cdot F}} \]
        5. lower-/.f6467.9

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F \cdot F}} \]
        6. lift-*.f64N/A

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\tan \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \ell\right)}}{F \cdot F} \]
        7. *-commutativeN/A

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F \cdot F} \]
        8. lower-*.f6467.9

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F \cdot F} \]
      4. Applied rewrites67.9%

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F \cdot F}} \]
    7. Recombined 2 regimes into one program.
    8. Final simplification79.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \mathsf{PI}\left(\right) \leq 10^{-13}:\\ \;\;\;\;\ell \cdot \mathsf{PI}\left(\right) - \frac{\ell}{F} \cdot \frac{\mathsf{PI}\left(\right)}{F}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \mathsf{PI}\left(\right) - \frac{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F \cdot F}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 2: 82.7% accurate, 0.6× speedup?

    \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\ l\_s \cdot \left(t\_0 - \frac{{F}^{-1}}{\frac{1}{\tan t\_0} \cdot F}\right) \end{array} \end{array} \]
    l\_m = (fabs.f64 l)
    l\_s = (copysign.f64 #s(literal 1 binary64) l)
    (FPCore (l_s F l_m)
     :precision binary64
     (let* ((t_0 (* l_m (PI))))
       (* l_s (- t_0 (/ (pow F -1.0) (* (/ 1.0 (tan t_0)) F))))))
    \begin{array}{l}
    l\_m = \left|\ell\right|
    \\
    l\_s = \mathsf{copysign}\left(1, \ell\right)
    
    \\
    \begin{array}{l}
    t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
    l\_s \cdot \left(t\_0 - \frac{{F}^{-1}}{\frac{1}{\tan t\_0} \cdot F}\right)
    \end{array}
    \end{array}
    
    Derivation
    1. Initial program 75.1%

      \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)} \cdot \frac{1}{F \cdot F} \]
      5. tan-quotN/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}} \cdot \frac{1}{F \cdot F} \]
      6. lift-*.f64N/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)} \cdot \frac{1}{\color{blue}{F \cdot F}} \]
      7. associate-/r*N/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)} \cdot \color{blue}{\frac{\frac{1}{F}}{F}} \]
      8. clear-numN/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{1}{\frac{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}}} \cdot \frac{\frac{1}{F}}{F} \]
      9. frac-2negN/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{1}{\frac{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}} \cdot \color{blue}{\frac{\mathsf{neg}\left(\frac{1}{F}\right)}{\mathsf{neg}\left(F\right)}} \]
      10. frac-timesN/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{1 \cdot \left(\mathsf{neg}\left(\frac{1}{F}\right)\right)}{\frac{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)} \cdot \left(\mathsf{neg}\left(F\right)\right)}} \]
    4. Applied rewrites81.6%

      \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{{F}^{-1}}{\frac{1}{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)} \cdot F}} \]
    5. Final simplification81.6%

      \[\leadsto \ell \cdot \mathsf{PI}\left(\right) - \frac{{F}^{-1}}{\frac{1}{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)} \cdot F} \]
    6. Add Preprocessing

    Alternative 3: 82.7% accurate, 1.0× speedup?

    \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\ l\_s \cdot \left(t\_0 - \frac{\frac{\tan t\_0}{F}}{F}\right) \end{array} \end{array} \]
    l\_m = (fabs.f64 l)
    l\_s = (copysign.f64 #s(literal 1 binary64) l)
    (FPCore (l_s F l_m)
     :precision binary64
     (let* ((t_0 (* l_m (PI)))) (* l_s (- t_0 (/ (/ (tan t_0) F) F)))))
    \begin{array}{l}
    l\_m = \left|\ell\right|
    \\
    l\_s = \mathsf{copysign}\left(1, \ell\right)
    
    \\
    \begin{array}{l}
    t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
    l\_s \cdot \left(t\_0 - \frac{\frac{\tan t\_0}{F}}{F}\right)
    \end{array}
    \end{array}
    
    Derivation
    1. Initial program 75.1%

      \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot \frac{1}{F \cdot F}} \]
      3. lift-/.f64N/A

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F \cdot F}} \]
      5. lift-*.f64N/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\color{blue}{F \cdot F}} \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}{F}} \]
      7. lower-/.f64N/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}{F}} \]
      8. lower-/.f6481.6

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\frac{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}}{F} \]
      9. lift-*.f64N/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\tan \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \ell\right)}}{F}}{F} \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F}}{F} \]
      11. lower-*.f6481.6

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F}}{F} \]
    4. Applied rewrites81.6%

      \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{F}} \]
    5. Final simplification81.6%

      \[\leadsto \ell \cdot \mathsf{PI}\left(\right) - \frac{\frac{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{F} \]
    6. Add Preprocessing

    Alternative 4: 76.0% accurate, 2.9× speedup?

    \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 5 \cdot 10^{-10}:\\ \;\;\;\;t\_0 - \frac{l\_m}{F} \cdot \frac{\mathsf{PI}\left(\right)}{F}\\ \mathbf{else}:\\ \;\;\;\;t\_0 - \left(-l\_m\right) \cdot \frac{\mathsf{PI}\left(\right)}{F \cdot F}\\ \end{array} \end{array} \end{array} \]
    l\_m = (fabs.f64 l)
    l\_s = (copysign.f64 #s(literal 1 binary64) l)
    (FPCore (l_s F l_m)
     :precision binary64
     (let* ((t_0 (* l_m (PI))))
       (*
        l_s
        (if (<= t_0 5e-10)
          (- t_0 (* (/ l_m F) (/ (PI) F)))
          (- t_0 (* (- l_m) (/ (PI) (* F F))))))))
    \begin{array}{l}
    l\_m = \left|\ell\right|
    \\
    l\_s = \mathsf{copysign}\left(1, \ell\right)
    
    \\
    \begin{array}{l}
    t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
    l\_s \cdot \begin{array}{l}
    \mathbf{if}\;t\_0 \leq 5 \cdot 10^{-10}:\\
    \;\;\;\;t\_0 - \frac{l\_m}{F} \cdot \frac{\mathsf{PI}\left(\right)}{F}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0 - \left(-l\_m\right) \cdot \frac{\mathsf{PI}\left(\right)}{F \cdot F}\\
    
    
    \end{array}
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 (PI.f64) l) < 5.00000000000000031e-10

      1. Initial program 78.3%

        \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
      2. Add Preprocessing
      3. Taylor expanded in l around 0

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \ell}}{{F}^{2}} \]
        2. associate-*l/N/A

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}} \cdot \ell} \]
        3. lower-*.f64N/A

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}}} \cdot \ell \]
        5. lower-PI.f64N/A

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}} \cdot \ell \]
        6. unpow2N/A

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
        7. lower-*.f6475.2

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
      5. Applied rewrites75.2%

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell} \]
      6. Step-by-step derivation
        1. Applied rewrites84.1%

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{F} \cdot \color{blue}{\frac{\ell}{F}} \]

        if 5.00000000000000031e-10 < (*.f64 (PI.f64) l)

        1. Initial program 66.5%

          \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
        2. Add Preprocessing
        3. Taylor expanded in l around 0

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \ell}}{{F}^{2}} \]
          2. associate-*l/N/A

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}} \cdot \ell} \]
          3. lower-*.f64N/A

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}}} \cdot \ell \]
          5. lower-PI.f64N/A

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}} \cdot \ell \]
          6. unpow2N/A

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
          7. lower-*.f6446.5

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
        5. Applied rewrites46.5%

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell} \]
        6. Step-by-step derivation
          1. Applied rewrites51.0%

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{-\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell \]
        7. Recombined 2 regimes into one program.
        8. Final simplification75.1%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \mathsf{PI}\left(\right) \leq 5 \cdot 10^{-10}:\\ \;\;\;\;\ell \cdot \mathsf{PI}\left(\right) - \frac{\ell}{F} \cdot \frac{\mathsf{PI}\left(\right)}{F}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \mathsf{PI}\left(\right) - \left(-\ell\right) \cdot \frac{\mathsf{PI}\left(\right)}{F \cdot F}\\ \end{array} \]
        9. Add Preprocessing

        Alternative 5: 70.5% accurate, 3.1× speedup?

        \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 \leq 5 \cdot 10^{-10}:\\ \;\;\;\;t\_0 - \frac{t\_0}{F \cdot F}\\ \mathbf{else}:\\ \;\;\;\;t\_0 - \left(-l\_m\right) \cdot \frac{\mathsf{PI}\left(\right)}{F \cdot F}\\ \end{array} \end{array} \end{array} \]
        l\_m = (fabs.f64 l)
        l\_s = (copysign.f64 #s(literal 1 binary64) l)
        (FPCore (l_s F l_m)
         :precision binary64
         (let* ((t_0 (* l_m (PI))))
           (*
            l_s
            (if (<= t_0 5e-10)
              (- t_0 (/ t_0 (* F F)))
              (- t_0 (* (- l_m) (/ (PI) (* F F))))))))
        \begin{array}{l}
        l\_m = \left|\ell\right|
        \\
        l\_s = \mathsf{copysign}\left(1, \ell\right)
        
        \\
        \begin{array}{l}
        t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
        l\_s \cdot \begin{array}{l}
        \mathbf{if}\;t\_0 \leq 5 \cdot 10^{-10}:\\
        \;\;\;\;t\_0 - \frac{t\_0}{F \cdot F}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0 - \left(-l\_m\right) \cdot \frac{\mathsf{PI}\left(\right)}{F \cdot F}\\
        
        
        \end{array}
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 (PI.f64) l) < 5.00000000000000031e-10

          1. Initial program 78.3%

            \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
          2. Add Preprocessing
          3. Taylor expanded in l around 0

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

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \ell}}{{F}^{2}} \]
            2. associate-*l/N/A

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}} \cdot \ell} \]
            3. lower-*.f64N/A

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

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}}} \cdot \ell \]
            5. lower-PI.f64N/A

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}} \cdot \ell \]
            6. unpow2N/A

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
            7. lower-*.f6475.2

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
          5. Applied rewrites75.2%

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell} \]
          6. Step-by-step derivation
            1. Applied rewrites75.7%

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\ell \cdot \mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \]

            if 5.00000000000000031e-10 < (*.f64 (PI.f64) l)

            1. Initial program 66.5%

              \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
            2. Add Preprocessing
            3. Taylor expanded in l around 0

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

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \ell}}{{F}^{2}} \]
              2. associate-*l/N/A

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}} \cdot \ell} \]
              3. lower-*.f64N/A

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

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}}} \cdot \ell \]
              5. lower-PI.f64N/A

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}} \cdot \ell \]
              6. unpow2N/A

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
              7. lower-*.f6446.5

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
            5. Applied rewrites46.5%

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell} \]
            6. Step-by-step derivation
              1. Applied rewrites51.0%

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{-\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell \]
            7. Recombined 2 regimes into one program.
            8. Final simplification68.9%

              \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \cdot \mathsf{PI}\left(\right) \leq 5 \cdot 10^{-10}:\\ \;\;\;\;\ell \cdot \mathsf{PI}\left(\right) - \frac{\ell \cdot \mathsf{PI}\left(\right)}{F \cdot F}\\ \mathbf{else}:\\ \;\;\;\;\ell \cdot \mathsf{PI}\left(\right) - \left(-\ell\right) \cdot \frac{\mathsf{PI}\left(\right)}{F \cdot F}\\ \end{array} \]
            9. Add Preprocessing

            Alternative 6: 69.7% accurate, 4.5× speedup?

            \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\ l\_s \cdot \left(t\_0 - \frac{t\_0}{F \cdot F}\right) \end{array} \end{array} \]
            l\_m = (fabs.f64 l)
            l\_s = (copysign.f64 #s(literal 1 binary64) l)
            (FPCore (l_s F l_m)
             :precision binary64
             (let* ((t_0 (* l_m (PI)))) (* l_s (- t_0 (/ t_0 (* F F))))))
            \begin{array}{l}
            l\_m = \left|\ell\right|
            \\
            l\_s = \mathsf{copysign}\left(1, \ell\right)
            
            \\
            \begin{array}{l}
            t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
            l\_s \cdot \left(t\_0 - \frac{t\_0}{F \cdot F}\right)
            \end{array}
            \end{array}
            
            Derivation
            1. Initial program 75.1%

              \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
            2. Add Preprocessing
            3. Taylor expanded in l around 0

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

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \ell}}{{F}^{2}} \]
              2. associate-*l/N/A

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}} \cdot \ell} \]
              3. lower-*.f64N/A

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

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}}} \cdot \ell \]
              5. lower-PI.f64N/A

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}} \cdot \ell \]
              6. unpow2N/A

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
              7. lower-*.f6467.4

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
            5. Applied rewrites67.4%

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell} \]
            6. Step-by-step derivation
              1. Applied rewrites67.7%

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\ell \cdot \mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \]
              2. Final simplification67.7%

                \[\leadsto \ell \cdot \mathsf{PI}\left(\right) - \frac{\ell \cdot \mathsf{PI}\left(\right)}{F \cdot F} \]
              3. Add Preprocessing

              Alternative 7: 69.7% accurate, 4.5× speedup?

              \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \left(l\_m \cdot \mathsf{PI}\left(\right) - \frac{l\_m}{F \cdot F} \cdot \mathsf{PI}\left(\right)\right) \end{array} \]
              l\_m = (fabs.f64 l)
              l\_s = (copysign.f64 #s(literal 1 binary64) l)
              (FPCore (l_s F l_m)
               :precision binary64
               (* l_s (- (* l_m (PI)) (* (/ l_m (* F F)) (PI)))))
              \begin{array}{l}
              l\_m = \left|\ell\right|
              \\
              l\_s = \mathsf{copysign}\left(1, \ell\right)
              
              \\
              l\_s \cdot \left(l\_m \cdot \mathsf{PI}\left(\right) - \frac{l\_m}{F \cdot F} \cdot \mathsf{PI}\left(\right)\right)
              \end{array}
              
              Derivation
              1. Initial program 75.1%

                \[\mathsf{PI}\left(\right) \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\mathsf{PI}\left(\right) \cdot \ell\right) \]
              2. Add Preprocessing
              3. Taylor expanded in l around 0

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

                  \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot \ell}}{{F}^{2}} \]
                2. associate-*l/N/A

                  \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}} \cdot \ell} \]
                3. lower-*.f64N/A

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

                  \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{{F}^{2}}} \cdot \ell \]
                5. lower-PI.f64N/A

                  \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\mathsf{PI}\left(\right)}}{{F}^{2}} \cdot \ell \]
                6. unpow2N/A

                  \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
                7. lower-*.f6467.4

                  \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\mathsf{PI}\left(\right)}{\color{blue}{F \cdot F}} \cdot \ell \]
              5. Applied rewrites67.4%

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell} \]
              6. Step-by-step derivation
                1. Applied rewrites49.7%

                  \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{-\mathsf{PI}\left(\right)}{F \cdot F} \cdot \ell \]
                2. Step-by-step derivation
                  1. Applied rewrites67.7%

                    \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \mathsf{PI}\left(\right) \cdot \color{blue}{\frac{\ell}{F \cdot F}} \]
                  2. Final simplification67.7%

                    \[\leadsto \ell \cdot \mathsf{PI}\left(\right) - \frac{\ell}{F \cdot F} \cdot \mathsf{PI}\left(\right) \]
                  3. Add Preprocessing

                  Reproduce

                  ?
                  herbie shell --seed 2024312 
                  (FPCore (F l)
                    :name "VandenBroeck and Keller, Equation (6)"
                    :precision binary64
                    (- (* (PI) l) (* (/ 1.0 (* F F)) (tan (* (PI) l)))))