NMSE Section 6.1 mentioned, B

Percentage Accurate: 78.1% → 99.7%
Time: 10.6s
Alternatives: 13
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 13 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.1% 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 \cdot 2}}{a}}{b + a} \end{array} \]
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (/ (/ (/ (PI) (* b 2.0)) a) (+ b a)))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\frac{\mathsf{PI}\left(\right)}{b \cdot 2}}{a}}{b + a}
\end{array}
Derivation
  1. Initial program 80.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. Applied rewrites99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.1% accurate, 2.0× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -1.4 \cdot 10^{+152}:\\ \;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot 0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\ \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 -1.4e+152)
   (* (PI) (/ 0.5 (* a (* b a))))
   (/ (* (PI) 0.5) (* b (* a (+ b a))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.4 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot 0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.4000000000000001e152

    1. Initial program 54.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. associate-*r/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(a \cdot a\right)}} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

    if -1.4000000000000001e152 < a

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}{\left(a \cdot \color{blue}{\left(a + b\right)}\right) \cdot b} \]
      17. distribute-rgt-inN/A

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

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

        \[\leadsto \frac{\mathsf{PI}\left(\right) \cdot \frac{1}{2}}{\color{blue}{b \cdot \left(a \cdot a + b \cdot a\right)}} \]
      20. distribute-rgt-inN/A

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1.4 \cdot 10^{+152}:\\ \;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot 0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.0% accurate, 2.0× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \cdot 0.5\\ \mathbf{if}\;b \leq 9.5 \cdot 10^{+81}:\\ \;\;\;\;\frac{t\_0}{a \cdot \left(b \cdot \left(b + a\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{b \cdot \left(b \cdot a\right)}\\ \end{array} \end{array} \]
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b)
 :precision binary64
 (let* ((t_0 (* (PI) 0.5)))
   (if (<= b 9.5e+81) (/ t_0 (* a (* b (+ b a)))) (/ t_0 (* b (* b a))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot 0.5\\
\mathbf{if}\;b \leq 9.5 \cdot 10^{+81}:\\
\;\;\;\;\frac{t\_0}{a \cdot \left(b \cdot \left(b + a\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{b \cdot \left(b \cdot a\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 9.50000000000000083e81

    1. Initial program 81.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 rewrites99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.50000000000000083e81 < b

    1. Initial program 72.7%

      \[\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-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) \]
      2. 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) \]
      3. *-rgt-identityN/A

        \[\leadsto \left(\color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right)} \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(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \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(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \cdot \frac{1}{b \cdot b - \color{blue}{a \cdot a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      6. lift--.f64N/A

        \[\leadsto \left(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \cdot \frac{1}{\color{blue}{b \cdot b - a \cdot a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      7. *-rgt-identityN/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) \]
      8. 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) \]
      9. 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) \]
      10. associate-*l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.0% accurate, 2.0× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -1 \cdot 10^{+116}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot 0.5}{a \cdot \left(b \cdot a\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\ \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 -1e+116)
   (/ (* (PI) 0.5) (* a (* b a)))
   (* (PI) (/ 0.5 (* b (* a (+ b a)))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{+116}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot 0.5}{a \cdot \left(b \cdot a\right)}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.00000000000000002e116

    1. Initial program 62.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. associate-*r/N/A

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e116 < a

    1. Initial program 83.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 rewrites99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{2}}{\left(a \cdot \color{blue}{\left(a + b\right)}\right) \cdot b} \cdot \mathsf{PI}\left(\right) \]
      16. distribute-rgt-inN/A

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

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

        \[\leadsto \frac{\frac{1}{2}}{\color{blue}{b \cdot \left(a \cdot a + b \cdot a\right)}} \cdot \mathsf{PI}\left(\right) \]
      19. distribute-rgt-inN/A

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -1 \cdot 10^{+116}:\\ \;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot 0.5}{a \cdot \left(b \cdot a\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.7% accurate, 2.0× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\frac{\mathsf{PI}\left(\right) \cdot 0.5}{b \cdot a}}{b + a} \end{array} \]
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (/ (/ (* (PI) 0.5) (* b a)) (+ b a)))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\mathsf{PI}\left(\right) \cdot 0.5}{b \cdot a}}{b + a}
\end{array}
Derivation
  1. Initial program 80.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. Applied rewrites99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 99.6% accurate, 2.0× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\mathsf{PI}\left(\right)}{b + a} \cdot \frac{0.5}{b \cdot a} \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 (* b a))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\mathsf{PI}\left(\right)}{b + a} \cdot \frac{0.5}{b \cdot a}
\end{array}
Derivation
  1. Initial program 80.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. Applied rewrites99.6%

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

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

Alternative 7: 99.6% accurate, 2.0× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\mathsf{PI}\left(\right)}{b \cdot a} \cdot \frac{0.5}{b + a} \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 (+ b a))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\mathsf{PI}\left(\right)}{b \cdot a} \cdot \frac{0.5}{b + a}
\end{array}
Derivation
  1. Initial program 80.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. Applied rewrites99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 89.8% accurate, 2.2× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} t_0 := \mathsf{PI}\left(\right) \cdot 0.5\\ \mathbf{if}\;b \leq 1.1 \cdot 10^{-95}:\\ \;\;\;\;\frac{t\_0}{a \cdot \left(b \cdot a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{b \cdot \left(b \cdot a\right)}\\ \end{array} \end{array} \]
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b)
 :precision binary64
 (let* ((t_0 (* (PI) 0.5)))
   (if (<= b 1.1e-95) (/ t_0 (* a (* b a))) (/ t_0 (* b (* b a))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot 0.5\\
\mathbf{if}\;b \leq 1.1 \cdot 10^{-95}:\\
\;\;\;\;\frac{t\_0}{a \cdot \left(b \cdot a\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{b \cdot \left(b \cdot a\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.0999999999999999e-95

    1. Initial program 78.3%

      \[\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. associate-*r/N/A

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

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

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

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

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

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

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

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

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

    if 1.0999999999999999e-95 < b

    1. Initial program 85.9%

      \[\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-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) \]
      2. 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) \]
      3. *-rgt-identityN/A

        \[\leadsto \left(\color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right)} \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(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \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(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \cdot \frac{1}{b \cdot b - \color{blue}{a \cdot a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      6. lift--.f64N/A

        \[\leadsto \left(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \cdot \frac{1}{\color{blue}{b \cdot b - a \cdot a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      7. *-rgt-identityN/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) \]
      8. 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) \]
      9. 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) \]
      10. associate-*l/N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{b}}{2 \cdot \left(b \cdot a\right)} \]
    7. Applied rewrites78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 89.8% accurate, 2.2× speedup?

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

\mathbf{else}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(b \cdot a\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.0999999999999999e-95

    1. Initial program 78.3%

      \[\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. associate-*r/N/A

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

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

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

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

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

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

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

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

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

    if 1.0999999999999999e-95 < b

    1. Initial program 85.9%

      \[\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-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) \]
      2. 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) \]
      3. *-rgt-identityN/A

        \[\leadsto \left(\color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right)} \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(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \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(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \cdot \frac{1}{b \cdot b - \color{blue}{a \cdot a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      6. lift--.f64N/A

        \[\leadsto \left(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \cdot \frac{1}{\color{blue}{b \cdot b - a \cdot a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      7. *-rgt-identityN/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) \]
      8. 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) \]
      9. 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) \]
      10. associate-*l/N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{b}}{2 \cdot \left(b \cdot a\right)} \]
    7. Applied rewrites78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 89.8% accurate, 2.2× speedup?

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

\mathbf{else}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(b \cdot a\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.0999999999999999e-95

    1. Initial program 78.3%

      \[\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. associate-*r/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(a \cdot a\right)}} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

    if 1.0999999999999999e-95 < b

    1. Initial program 85.9%

      \[\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-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) \]
      2. 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) \]
      3. *-rgt-identityN/A

        \[\leadsto \left(\color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right)} \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(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \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(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \cdot \frac{1}{b \cdot b - \color{blue}{a \cdot a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      6. lift--.f64N/A

        \[\leadsto \left(\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot 1\right) \cdot \frac{1}{\color{blue}{b \cdot b - a \cdot a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      7. *-rgt-identityN/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) \]
      8. 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) \]
      9. 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) \]
      10. associate-*l/N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{b}}{2 \cdot \left(b \cdot a\right)} \]
    7. Applied rewrites78.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 99.1% accurate, 2.4× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\mathsf{PI}\left(\right) \cdot 0.5}{\left(b + a\right) \cdot \left(b \cdot a\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) (* (+ b a) (* b a))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\mathsf{PI}\left(\right) \cdot 0.5}{\left(b + a\right) \cdot \left(b \cdot a\right)}
\end{array}
Derivation
  1. Initial program 80.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. Applied rewrites99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 63.6% accurate, 2.6× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \mathsf{PI}\left(\right) \cdot \frac{0.5}{a \cdot \left(b \cdot a\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)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\mathsf{PI}\left(\right) \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}
\end{array}
Derivation
  1. Initial program 80.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. associate-*r/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(a \cdot a\right)}} \]
  8. Step-by-step derivation
    1. associate-*r*N/A

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

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

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

    \[\leadsto \mathsf{PI}\left(\right) \cdot \frac{0.5}{\color{blue}{\left(b \cdot a\right) \cdot a}} \]
  10. Final simplification63.9%

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

Alternative 13: 57.6% accurate, 2.6× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(a \cdot a\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 (* b (* a a)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(a \cdot a\right)}
\end{array}
Derivation
  1. Initial program 80.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. associate-*r/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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