NMSE Section 6.1 mentioned, B

Percentage Accurate: 78.8% → 99.6%
Time: 4.6s
Alternatives: 6
Speedup: 1.8×

Specification

?
\[\begin{array}{l} \\ \left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \end{array} \]
(FPCore (a b)
 :precision binary64
 (* (* (/ (PI) 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))
\begin{array}{l}

\\
\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 6 alternatives:

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

Initial Program: 78.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \end{array} \]
(FPCore (a b)
 :precision binary64
 (* (* (/ (PI) 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))
\begin{array}{l}

\\
\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right)
\end{array}

Alternative 1: 99.6% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{PI}\left(\right)}{2 \cdot \left(a + b\right)} \cdot \frac{1}{b \cdot a} \end{array} \]
(FPCore (a b) :precision binary64 (* (/ (PI) (* 2.0 (+ a b))) (/ 1.0 (* b a))))
\begin{array}{l}

\\
\frac{\mathsf{PI}\left(\right)}{2 \cdot \left(a + b\right)} \cdot \frac{1}{b \cdot a}
\end{array}
Derivation
  1. Initial program 76.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{PI}\left(\right)}{2} \cdot 1}{b \cdot b - a \cdot a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    7. difference-of-squaresN/A

      \[\leadsto \frac{\frac{\mathsf{PI}\left(\right)}{2} \cdot 1}{\color{blue}{\left(b + a\right) \cdot \left(b - a\right)}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    8. times-fracN/A

      \[\leadsto \color{blue}{\left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \frac{1}{b - a}\right)} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    9. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \frac{1}{b - a}\right)} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    10. lower-/.f64N/A

      \[\leadsto \left(\color{blue}{\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a}} \cdot \frac{1}{b - a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    11. lower-+.f64N/A

      \[\leadsto \left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{\color{blue}{b + a}} \cdot \frac{1}{b - a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    12. lower-/.f64N/A

      \[\leadsto \left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \color{blue}{\frac{1}{b - a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    13. lower--.f6485.9

      \[\leadsto \left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \frac{1}{\color{blue}{b - a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
  4. Applied rewrites85.9%

    \[\leadsto \color{blue}{\left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \frac{1}{b - a}\right)} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \color{blue}{\left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \frac{1}{b - a}\right)} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    3. lift-+.f64N/A

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

      \[\leadsto \left(\color{blue}{\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a}} \cdot \frac{1}{b - a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    5. lift-PI.f64N/A

      \[\leadsto \left(\frac{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}}{b + a} \cdot \frac{1}{b - a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    6. lift-/.f64N/A

      \[\leadsto \left(\frac{\color{blue}{\frac{\mathsf{PI}\left(\right)}{2}}}{b + a} \cdot \frac{1}{b - a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    7. lift--.f64N/A

      \[\leadsto \left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \frac{1}{\color{blue}{b - a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    8. lift-/.f64N/A

      \[\leadsto \left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \color{blue}{\frac{1}{b - a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    9. lift--.f64N/A

      \[\leadsto \left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \frac{1}{b - a}\right) \cdot \color{blue}{\left(\frac{1}{a} - \frac{1}{b}\right)} \]
    10. lift-/.f64N/A

      \[\leadsto \left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \frac{1}{b - a}\right) \cdot \left(\color{blue}{\frac{1}{a}} - \frac{1}{b}\right) \]
    11. lift-/.f64N/A

      \[\leadsto \left(\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \frac{1}{b - a}\right) \cdot \left(\frac{1}{a} - \color{blue}{\frac{1}{b}}\right) \]
    12. associate-*l*N/A

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \left(\frac{1}{b - a} \cdot \left(\frac{1}{a} - \frac{1}{b}\right)\right)} \]
    13. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{PI}\left(\right)}{2}}{b + a} \cdot \left(\frac{1}{b - a} \cdot \left(\frac{1}{a} - \frac{1}{b}\right)\right)} \]
  6. Applied rewrites99.6%

    \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{2 \cdot \left(a + b\right)} \cdot \left({\left(b - a\right)}^{-1} \cdot \left({a}^{-1} - {b}^{-1}\right)\right)} \]
  7. Taylor expanded in a around 0

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

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

        \[\leadsto \frac{\mathsf{PI}\left(\right)}{2 \cdot \left(a + b\right)} \cdot \frac{1}{\color{blue}{b \cdot a}} \]
      2. Add Preprocessing

      Alternative 2: 94.7% accurate, 1.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{PI}\left(\right) \cdot b}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(\left(b + a\right) \cdot b\right)\right)}\\ t_1 := \frac{0.5 \cdot \mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)}\\ \mathbf{if}\;b \leq -3.25 \cdot 10^{+91}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \leq -9.8 \cdot 10^{-95}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;b \leq 6.4 \cdot 10^{-242}:\\ \;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \cdot 0.5\\ \mathbf{elif}\;b \leq 1.35 \cdot 10^{+70}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
      (FPCore (a b)
       :precision binary64
       (let* ((t_0 (/ (* (PI) b) (* (* a b) (* 2.0 (* (+ b a) b)))))
              (t_1 (/ (* 0.5 (PI)) (* b (* b a)))))
         (if (<= b -3.25e+91)
           t_1
           (if (<= b -9.8e-95)
             t_0
             (if (<= b 6.4e-242)
               (* (/ (/ (PI) a) (* b a)) 0.5)
               (if (<= b 1.35e+70) t_0 t_1))))))
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{\mathsf{PI}\left(\right) \cdot b}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(\left(b + a\right) \cdot b\right)\right)}\\
      t_1 := \frac{0.5 \cdot \mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)}\\
      \mathbf{if}\;b \leq -3.25 \cdot 10^{+91}:\\
      \;\;\;\;t\_1\\
      
      \mathbf{elif}\;b \leq -9.8 \cdot 10^{-95}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;b \leq 6.4 \cdot 10^{-242}:\\
      \;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \cdot 0.5\\
      
      \mathbf{elif}\;b \leq 1.35 \cdot 10^{+70}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if b < -3.2499999999999999e91 or 1.35e70 < b

        1. Initial program 57.8%

          \[\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in a around inf

          \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot b}} \]
        4. Step-by-step derivation
          1. Applied rewrites44.0%

            \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5} \]
          2. Step-by-step derivation
            1. Applied rewrites44.0%

              \[\leadsto \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5 \]
            2. Taylor expanded in a around 0

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{\mathsf{PI}\left(\right)}{a \cdot {b}^{2}}} \]
            3. Step-by-step derivation
              1. Applied rewrites75.4%

                \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5} \]
              2. Step-by-step derivation
                1. Applied rewrites98.2%

                  \[\leadsto \frac{0.5 \cdot \mathsf{PI}\left(\right)}{\color{blue}{b \cdot \left(b \cdot a\right)}} \]

                if -3.2499999999999999e91 < b < -9.8e-95 or 6.39999999999999997e-242 < b < 1.35e70

                1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\left(\frac{1}{a} - \frac{1}{b}\right) \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right)} \]
                  13. frac-subN/A

                    \[\leadsto \color{blue}{\frac{1 \cdot b - a \cdot 1}{a \cdot b}} \cdot \left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \]
                  14. frac-timesN/A

                    \[\leadsto \frac{1 \cdot b - a \cdot 1}{a \cdot b} \cdot \color{blue}{\frac{\mathsf{PI}\left(\right) \cdot 1}{2 \cdot \left(b \cdot b - a \cdot a\right)}} \]
                  15. frac-timesN/A

                    \[\leadsto \color{blue}{\frac{\left(1 \cdot b - a \cdot 1\right) \cdot \left(\mathsf{PI}\left(\right) \cdot 1\right)}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(b \cdot b - a \cdot a\right)\right)}} \]
                4. Applied rewrites89.4%

                  \[\leadsto \color{blue}{\frac{\left(1 \cdot b - a \cdot 1\right) \cdot \left(\mathsf{PI}\left(\right) \cdot 1\right)}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right)}} \]
                5. Taylor expanded in a around 0

                  \[\leadsto \frac{\color{blue}{b \cdot \mathsf{PI}\left(\right)}}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right)} \]
                6. Step-by-step derivation
                  1. Applied rewrites63.8%

                    \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right) \cdot b}}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(\left(b + a\right) \cdot \left(b - a\right)\right)\right)} \]
                  2. Taylor expanded in a around 0

                    \[\leadsto \frac{\mathsf{PI}\left(\right) \cdot b}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(\left(b + a\right) \cdot \color{blue}{b}\right)\right)} \]
                  3. Step-by-step derivation
                    1. Applied rewrites97.0%

                      \[\leadsto \frac{\mathsf{PI}\left(\right) \cdot b}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(\left(b + a\right) \cdot \color{blue}{b}\right)\right)} \]

                    if -9.8e-95 < b < 6.39999999999999997e-242

                    1. Initial program 79.8%

                      \[\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
                    2. Add Preprocessing
                    3. Taylor expanded in a around inf

                      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot b}} \]
                    4. Step-by-step derivation
                      1. Applied rewrites81.5%

                        \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5} \]
                      2. Step-by-step derivation
                        1. Applied rewrites92.7%

                          \[\leadsto \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5 \]
                        2. Step-by-step derivation
                          1. Applied rewrites94.6%

                            \[\leadsto \frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \cdot 0.5 \]
                        3. Recombined 3 regimes into one program.
                        4. Add Preprocessing

                        Alternative 3: 83.9% accurate, 1.6× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -4.7 \cdot 10^{-51} \lor \neg \left(a \leq 4.2 \cdot 10^{-84}\right):\\ \;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot \mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)}\\ \end{array} \end{array} \]
                        (FPCore (a b)
                         :precision binary64
                         (if (or (<= a -4.7e-51) (not (<= a 4.2e-84)))
                           (* (/ (/ (PI) a) (* b a)) 0.5)
                           (/ (* 0.5 (PI)) (* b (* b a)))))
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;a \leq -4.7 \cdot 10^{-51} \lor \neg \left(a \leq 4.2 \cdot 10^{-84}\right):\\
                        \;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \cdot 0.5\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\frac{0.5 \cdot \mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)}\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if a < -4.6999999999999997e-51 or 4.19999999999999996e-84 < a

                          1. Initial program 78.2%

                            \[\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
                          2. Add Preprocessing
                          3. Taylor expanded in a around inf

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

                              \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5} \]
                            2. Step-by-step derivation
                              1. Applied rewrites86.0%

                                \[\leadsto \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5 \]
                              2. Step-by-step derivation
                                1. Applied rewrites86.7%

                                  \[\leadsto \frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \cdot 0.5 \]

                                if -4.6999999999999997e-51 < a < 4.19999999999999996e-84

                                1. Initial program 72.5%

                                  \[\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
                                2. Add Preprocessing
                                3. Taylor expanded in a around inf

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

                                    \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5} \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites26.1%

                                      \[\leadsto \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5 \]
                                    2. Taylor expanded in a around 0

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

                                        \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5} \]
                                      2. Step-by-step derivation
                                        1. Applied rewrites92.4%

                                          \[\leadsto \frac{0.5 \cdot \mathsf{PI}\left(\right)}{\color{blue}{b \cdot \left(b \cdot a\right)}} \]
                                      3. Recombined 2 regimes into one program.
                                      4. Final simplification88.9%

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4.7 \cdot 10^{-51} \lor \neg \left(a \leq 4.2 \cdot 10^{-84}\right):\\ \;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot \mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)}\\ \end{array} \]
                                      5. Add Preprocessing

                                      Alternative 4: 83.8% accurate, 1.8× speedup?

                                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -4.7 \cdot 10^{-51} \lor \neg \left(a \leq 4.2 \cdot 10^{-84}\right):\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot \mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)}\\ \end{array} \end{array} \]
                                      (FPCore (a b)
                                       :precision binary64
                                       (if (or (<= a -4.7e-51) (not (<= a 4.2e-84)))
                                         (* (/ (PI) (* a (* a b))) 0.5)
                                         (/ (* 0.5 (PI)) (* b (* b a)))))
                                      \begin{array}{l}
                                      
                                      \\
                                      \begin{array}{l}
                                      \mathbf{if}\;a \leq -4.7 \cdot 10^{-51} \lor \neg \left(a \leq 4.2 \cdot 10^{-84}\right):\\
                                      \;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\frac{0.5 \cdot \mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)}\\
                                      
                                      
                                      \end{array}
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if a < -4.6999999999999997e-51 or 4.19999999999999996e-84 < a

                                        1. Initial program 78.2%

                                          \[\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
                                        2. Add Preprocessing
                                        3. Taylor expanded in a around inf

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

                                            \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5} \]
                                          2. Step-by-step derivation
                                            1. Applied rewrites86.0%

                                              \[\leadsto \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5 \]

                                            if -4.6999999999999997e-51 < a < 4.19999999999999996e-84

                                            1. Initial program 72.5%

                                              \[\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in a around inf

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

                                                \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5} \]
                                              2. Step-by-step derivation
                                                1. Applied rewrites26.1%

                                                  \[\leadsto \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5 \]
                                                2. Taylor expanded in a around 0

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

                                                    \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5} \]
                                                  2. Step-by-step derivation
                                                    1. Applied rewrites92.4%

                                                      \[\leadsto \frac{0.5 \cdot \mathsf{PI}\left(\right)}{\color{blue}{b \cdot \left(b \cdot a\right)}} \]
                                                  3. Recombined 2 regimes into one program.
                                                  4. Final simplification88.5%

                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4.7 \cdot 10^{-51} \lor \neg \left(a \leq 4.2 \cdot 10^{-84}\right):\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 \cdot \mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)}\\ \end{array} \]
                                                  5. Add Preprocessing

                                                  Alternative 5: 78.4% accurate, 1.8× speedup?

                                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -4.7 \cdot 10^{-51} \lor \neg \left(a \leq 3.4 \cdot 10^{-84}\right):\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\ \end{array} \end{array} \]
                                                  (FPCore (a b)
                                                   :precision binary64
                                                   (if (or (<= a -4.7e-51) (not (<= a 3.4e-84)))
                                                     (* (/ (PI) (* a (* a b))) 0.5)
                                                     (* (/ (PI) (* (* b b) a)) 0.5)))
                                                  \begin{array}{l}
                                                  
                                                  \\
                                                  \begin{array}{l}
                                                  \mathbf{if}\;a \leq -4.7 \cdot 10^{-51} \lor \neg \left(a \leq 3.4 \cdot 10^{-84}\right):\\
                                                  \;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
                                                  
                                                  \mathbf{else}:\\
                                                  \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\
                                                  
                                                  
                                                  \end{array}
                                                  \end{array}
                                                  
                                                  Derivation
                                                  1. Split input into 2 regimes
                                                  2. if a < -4.6999999999999997e-51 or 3.40000000000000021e-84 < a

                                                    1. Initial program 78.2%

                                                      \[\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in a around inf

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

                                                        \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5} \]
                                                      2. Step-by-step derivation
                                                        1. Applied rewrites86.0%

                                                          \[\leadsto \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5 \]

                                                        if -4.6999999999999997e-51 < a < 3.40000000000000021e-84

                                                        1. Initial program 72.5%

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

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

                                                            \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5} \]
                                                        5. Recombined 2 regimes into one program.
                                                        6. Final simplification80.8%

                                                          \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4.7 \cdot 10^{-51} \lor \neg \left(a \leq 3.4 \cdot 10^{-84}\right):\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\ \end{array} \]
                                                        7. Add Preprocessing

                                                        Alternative 6: 61.8% accurate, 2.6× speedup?

                                                        \[\begin{array}{l} \\ \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5 \end{array} \]
                                                        (FPCore (a b) :precision binary64 (* (/ (PI) (* a (* a b))) 0.5))
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Initial program 76.0%

                                                          \[\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
                                                        2. Add Preprocessing
                                                        3. Taylor expanded in a around inf

                                                          \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot b}} \]
                                                        4. Step-by-step derivation
                                                          1. Applied rewrites56.7%

                                                            \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5} \]
                                                          2. Step-by-step derivation
                                                            1. Applied rewrites62.8%

                                                              \[\leadsto \frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5 \]
                                                            2. Add Preprocessing

                                                            Reproduce

                                                            ?
                                                            herbie shell --seed 2025025 
                                                            (FPCore (a b)
                                                              :name "NMSE Section 6.1 mentioned, B"
                                                              :precision binary64
                                                              (* (* (/ (PI) 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))