VandenBroeck and Keller, Equation (6)

Percentage Accurate: 76.4% → 99.2%
Time: 6.5s
Alternatives: 8
Speedup: 4.4×

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 8 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.4% 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.2% 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 := {\mathsf{PI}\left(\right)}^{-1} + \mathsf{PI}\left(\right)\\ t_1 := \mathsf{PI}\left(\right) \cdot l\_m\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;l\_m \leq 5.6 \cdot 10^{+14}:\\ \;\;\;\;t\_1 + \frac{\frac{\frac{\sin t\_1}{\cos \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), l\_m, \mathsf{PI}\left(\right)\right)\right)}}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(t\_0, l\_m, \frac{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - {\mathsf{PI}\left(\right)}^{-2}\right) \cdot l\_m}{t\_0}\right)}{2}\\ \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 (+ (pow (PI) -1.0) (PI))) (t_1 (* (PI) l_m)))
   (*
    l_s
    (if (<= l_m 5.6e+14)
      (+ t_1 (/ (/ (/ (sin t_1) (cos (fma (PI) l_m (PI)))) F) F))
      (/
       (fma t_0 l_m (/ (* (- (* (PI) (PI)) (pow (PI) -2.0)) l_m) t_0))
       2.0)))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)

\\
\begin{array}{l}
t_0 := {\mathsf{PI}\left(\right)}^{-1} + \mathsf{PI}\left(\right)\\
t_1 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 5.6 \cdot 10^{+14}:\\
\;\;\;\;t\_1 + \frac{\frac{\frac{\sin t\_1}{\cos \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), l\_m, \mathsf{PI}\left(\right)\right)\right)}}{F}}{F}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, l\_m, \frac{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - {\mathsf{PI}\left(\right)}^{-2}\right) \cdot l\_m}{t\_0}\right)}{2}\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if l < 5.6e14

    1. Initial program 84.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. 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. 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) \]
      3. associate-*l/N/A

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}}{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-/.f6490.3

        \[\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-*.f6490.3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.6e14 < l

    1. Initial program 71.2%

      \[\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. Applied rewrites99.6%

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

          \[\leadsto \frac{\mathsf{fma}\left({\mathsf{PI}\left(\right)}^{-1} + \mathsf{PI}\left(\right), \ell, \left(\mathsf{PI}\left(\right) - {\mathsf{PI}\left(\right)}^{-1}\right) \cdot \ell\right)}{\color{blue}{2}} \]
        2. Step-by-step derivation
          1. Applied rewrites99.8%

            \[\leadsto \frac{\mathsf{fma}\left({\mathsf{PI}\left(\right)}^{-1} + \mathsf{PI}\left(\right), \ell, \frac{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - {\mathsf{PI}\left(\right)}^{-2}\right) \cdot \ell}{{\mathsf{PI}\left(\right)}^{-1} + \mathsf{PI}\left(\right)}\right)}{2} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification92.3%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 5.6 \cdot 10^{+14}:\\ \;\;\;\;\mathsf{PI}\left(\right) \cdot \ell + \frac{\frac{\frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\cos \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \mathsf{PI}\left(\right)\right)\right)}}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left({\mathsf{PI}\left(\right)}^{-1} + \mathsf{PI}\left(\right), \ell, \frac{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - {\mathsf{PI}\left(\right)}^{-2}\right) \cdot \ell}{{\mathsf{PI}\left(\right)}^{-1} + \mathsf{PI}\left(\right)}\right)}{2}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 2: 99.2% 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 := \mathsf{PI}\left(\right) \cdot l\_m\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;l\_m \leq 5.6 \cdot 10^{+14}:\\ \;\;\;\;t\_0 + \frac{\frac{\frac{\sin t\_0}{\cos \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), l\_m, \mathsf{PI}\left(\right)\right)\right)}}{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 (* (PI) l_m)))
           (*
            l_s
            (if (<= l_m 5.6e+14)
              (+ t_0 (/ (/ (/ (sin t_0) (cos (fma (PI) l_m (PI)))) 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 := \mathsf{PI}\left(\right) \cdot l\_m\\
        l\_s \cdot \begin{array}{l}
        \mathbf{if}\;l\_m \leq 5.6 \cdot 10^{+14}:\\
        \;\;\;\;t\_0 + \frac{\frac{\frac{\sin t\_0}{\cos \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), l\_m, \mathsf{PI}\left(\right)\right)\right)}}{F}}{F}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if l < 5.6e14

          1. Initial program 84.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. 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. 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) \]
            3. associate-*l/N/A

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

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

              \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}}{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-/.f6490.3

              \[\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-*.f6490.3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if 5.6e14 < l

          1. Initial program 71.2%

            \[\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. Applied rewrites99.6%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 5.6 \cdot 10^{+14}:\\ \;\;\;\;\mathsf{PI}\left(\right) \cdot \ell + \frac{\frac{\frac{\sin \left(\mathsf{PI}\left(\right) \cdot \ell\right)}{\cos \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), \ell, \mathsf{PI}\left(\right)\right)\right)}}{F}}{F}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{PI}\left(\right) \cdot \ell\\ \end{array} \]
          7. Add Preprocessing

          Alternative 3: 99.2% 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 := \mathsf{PI}\left(\right) \cdot l\_m\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;l\_m \leq 5.6 \cdot 10^{+14}:\\ \;\;\;\;t\_0 - {F}^{-1} \cdot \frac{\tan \left(l\_m \cdot \mathsf{PI}\left(\right)\right)}{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 (* (PI) l_m)))
             (*
              l_s
              (if (<= l_m 5.6e+14)
                (- t_0 (* (pow F -1.0) (/ (tan (* l_m (PI))) F)))
                t_0))))
          \begin{array}{l}
          l\_m = \left|\ell\right|
          \\
          l\_s = \mathsf{copysign}\left(1, \ell\right)
          
          \\
          \begin{array}{l}
          t_0 := \mathsf{PI}\left(\right) \cdot l\_m\\
          l\_s \cdot \begin{array}{l}
          \mathbf{if}\;l\_m \leq 5.6 \cdot 10^{+14}:\\
          \;\;\;\;t\_0 - {F}^{-1} \cdot \frac{\tan \left(l\_m \cdot \mathsf{PI}\left(\right)\right)}{F}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if l < 5.6e14

            1. Initial program 84.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. 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. 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) \]
              3. associate-*l/N/A

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - {F}^{-1} \cdot \frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F} \]
              12. lower-*.f6490.3

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

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

            if 5.6e14 < l

            1. Initial program 71.2%

              \[\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. Applied rewrites99.6%

                \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
            5. Recombined 2 regimes into one program.
            6. Add Preprocessing

            Alternative 4: 84.0% accurate, 0.8× speedup?

            \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \cdot l\_m\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0 \leq -4 \cdot 10^{-221}:\\ \;\;\;\;\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 (* (PI) l_m)))
               (*
                l_s
                (if (<= (- t_0 (* (/ 1.0 (* F F)) (tan t_0))) -4e-221)
                  (/ (* (- (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 := \mathsf{PI}\left(\right) \cdot l\_m\\
            l\_s \cdot \begin{array}{l}
            \mathbf{if}\;t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0 \leq -4 \cdot 10^{-221}:\\
            \;\;\;\;\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)))) < -4.00000000000000007e-221

              1. Initial program 78.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. 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) \]
                3. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \color{blue}{{F}^{-1} \cdot \frac{\tan \left(\ell \cdot \mathsf{PI}\left(\right)\right)}{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. Applied rewrites68.7%

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

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

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

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

                  if -4.00000000000000007e-221 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l))))

                  1. Initial program 83.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. Applied rewrites77.3%

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

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

                  Alternative 5: 99.2% 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 := \mathsf{PI}\left(\right) \cdot l\_m\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;l\_m \leq 5.6 \cdot 10^{+14}:\\ \;\;\;\;t\_0 - \frac{\frac{\tan \left(l\_m \cdot \mathsf{PI}\left(\right)\right)}{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 (* (PI) l_m)))
                     (* l_s (if (<= l_m 5.6e+14) (- t_0 (/ (/ (tan (* l_m (PI))) 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 := \mathsf{PI}\left(\right) \cdot l\_m\\
                  l\_s \cdot \begin{array}{l}
                  \mathbf{if}\;l\_m \leq 5.6 \cdot 10^{+14}:\\
                  \;\;\;\;t\_0 - \frac{\frac{\tan \left(l\_m \cdot \mathsf{PI}\left(\right)\right)}{F}}{F}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if l < 5.6e14

                    1. Initial program 84.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. 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. 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) \]
                      3. associate-*l/N/A

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

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

                        \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - \frac{\color{blue}{\tan \left(\mathsf{PI}\left(\right) \cdot \ell\right)}}{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-/.f6490.3

                        \[\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-*.f6490.3

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

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

                    if 5.6e14 < l

                    1. Initial program 71.2%

                      \[\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. Applied rewrites99.6%

                        \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
                    5. Recombined 2 regimes into one program.
                    6. Add Preprocessing

                    Alternative 6: 98.3% accurate, 3.2× speedup?

                    \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \cdot l\_m\\ l\_s \cdot \begin{array}{l} \mathbf{if}\;l\_m \leq 30000000000000:\\ \;\;\;\;t\_0 - \frac{l\_m}{F} \cdot \frac{\mathsf{PI}\left(\right)}{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 (* (PI) l_m)))
                       (*
                        l_s
                        (if (<= l_m 30000000000000.0) (- t_0 (* (/ l_m F) (/ (PI) F))) t_0))))
                    \begin{array}{l}
                    l\_m = \left|\ell\right|
                    \\
                    l\_s = \mathsf{copysign}\left(1, \ell\right)
                    
                    \\
                    \begin{array}{l}
                    t_0 := \mathsf{PI}\left(\right) \cdot l\_m\\
                    l\_s \cdot \begin{array}{l}
                    \mathbf{if}\;l\_m \leq 30000000000000:\\
                    \;\;\;\;t\_0 - \frac{l\_m}{F} \cdot \frac{\mathsf{PI}\left(\right)}{F}\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;t\_0\\
                    
                    
                    \end{array}
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if l < 3e13

                      1. Initial program 84.2%

                        \[\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. 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) \]
                        3. associate-*l/N/A

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

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

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

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

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

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

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

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

                          \[\leadsto \mathsf{PI}\left(\right) \cdot \ell - {F}^{-1} \cdot \frac{\tan \color{blue}{\left(\ell \cdot \mathsf{PI}\left(\right)\right)}}{F} \]
                        12. lower-*.f6490.2

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

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

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

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

                        if 3e13 < l

                        1. Initial program 71.7%

                          \[\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. Applied rewrites98.0%

                            \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
                        5. Recombined 2 regimes into one program.
                        6. Add Preprocessing

                        Alternative 7: 92.7% accurate, 4.4× speedup?

                        \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \begin{array}{l} \mathbf{if}\;l\_m \leq 30000000000000:\\ \;\;\;\;\left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F \cdot F}\right) \cdot l\_m\\ \mathbf{else}:\\ \;\;\;\;\mathsf{PI}\left(\right) \cdot l\_m\\ \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
                         (*
                          l_s
                          (if (<= l_m 30000000000000.0)
                            (* (- (PI) (/ (PI) (* F F))) l_m)
                            (* (PI) l_m))))
                        \begin{array}{l}
                        l\_m = \left|\ell\right|
                        \\
                        l\_s = \mathsf{copysign}\left(1, \ell\right)
                        
                        \\
                        l\_s \cdot \begin{array}{l}
                        \mathbf{if}\;l\_m \leq 30000000000000:\\
                        \;\;\;\;\left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F \cdot F}\right) \cdot l\_m\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\mathsf{PI}\left(\right) \cdot l\_m\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if l < 3e13

                          1. Initial program 84.2%

                            \[\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. Applied rewrites78.1%

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

                            if 3e13 < l

                            1. Initial program 71.7%

                              \[\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. Applied rewrites98.0%

                                \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \ell} \]
                            5. Recombined 2 regimes into one program.
                            6. Add Preprocessing

                            Alternative 8: 74.1% accurate, 22.5× speedup?

                            \[\begin{array}{l} l\_m = \left|\ell\right| \\ l\_s = \mathsf{copysign}\left(1, \ell\right) \\ l\_s \cdot \left(\mathsf{PI}\left(\right) \cdot l\_m\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 (* (PI) l_m)))
                            \begin{array}{l}
                            l\_m = \left|\ell\right|
                            \\
                            l\_s = \mathsf{copysign}\left(1, \ell\right)
                            
                            \\
                            l\_s \cdot \left(\mathsf{PI}\left(\right) \cdot l\_m\right)
                            \end{array}
                            
                            Derivation
                            1. Initial program 81.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 F around inf

                              \[\leadsto \color{blue}{\ell \cdot \mathsf{PI}\left(\right)} \]
                            4. Step-by-step derivation
                              1. Applied rewrites73.5%

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

                              Reproduce

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