VandenBroeck and Keller, Equation (6)

Percentage Accurate: 77.0% → 99.1%
Time: 7.0s
Alternatives: 7
Speedup: 3.7×

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: 77.0% 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: 99.1% accurate, 0.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 \begin{array}{l} \mathbf{if}\;t\_0 \leq 2000000000:\\ \;\;\;\;t\_0 - \frac{\frac{\sin t\_0}{F}}{\cos t\_0 \cdot F}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \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 2000000000.0)
      (- t_0 (/ (/ (sin t_0) F) (* (cos t_0) F)))
      t_0))))
\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 2000000000:\\
\;\;\;\;t\_0 - \frac{\frac{\sin t\_0}{F}}{\cos t\_0 \cdot F}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 79.0%

      \[\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-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} \]
      4. 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} \]
      5. 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 \color{blue}{\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. frac-timesN/A

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot F} \]
      11. *-lft-identityN/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{\color{blue}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot F}} \]
      19. lower-cos.f6486.9

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{\cos \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)} \cdot F} \]
      22. lower-*.f6486.9

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

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

    if 2e9 < (*.f64 (PI.f64) l)

    1. Initial program 65.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 F around inf

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

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

        \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
      3. lower-PI.f6499.7

        \[\leadsto \color{blue}{\mathsf{PI}\left(\right)} \cdot \ell \]
    5. Applied rewrites99.7%

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.2%

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

Alternative 2: 83.5% accurate, 0.4× 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)\\ t_1 := t\_0 - \tan t\_0 \cdot \frac{1}{F \cdot F}\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+176}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-255}:\\ \;\;\;\;\frac{\left(-\mathsf{PI}\left(\right)\right) \cdot l\_m}{F \cdot F}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \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))) (t_1 (- t_0 (* (tan t_0) (/ 1.0 (* F F))))))
   (*
    l_s
    (if (<= t_1 -1e+176)
      t_0
      (if (<= t_1 -2e-255) (/ (* (- (PI)) l_m) (* F F)) t_0)))))
\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)\\
t_1 := t\_0 - \tan t\_0 \cdot \frac{1}{F \cdot F}\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+176}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-255}:\\
\;\;\;\;\frac{\left(-\mathsf{PI}\left(\right)\right) \cdot l\_m}{F \cdot F}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -1e176 or -2e-255 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l))))

    1. Initial program 68.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 F around inf

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

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

        \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
      3. lower-PI.f6474.3

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

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

    if -1e176 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -2e-255

    1. Initial program 96.8%

      \[\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-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} \]
      4. 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} \]
      5. 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 \color{blue}{\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. frac-timesN/A

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot F} \]
      11. *-lft-identityN/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{\color{blue}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot F}} \]
      19. lower-cos.f6496.8

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{\cos \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)} \cdot F} \]
      22. lower-*.f6496.8

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

      \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\sin \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{\cos \left(\ell \cdot \mathsf{PI}\left(\right)\right) \cdot F}} \]
    5. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 3: 83.5% accurate, 0.4× 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)\\ t_1 := t\_0 - \tan t\_0 \cdot \frac{1}{F \cdot F}\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+176}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-255}:\\ \;\;\;\;\frac{l\_m}{F \cdot F} \cdot \left(-\mathsf{PI}\left(\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \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))) (t_1 (- t_0 (* (tan t_0) (/ 1.0 (* F F))))))
         (*
          l_s
          (if (<= t_1 -1e+176)
            t_0
            (if (<= t_1 -2e-255) (* (/ l_m (* F F)) (- (PI))) t_0)))))
      \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)\\
      t_1 := t\_0 - \tan t\_0 \cdot \frac{1}{F \cdot F}\\
      l\_s \cdot \begin{array}{l}
      \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+176}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-255}:\\
      \;\;\;\;\frac{l\_m}{F \cdot F} \cdot \left(-\mathsf{PI}\left(\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -1e176 or -2e-255 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l))))

        1. Initial program 68.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 F around inf

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

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

            \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
          3. lower-PI.f6474.3

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

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

        if -1e176 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -2e-255

        1. Initial program 96.8%

          \[\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-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} \]
          4. 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} \]
          5. 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 \color{blue}{\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. frac-timesN/A

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

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{F}}}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot F} \]
          11. *-lft-identityN/A

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

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

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

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

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

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

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{\color{blue}{\cos \left(\mathsf{PI}\left(\right) \cdot \ell\right) \cdot F}} \]
          19. lower-cos.f6496.8

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

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

            \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\frac{\sin \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{\cos \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)} \cdot F} \]
          22. lower-*.f6496.8

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

          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\sin \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{\cos \left(\ell \cdot \mathsf{PI}\left(\right)\right) \cdot F}} \]
        5. Taylor expanded in l around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 4: 99.1% accurate, 0.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 2000000000:\\ \;\;\;\;t\_0 - \frac{\frac{\tan t\_0}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \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 2000000000.0) (- t_0 (/ (/ (tan t_0) F) F)) t_0))))
          \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 2000000000:\\
          \;\;\;\;t\_0 - \frac{\frac{\tan t\_0}{F}}{F}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f64 (PI.f64) l) < 2e9

            1. Initial program 79.0%

              \[\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-/.f6486.9

                \[\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-*.f6486.9

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

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

            if 2e9 < (*.f64 (PI.f64) l)

            1. Initial program 65.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 F around inf

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

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

                \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
              3. lower-PI.f6499.7

                \[\leadsto \color{blue}{\mathsf{PI}\left(\right)} \cdot \ell \]
            5. Applied rewrites99.7%

              \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification90.2%

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

          Alternative 5: 98.6% 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 2000000000:\\ \;\;\;\;t\_0 - \frac{\frac{\mathsf{PI}\left(\right)}{F} \cdot l\_m}{F}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \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 2000000000.0) (- t_0 (/ (* (/ (PI) F) l_m) F)) t_0))))
          \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 2000000000:\\
          \;\;\;\;t\_0 - \frac{\frac{\mathsf{PI}\left(\right)}{F} \cdot l\_m}{F}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f64 (PI.f64) l) < 2e9

            1. Initial program 79.0%

              \[\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-/.f6486.9

                \[\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-*.f6486.9

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

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{\frac{\frac{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{F}}{F}} \]
            5. Taylor expanded in l around 0

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

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

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

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

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

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

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

            if 2e9 < (*.f64 (PI.f64) l)

            1. Initial program 65.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 F around inf

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

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

                \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
              3. lower-PI.f6499.7

                \[\leadsto \color{blue}{\mathsf{PI}\left(\right)} \cdot \ell \]
            5. Applied rewrites99.7%

              \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification85.0%

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

          Alternative 6: 93.0% accurate, 3.7× 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 2000000000:\\ \;\;\;\;\left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F \cdot F}\right) \cdot l\_m\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \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 2000000000.0) (* (- (PI) (/ (PI) (* F F))) l_m) t_0))))
          \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 2000000000:\\
          \;\;\;\;\left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F \cdot F}\right) \cdot l\_m\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f64 (PI.f64) l) < 2e9

            1. Initial program 79.0%

              \[\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 \color{blue}{\ell \cdot \left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{{F}^{2}}\right)} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

            if 2e9 < (*.f64 (PI.f64) l)

            1. Initial program 65.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 F around inf

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

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

                \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
              3. lower-PI.f6499.7

                \[\leadsto \color{blue}{\mathsf{PI}\left(\right)} \cdot \ell \]
            5. Applied rewrites99.7%

              \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification79.1%

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

          Alternative 7: 73.9% accurate, 22.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)\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))))
          \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)\right)
          \end{array}
          
          Derivation
          1. Initial program 75.6%

            \[\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 F around inf

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

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

              \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
            3. lower-PI.f6472.2

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

            \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
          6. Final simplification72.2%

            \[\leadsto \ell \cdot \mathsf{PI}\left(\right) \]
          7. Add Preprocessing

          Reproduce

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