NMSE Section 6.1 mentioned, B

Percentage Accurate: 77.8% → 99.7%
Time: 8.7s
Alternatives: 7
Speedup: 2.4×

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 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.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.7% accurate, 1.7× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\frac{\frac{\mathsf{PI}\left(\right)}{b}}{a} \cdot 0.5}{a + b} \end{array} \]
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (/ (* (/ (/ (PI) b) a) 0.5) (+ a b)))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\frac{\mathsf{PI}\left(\right)}{b}}{a} \cdot 0.5}{a + b}
\end{array}
Derivation
  1. Initial program 80.6%

    \[\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. Applied rewrites92.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{PI}\left(\right)}{a + b}, \frac{0.5}{b - a} \cdot {a}^{-1}, \frac{\frac{0.5}{a + b} \cdot \frac{\mathsf{PI}\left(\right)}{b - a}}{-b}\right)} \]
  4. Applied rewrites86.4%

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{b}}{a} \cdot 0.5}{a + b} \]
  7. Applied rewrites99.8%

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

Alternative 2: 99.7% accurate, 2.0× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\frac{\mathsf{PI}\left(\right) \cdot 0.5}{a \cdot b}}{a + b} \end{array} \]
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (/ (/ (* (PI) 0.5) (* a b)) (+ a b)))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\mathsf{PI}\left(\right) \cdot 0.5}{a \cdot b}}{a + b}
\end{array}
Derivation
  1. Initial program 80.6%

    \[\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. Applied rewrites92.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{PI}\left(\right)}{a + b}, \frac{0.5}{b - a} \cdot {a}^{-1}, \frac{\frac{0.5}{a + b} \cdot \frac{\mathsf{PI}\left(\right)}{b - a}}{-b}\right)} \]
  4. Applied rewrites86.4%

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{b}}{a} \cdot 0.5}{a + b} \]
  7. Applied rewrites99.8%

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

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

    Alternative 3: 89.1% accurate, 2.2× speedup?

    \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -3.4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot b} \cdot 0.5\\ \end{array} \end{array} \]
    NOTE: a and b should be sorted in increasing order before calling this function.
    (FPCore (a b)
     :precision binary64
     (if (<= a -3.4e-8)
       (* (/ (PI) (* (* a b) a)) 0.5)
       (* (/ (PI) (* (* a b) b)) 0.5)))
    \begin{array}{l}
    [a, b] = \mathsf{sort}([a, b])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;a \leq -3.4 \cdot 10^{-8}:\\
    \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot a} \cdot 0.5\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot b} \cdot 0.5\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if a < -3.4e-8

      1. Initial program 83.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 b around 0

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

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

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

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

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

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

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

          \[\leadsto \frac{\mathsf{PI}\left(\right)}{b \cdot \color{blue}{\left(a \cdot a\right)}} \cdot \frac{1}{2} \]
        8. lower-*.f6480.7

          \[\leadsto \frac{\mathsf{PI}\left(\right)}{b \cdot \color{blue}{\left(a \cdot a\right)}} \cdot 0.5 \]
      5. Applied rewrites80.7%

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

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

        if -3.4e-8 < a

        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. Applied rewrites91.8%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{PI}\left(\right)}{a + b}, \frac{0.5}{b - a} \cdot {a}^{-1}, \frac{\frac{0.5}{a + b} \cdot \frac{\mathsf{PI}\left(\right)}{b - a}}{-b}\right)} \]
        4. Taylor expanded in b around inf

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

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

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

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

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

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

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

            \[\leadsto \frac{\mathsf{PI}\left(\right)}{\color{blue}{\left(b \cdot b\right)} \cdot a} \cdot \frac{1}{2} \]
          8. lower-*.f6461.6

            \[\leadsto \frac{\mathsf{PI}\left(\right)}{\color{blue}{\left(b \cdot b\right)} \cdot a} \cdot 0.5 \]
        6. Applied rewrites61.6%

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

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

        Alternative 4: 83.5% accurate, 2.2× speedup?

        \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -3.4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\ \end{array} \end{array} \]
        NOTE: a and b should be sorted in increasing order before calling this function.
        (FPCore (a b)
         :precision binary64
         (if (<= a -3.4e-8)
           (* (/ (PI) (* (* a b) a)) 0.5)
           (* (/ (PI) (* (* b b) a)) 0.5)))
        \begin{array}{l}
        [a, b] = \mathsf{sort}([a, b])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;a \leq -3.4 \cdot 10^{-8}:\\
        \;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot a} \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 < -3.4e-8

          1. Initial program 83.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 b around 0

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

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

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

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

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

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

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

              \[\leadsto \frac{\mathsf{PI}\left(\right)}{b \cdot \color{blue}{\left(a \cdot a\right)}} \cdot \frac{1}{2} \]
            8. lower-*.f6480.7

              \[\leadsto \frac{\mathsf{PI}\left(\right)}{b \cdot \color{blue}{\left(a \cdot a\right)}} \cdot 0.5 \]
          5. Applied rewrites80.7%

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

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

            if -3.4e-8 < a

            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 b around inf

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

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

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

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

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

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

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

                \[\leadsto \frac{\mathsf{PI}\left(\right)}{\color{blue}{\left(b \cdot b\right)} \cdot a} \cdot \frac{1}{2} \]
              8. lower-*.f6461.6

                \[\leadsto \frac{\mathsf{PI}\left(\right)}{\color{blue}{\left(b \cdot b\right)} \cdot a} \cdot 0.5 \]
            5. Applied rewrites61.6%

              \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5} \]
          7. Recombined 2 regimes into one program.
          8. Add Preprocessing

          Alternative 5: 98.9% accurate, 2.4× speedup?

          \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\mathsf{PI}\left(\right) \cdot 0.5}{\left(a \cdot b\right) \cdot \left(a + b\right)} \end{array} \]
          NOTE: a and b should be sorted in increasing order before calling this function.
          (FPCore (a b) :precision binary64 (/ (* (PI) 0.5) (* (* a b) (+ a b))))
          \begin{array}{l}
          [a, b] = \mathsf{sort}([a, b])\\
          \\
          \frac{\mathsf{PI}\left(\right) \cdot 0.5}{\left(a \cdot b\right) \cdot \left(a + b\right)}
          \end{array}
          
          Derivation
          1. Initial program 80.6%

            \[\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. Applied rewrites92.2%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\mathsf{PI}\left(\right)}{a + b}, \frac{0.5}{b - a} \cdot {a}^{-1}, \frac{\frac{0.5}{a + b} \cdot \frac{\mathsf{PI}\left(\right)}{b - a}}{-b}\right)} \]
          4. Applied rewrites99.0%

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

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

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

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

              \[\leadsto \frac{\color{blue}{\mathsf{PI}\left(\right)} \cdot 0.5}{\left(a \cdot b\right) \cdot \left(a + b\right)} \]
          7. Applied rewrites99.0%

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

          Alternative 6: 62.4% accurate, 2.6× speedup?

          \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot a} \cdot 0.5 \end{array} \]
          NOTE: a and b should be sorted in increasing order before calling this function.
          (FPCore (a b) :precision binary64 (* (/ (PI) (* (* a b) a)) 0.5))
          \begin{array}{l}
          [a, b] = \mathsf{sort}([a, b])\\
          \\
          \frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot a} \cdot 0.5
          \end{array}
          
          Derivation
          1. Initial program 80.6%

            \[\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 b around 0

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\mathsf{PI}\left(\right)}{b \cdot \color{blue}{\left(a \cdot a\right)}} \cdot 0.5 \]
          5. Applied rewrites59.1%

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

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

            Alternative 7: 56.3% accurate, 2.6× speedup?

            \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \end{array} \]
            NOTE: a and b should be sorted in increasing order before calling this function.
            (FPCore (a b) :precision binary64 (* (/ (PI) (* (* a a) b)) 0.5))
            \begin{array}{l}
            [a, b] = \mathsf{sort}([a, b])\\
            \\
            \frac{\mathsf{PI}\left(\right)}{\left(a \cdot a\right) \cdot b} \cdot 0.5
            \end{array}
            
            Derivation
            1. Initial program 80.6%

              \[\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 b around 0

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

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

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

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

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

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

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

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

                \[\leadsto \frac{\mathsf{PI}\left(\right)}{b \cdot \color{blue}{\left(a \cdot a\right)}} \cdot 0.5 \]
            5. Applied rewrites59.1%

              \[\leadsto \color{blue}{\frac{\mathsf{PI}\left(\right)}{b \cdot \left(a \cdot a\right)} \cdot 0.5} \]
            6. Final simplification59.1%

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

            Reproduce

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