NMSE Section 6.1 mentioned, B

Percentage Accurate: 78.6% → 99.6%
Time: 10.1s
Alternatives: 10
Speedup: 1.9×

Specification

?
\[\begin{array}{l} \\ \left(\frac{\pi}{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))))
double code(double a, double b) {
	return ((((double) M_PI) / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
public static double code(double a, double b) {
	return ((Math.PI / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
def code(a, b):
	return ((math.pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b))
function code(a, b)
	return Float64(Float64(Float64(pi / 2.0) * Float64(1.0 / Float64(Float64(b * b) - Float64(a * a)))) * Float64(Float64(1.0 / a) - Float64(1.0 / b)))
end
function tmp = code(a, b)
	tmp = ((pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
end
code[a_, b_] := N[(N[(N[(Pi / 2.0), $MachinePrecision] * N[(1.0 / N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] - N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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 10 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.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\frac{\pi}{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))))
double code(double a, double b) {
	return ((((double) M_PI) / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
public static double code(double a, double b) {
	return ((Math.PI / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
def code(a, b):
	return ((math.pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b))
function code(a, b)
	return Float64(Float64(Float64(pi / 2.0) * Float64(1.0 / Float64(Float64(b * b) - Float64(a * a)))) * Float64(Float64(1.0 / a) - Float64(1.0 / b)))
end
function tmp = code(a, b)
	tmp = ((pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
end
code[a_, b_] := N[(N[(N[(Pi / 2.0), $MachinePrecision] * N[(1.0 / N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] - N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.6% accurate, 1.5× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -5 \cdot 10^{+147}:\\ \;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\pi \cdot \frac{\frac{\frac{0.5}{a}}{a + b}}{b}\\ \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 -5e+147)
   (* (/ PI (* b a)) (/ 0.5 a))
   (* PI (/ (/ (/ 0.5 a) (+ a b)) b))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (a <= -5e+147) {
		tmp = (((double) M_PI) / (b * a)) * (0.5 / a);
	} else {
		tmp = ((double) M_PI) * (((0.5 / a) / (a + b)) / b);
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (a <= -5e+147) {
		tmp = (Math.PI / (b * a)) * (0.5 / a);
	} else {
		tmp = Math.PI * (((0.5 / a) / (a + b)) / b);
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if a <= -5e+147:
		tmp = (math.pi / (b * a)) * (0.5 / a)
	else:
		tmp = math.pi * (((0.5 / a) / (a + b)) / b)
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (a <= -5e+147)
		tmp = Float64(Float64(pi / Float64(b * a)) * Float64(0.5 / a));
	else
		tmp = Float64(pi * Float64(Float64(Float64(0.5 / a) / Float64(a + b)) / b));
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -5e+147)
		tmp = (pi / (b * a)) * (0.5 / a);
	else
		tmp = pi * (((0.5 / a) / (a + b)) / b);
	end
	tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := If[LessEqual[a, -5e+147], N[(N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(Pi * N[(N[(N[(0.5 / a), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5 \cdot 10^{+147}:\\
\;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{0.5}{a}\\

\mathbf{else}:\\
\;\;\;\;\pi \cdot \frac{\frac{\frac{0.5}{a}}{a + b}}{b}\\


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

    1. Initial program 56.8%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Taylor expanded in a around inf

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

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

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

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

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
      7. lift-*.f6476.0

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
    4. Applied rewrites76.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\pi}{a \cdot b} \cdot \frac{\frac{1}{2}}{a} \]
      22. *-commutativeN/A

        \[\leadsto \frac{\pi}{b \cdot a} \cdot \frac{\frac{1}{2}}{a} \]
      23. lower-*.f64N/A

        \[\leadsto \frac{\pi}{b \cdot a} \cdot \frac{\frac{1}{2}}{a} \]
      24. lower-/.f6499.8

        \[\leadsto \frac{\pi}{b \cdot a} \cdot \frac{0.5}{\color{blue}{a}} \]
    6. Applied rewrites99.8%

      \[\leadsto \frac{\pi}{b \cdot a} \cdot \color{blue}{\frac{0.5}{a}} \]

    if -5.0000000000000002e147 < a

    1. Initial program 85.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{\color{blue}{a + b}}}{1 \cdot b - a \cdot 1} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      16. *-lft-identityN/A

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

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{b - \color{blue}{a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      18. lower--.f6492.1

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{\color{blue}{b - a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    3. Applied rewrites92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \pi \cdot \frac{1}{\color{blue}{a \cdot \left(b \cdot \left(\left(b + a\right) \cdot 2\right)\right)}} \]
    6. Applied rewrites91.4%

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

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

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

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

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

        \[\leadsto \pi \cdot \frac{1}{\left(a + a\right) \cdot \left(b \cdot \color{blue}{\left(a + b\right)}\right)} \]
      6. count-2-revN/A

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

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

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

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

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

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

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

        \[\leadsto \pi \cdot \color{blue}{\frac{\frac{\frac{1}{2} \cdot \frac{1}{a}}{a + b}}{b}} \]
      14. lower-/.f64N/A

        \[\leadsto \pi \cdot \color{blue}{\frac{\frac{\frac{1}{2} \cdot \frac{1}{a}}{a + b}}{b}} \]
      15. lower-/.f64N/A

        \[\leadsto \pi \cdot \frac{\color{blue}{\frac{\frac{1}{2} \cdot \frac{1}{a}}{a + b}}}{b} \]
      16. associate-*r/N/A

        \[\leadsto \pi \cdot \frac{\frac{\color{blue}{\frac{\frac{1}{2} \cdot 1}{a}}}{a + b}}{b} \]
      17. metadata-evalN/A

        \[\leadsto \pi \cdot \frac{\frac{\frac{\color{blue}{\frac{1}{2}}}{a}}{a + b}}{b} \]
      18. lift-/.f64N/A

        \[\leadsto \pi \cdot \frac{\frac{\color{blue}{\frac{\frac{1}{2}}{a}}}{a + b}}{b} \]
      19. lift-+.f6499.6

        \[\leadsto \pi \cdot \frac{\frac{\frac{0.5}{a}}{\color{blue}{a + b}}}{b} \]
    8. Applied rewrites99.6%

      \[\leadsto \pi \cdot \color{blue}{\frac{\frac{\frac{0.5}{a}}{a + b}}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 99.4% accurate, 1.6× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -1.3 \cdot 10^{+157}:\\ \;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{0.5}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \left(a + b\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.3e+157)
   (* (/ PI (* b a)) (/ 0.5 a))
   (/ (/ PI b) (* (+ a a) (+ a b)))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (a <= -1.3e+157) {
		tmp = (((double) M_PI) / (b * a)) * (0.5 / a);
	} else {
		tmp = (((double) M_PI) / b) / ((a + a) * (a + b));
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (a <= -1.3e+157) {
		tmp = (Math.PI / (b * a)) * (0.5 / a);
	} else {
		tmp = (Math.PI / b) / ((a + a) * (a + b));
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if a <= -1.3e+157:
		tmp = (math.pi / (b * a)) * (0.5 / a)
	else:
		tmp = (math.pi / b) / ((a + a) * (a + b))
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (a <= -1.3e+157)
		tmp = Float64(Float64(pi / Float64(b * a)) * Float64(0.5 / a));
	else
		tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * Float64(a + b)));
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -1.3e+157)
		tmp = (pi / (b * a)) * (0.5 / a);
	else
		tmp = (pi / b) / ((a + a) * (a + b));
	end
	tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := If[LessEqual[a, -1.3e+157], N[(N[(Pi / N[(b * a), $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.3 \cdot 10^{+157}:\\
\;\;\;\;\frac{\pi}{b \cdot a} \cdot \frac{0.5}{a}\\

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


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

    1. Initial program 55.7%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Taylor expanded in a around inf

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

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

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

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

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
      7. lift-*.f6475.8

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
    4. Applied rewrites75.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\pi}{a \cdot b} \cdot \frac{\frac{1}{2}}{a} \]
      22. *-commutativeN/A

        \[\leadsto \frac{\pi}{b \cdot a} \cdot \frac{\frac{1}{2}}{a} \]
      23. lower-*.f64N/A

        \[\leadsto \frac{\pi}{b \cdot a} \cdot \frac{\frac{1}{2}}{a} \]
      24. lower-/.f6499.8

        \[\leadsto \frac{\pi}{b \cdot a} \cdot \frac{0.5}{\color{blue}{a}} \]
    6. Applied rewrites99.8%

      \[\leadsto \frac{\pi}{b \cdot a} \cdot \color{blue}{\frac{0.5}{a}} \]

    if -1.30000000000000005e157 < a

    1. Initial program 85.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{\color{blue}{a + b}}}{1 \cdot b - a \cdot 1} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      16. *-lft-identityN/A

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

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{b - \color{blue}{a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      18. lower--.f6492.2

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{\color{blue}{b - a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    3. Applied rewrites92.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\pi}{b}}{\color{blue}{\left(2 \cdot a\right) \cdot \left(b + a\right)}} \]
      18. count-2-revN/A

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

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

        \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
      21. lower-+.f6499.3

        \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
    6. Applied rewrites99.3%

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

Alternative 3: 99.2% accurate, 1.6× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -1.7 \cdot 10^{+89}:\\ \;\;\;\;\frac{\frac{\pi}{b} \cdot \frac{0.5}{a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{\left(a \cdot \left(a + b\right)\right) \cdot \left(b + b\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.7e+89)
   (/ (* (/ PI b) (/ 0.5 a)) a)
   (/ PI (* (* a (+ a b)) (+ b b)))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (a <= -1.7e+89) {
		tmp = ((((double) M_PI) / b) * (0.5 / a)) / a;
	} else {
		tmp = ((double) M_PI) / ((a * (a + b)) * (b + b));
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (a <= -1.7e+89) {
		tmp = ((Math.PI / b) * (0.5 / a)) / a;
	} else {
		tmp = Math.PI / ((a * (a + b)) * (b + b));
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if a <= -1.7e+89:
		tmp = ((math.pi / b) * (0.5 / a)) / a
	else:
		tmp = math.pi / ((a * (a + b)) * (b + b))
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (a <= -1.7e+89)
		tmp = Float64(Float64(Float64(pi / b) * Float64(0.5 / a)) / a);
	else
		tmp = Float64(pi / Float64(Float64(a * Float64(a + b)) * Float64(b + b)));
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -1.7e+89)
		tmp = ((pi / b) * (0.5 / a)) / a;
	else
		tmp = pi / ((a * (a + b)) * (b + b));
	end
	tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := If[LessEqual[a, -1.7e+89], N[(N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(Pi / N[(N[(a * N[(a + b), $MachinePrecision]), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.7 \cdot 10^{+89}:\\
\;\;\;\;\frac{\frac{\pi}{b} \cdot \frac{0.5}{a}}{a}\\

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


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

    1. Initial program 67.5%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Taylor expanded in a around inf

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

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

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

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

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
      7. lift-*.f6481.3

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
    4. Applied rewrites81.3%

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

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

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

        \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot \frac{1}{2} \]
      6. lower-*.f6498.5

        \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5 \]
    6. Applied rewrites98.5%

      \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5 \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\pi}{b \cdot a} \cdot \frac{\frac{1}{2}}{a} \]
      10. lift-/.f64N/A

        \[\leadsto \frac{\pi}{b \cdot a} \cdot \frac{\frac{1}{2}}{\color{blue}{a}} \]
      11. lift-PI.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\pi}{b} \cdot \frac{\frac{1}{2}}{a}}{a} \]
      21. lift-/.f6499.4

        \[\leadsto \frac{\frac{\pi}{b} \cdot \frac{0.5}{a}}{a} \]
    8. Applied rewrites99.4%

      \[\leadsto \frac{\frac{\pi}{b} \cdot \frac{0.5}{a}}{\color{blue}{a}} \]

    if -1.7000000000000001e89 < a

    1. Initial program 83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{\color{blue}{a + b}}}{1 \cdot b - a \cdot 1} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      16. *-lft-identityN/A

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

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{b - \color{blue}{a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      18. lower--.f6491.3

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{\color{blue}{b - a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    3. Applied rewrites91.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\pi}{b}}{\color{blue}{\left(2 \cdot a\right) \cdot \left(b + a\right)}} \]
      18. count-2-revN/A

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

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

        \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
      21. lower-+.f6499.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\pi}}{\left(a + a\right) \cdot \left(b \cdot \left(a + b\right)\right)} \]
      15. count-2-revN/A

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

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

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

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

        \[\leadsto \frac{\pi}{b \cdot \color{blue}{\left(2 \cdot \left(a \cdot \left(a + b\right)\right)\right)}} \]
      20. distribute-lft-outN/A

        \[\leadsto \frac{\pi}{b \cdot \left(2 \cdot \color{blue}{\left(a \cdot a + a \cdot b\right)}\right)} \]
      21. pow2N/A

        \[\leadsto \frac{\pi}{b \cdot \left(2 \cdot \left(\color{blue}{{a}^{2}} + a \cdot b\right)\right)} \]
      22. +-commutativeN/A

        \[\leadsto \frac{\pi}{b \cdot \left(2 \cdot \color{blue}{\left(a \cdot b + {a}^{2}\right)}\right)} \]
    8. Applied rewrites99.1%

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

Alternative 4: 98.9% accurate, 1.7× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\pi}{\left(b \cdot a\right) \cdot \left(\left(b + a\right) \cdot 2\right)} \cdot 1 \end{array} \]
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b) :precision binary64 (* (/ PI (* (* b a) (* (+ b a) 2.0))) 1.0))
assert(a < b);
double code(double a, double b) {
	return (((double) M_PI) / ((b * a) * ((b + a) * 2.0))) * 1.0;
}
assert a < b;
public static double code(double a, double b) {
	return (Math.PI / ((b * a) * ((b + a) * 2.0))) * 1.0;
}
[a, b] = sort([a, b])
def code(a, b):
	return (math.pi / ((b * a) * ((b + a) * 2.0))) * 1.0
a, b = sort([a, b])
function code(a, b)
	return Float64(Float64(pi / Float64(Float64(b * a) * Float64(Float64(b + a) * 2.0))) * 1.0)
end
a, b = num2cell(sort([a, b])){:}
function tmp = code(a, b)
	tmp = (pi / ((b * a) * ((b + a) * 2.0))) * 1.0;
end
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := N[(N[(Pi / N[(N[(b * a), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\pi}{\left(b \cdot a\right) \cdot \left(\left(b + a\right) \cdot 2\right)} \cdot 1
\end{array}
Derivation
  1. Initial program 78.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\frac{\pi}{2}}{\color{blue}{a + b}}}{1 \cdot b - a \cdot 1} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    16. *-lft-identityN/A

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

      \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{b - \color{blue}{a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    18. lower--.f6488.6

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

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

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

Alternative 5: 90.3% accurate, 1.8× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\ \;\;\;\;\frac{\frac{\pi}{a}}{b \cdot a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\ \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.08e-72) (* (/ (/ PI a) (* b a)) 0.5) (/ (/ PI b) (* (+ a a) b))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (b <= 1.08e-72) {
		tmp = ((((double) M_PI) / a) / (b * a)) * 0.5;
	} else {
		tmp = (((double) M_PI) / b) / ((a + a) * b);
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (b <= 1.08e-72) {
		tmp = ((Math.PI / a) / (b * a)) * 0.5;
	} else {
		tmp = (Math.PI / b) / ((a + a) * b);
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if b <= 1.08e-72:
		tmp = ((math.pi / a) / (b * a)) * 0.5
	else:
		tmp = (math.pi / b) / ((a + a) * b)
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (b <= 1.08e-72)
		tmp = Float64(Float64(Float64(pi / a) / Float64(b * a)) * 0.5);
	else
		tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * b));
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (b <= 1.08e-72)
		tmp = ((pi / a) / (b * a)) * 0.5;
	else
		tmp = (pi / b) / ((a + a) * b);
	end
	tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := If[LessEqual[b, 1.08e-72], N[(N[(N[(Pi / a), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
\;\;\;\;\frac{\frac{\pi}{a}}{b \cdot a} \cdot 0.5\\

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


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

    1. Initial program 78.5%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Taylor expanded in a around inf

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

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

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

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

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
      7. lift-*.f6479.7

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
    4. Applied rewrites79.7%

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

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

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

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

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

        \[\leadsto \frac{\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)}{\mathsf{neg}\left(\left(a \cdot a\right) \cdot b\right)} \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \frac{\mathsf{neg}\left(\mathsf{PI}\left(\right)\right)}{\mathsf{neg}\left({a}^{2} \cdot b\right)} \cdot \frac{1}{2} \]
      7. frac-2negN/A

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

        \[\leadsto \frac{\frac{\mathsf{PI}\left(\right)}{{a}^{2}}}{b} \cdot \frac{1}{2} \]
      9. pow2N/A

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

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

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

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

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

        \[\leadsto \frac{\frac{\pi}{a}}{a \cdot b} \cdot \frac{1}{2} \]
      15. *-commutativeN/A

        \[\leadsto \frac{\frac{\pi}{a}}{b \cdot a} \cdot \frac{1}{2} \]
      16. lower-*.f6491.5

        \[\leadsto \frac{\frac{\pi}{a}}{b \cdot a} \cdot 0.5 \]
    6. Applied rewrites91.5%

      \[\leadsto \frac{\frac{\pi}{a}}{b \cdot a} \cdot 0.5 \]

    if 1.07999999999999998e-72 < b

    1. Initial program 78.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{\color{blue}{a + b}}}{1 \cdot b - a \cdot 1} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      16. *-lft-identityN/A

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

        \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{b - \color{blue}{a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      18. lower--.f6488.6

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

      \[\leadsto \color{blue}{\frac{\frac{\frac{\pi}{2}}{a + b}}{b - a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    4. Applied rewrites98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\pi}{b}}{\color{blue}{\left(2 \cdot a\right) \cdot \left(b + a\right)}} \]
      18. count-2-revN/A

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

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

        \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
      21. lower-+.f6499.4

        \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
    6. Applied rewrites99.4%

      \[\leadsto \color{blue}{\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \left(a + b\right)}} \]
    7. Taylor expanded in a around 0

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

        \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{b}} \]
    9. Recombined 2 regimes into one program.
    10. Add Preprocessing

    Alternative 6: 90.3% accurate, 1.8× speedup?

    \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\ \;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\ \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.08e-72) (* (/ PI a) (/ 0.5 (* b a))) (/ (/ PI b) (* (+ a a) b))))
    assert(a < b);
    double code(double a, double b) {
    	double tmp;
    	if (b <= 1.08e-72) {
    		tmp = (((double) M_PI) / a) * (0.5 / (b * a));
    	} else {
    		tmp = (((double) M_PI) / b) / ((a + a) * b);
    	}
    	return tmp;
    }
    
    assert a < b;
    public static double code(double a, double b) {
    	double tmp;
    	if (b <= 1.08e-72) {
    		tmp = (Math.PI / a) * (0.5 / (b * a));
    	} else {
    		tmp = (Math.PI / b) / ((a + a) * b);
    	}
    	return tmp;
    }
    
    [a, b] = sort([a, b])
    def code(a, b):
    	tmp = 0
    	if b <= 1.08e-72:
    		tmp = (math.pi / a) * (0.5 / (b * a))
    	else:
    		tmp = (math.pi / b) / ((a + a) * b)
    	return tmp
    
    a, b = sort([a, b])
    function code(a, b)
    	tmp = 0.0
    	if (b <= 1.08e-72)
    		tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(b * a)));
    	else
    		tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * b));
    	end
    	return tmp
    end
    
    a, b = num2cell(sort([a, b])){:}
    function tmp_2 = code(a, b)
    	tmp = 0.0;
    	if (b <= 1.08e-72)
    		tmp = (pi / a) * (0.5 / (b * a));
    	else
    		tmp = (pi / b) / ((a + a) * b);
    	end
    	tmp_2 = tmp;
    end
    
    NOTE: a and b should be sorted in increasing order before calling this function.
    code[a_, b_] := If[LessEqual[b, 1.08e-72], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    [a, b] = \mathsf{sort}([a, b])\\
    \\
    \begin{array}{l}
    \mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
    \;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{b \cdot a}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < 1.07999999999999998e-72

      1. Initial program 78.5%

        \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      2. Taylor expanded in a around inf

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

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

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

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

          \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
        5. lower-*.f64N/A

          \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
        6. pow2N/A

          \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
        7. lift-*.f6479.7

          \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
      4. Applied rewrites79.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\pi}{a} \cdot \frac{\frac{1}{2}}{a \cdot b} \]
        16. lower-/.f64N/A

          \[\leadsto \frac{\pi}{a} \cdot \frac{\frac{1}{2}}{\color{blue}{a \cdot b}} \]
        17. *-commutativeN/A

          \[\leadsto \frac{\pi}{a} \cdot \frac{\frac{1}{2}}{b \cdot \color{blue}{a}} \]
        18. lower-*.f6491.5

          \[\leadsto \frac{\pi}{a} \cdot \frac{0.5}{b \cdot \color{blue}{a}} \]
      6. Applied rewrites91.5%

        \[\leadsto \frac{\pi}{a} \cdot \color{blue}{\frac{0.5}{b \cdot a}} \]

      if 1.07999999999999998e-72 < b

      1. Initial program 78.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\frac{\frac{\pi}{2}}{\color{blue}{a + b}}}{1 \cdot b - a \cdot 1} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
        16. *-lft-identityN/A

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

          \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{b - \color{blue}{a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
        18. lower--.f6488.6

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

        \[\leadsto \color{blue}{\frac{\frac{\frac{\pi}{2}}{a + b}}{b - a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      4. Applied rewrites98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\frac{\pi}{b}}{\color{blue}{\left(2 \cdot a\right) \cdot \left(b + a\right)}} \]
        18. count-2-revN/A

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

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

          \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
        21. lower-+.f6499.4

          \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
      6. Applied rewrites99.4%

        \[\leadsto \color{blue}{\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \left(a + b\right)}} \]
      7. Taylor expanded in a around 0

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

          \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{b}} \]
      9. Recombined 2 regimes into one program.
      10. Add Preprocessing

      Alternative 7: 90.3% accurate, 1.8× speedup?

      \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\ \;\;\;\;\pi \cdot \frac{\frac{0.5}{a}}{a \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\ \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.08e-72) (* PI (/ (/ 0.5 a) (* a b))) (/ (/ PI b) (* (+ a a) b))))
      assert(a < b);
      double code(double a, double b) {
      	double tmp;
      	if (b <= 1.08e-72) {
      		tmp = ((double) M_PI) * ((0.5 / a) / (a * b));
      	} else {
      		tmp = (((double) M_PI) / b) / ((a + a) * b);
      	}
      	return tmp;
      }
      
      assert a < b;
      public static double code(double a, double b) {
      	double tmp;
      	if (b <= 1.08e-72) {
      		tmp = Math.PI * ((0.5 / a) / (a * b));
      	} else {
      		tmp = (Math.PI / b) / ((a + a) * b);
      	}
      	return tmp;
      }
      
      [a, b] = sort([a, b])
      def code(a, b):
      	tmp = 0
      	if b <= 1.08e-72:
      		tmp = math.pi * ((0.5 / a) / (a * b))
      	else:
      		tmp = (math.pi / b) / ((a + a) * b)
      	return tmp
      
      a, b = sort([a, b])
      function code(a, b)
      	tmp = 0.0
      	if (b <= 1.08e-72)
      		tmp = Float64(pi * Float64(Float64(0.5 / a) / Float64(a * b)));
      	else
      		tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * b));
      	end
      	return tmp
      end
      
      a, b = num2cell(sort([a, b])){:}
      function tmp_2 = code(a, b)
      	tmp = 0.0;
      	if (b <= 1.08e-72)
      		tmp = pi * ((0.5 / a) / (a * b));
      	else
      		tmp = (pi / b) / ((a + a) * b);
      	end
      	tmp_2 = tmp;
      end
      
      NOTE: a and b should be sorted in increasing order before calling this function.
      code[a_, b_] := If[LessEqual[b, 1.08e-72], N[(Pi * N[(N[(0.5 / a), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      [a, b] = \mathsf{sort}([a, b])\\
      \\
      \begin{array}{l}
      \mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
      \;\;\;\;\pi \cdot \frac{\frac{0.5}{a}}{a \cdot b}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if b < 1.07999999999999998e-72

        1. Initial program 78.5%

          \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
        2. Taylor expanded in a around inf

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

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

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

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

            \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
          5. lower-*.f64N/A

            \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
          6. pow2N/A

            \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
          7. lift-*.f6479.7

            \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
        4. Applied rewrites79.7%

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

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

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

            \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
          4. lower-*.f64N/A

            \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
          5. *-commutativeN/A

            \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot \frac{1}{2} \]
          6. lower-*.f6491.0

            \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5 \]
        6. Applied rewrites91.0%

          \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5 \]
        7. Step-by-step derivation
          1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \pi \cdot \frac{\color{blue}{\frac{\frac{1}{2}}{a}}}{b \cdot a} \]
          12. lower-/.f64N/A

            \[\leadsto \pi \cdot \frac{\frac{\frac{1}{2}}{a}}{\color{blue}{b \cdot a}} \]
          13. lift-/.f6491.4

            \[\leadsto \pi \cdot \frac{\frac{0.5}{a}}{\color{blue}{b} \cdot a} \]
          14. lift-*.f64N/A

            \[\leadsto \pi \cdot \frac{\frac{\frac{1}{2}}{a}}{b \cdot \color{blue}{a}} \]
          15. *-commutativeN/A

            \[\leadsto \pi \cdot \frac{\frac{\frac{1}{2}}{a}}{a \cdot \color{blue}{b}} \]
          16. lower-*.f6491.4

            \[\leadsto \pi \cdot \frac{\frac{0.5}{a}}{a \cdot \color{blue}{b}} \]
        8. Applied rewrites91.4%

          \[\leadsto \pi \cdot \color{blue}{\frac{\frac{0.5}{a}}{a \cdot b}} \]

        if 1.07999999999999998e-72 < b

        1. Initial program 78.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\frac{\frac{\pi}{2}}{\color{blue}{a + b}}}{1 \cdot b - a \cdot 1} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
          16. *-lft-identityN/A

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

            \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{b - \color{blue}{a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
          18. lower--.f6488.6

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

          \[\leadsto \color{blue}{\frac{\frac{\frac{\pi}{2}}{a + b}}{b - a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
        4. Applied rewrites98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\frac{\pi}{b}}{\color{blue}{\left(2 \cdot a\right) \cdot \left(b + a\right)}} \]
          18. count-2-revN/A

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

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

            \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
          21. lower-+.f6499.4

            \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
        6. Applied rewrites99.4%

          \[\leadsto \color{blue}{\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \left(a + b\right)}} \]
        7. Taylor expanded in a around 0

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

            \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{b}} \]
        9. Recombined 2 regimes into one program.
        10. Add Preprocessing

        Alternative 8: 90.0% accurate, 1.8× speedup?

        \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\ \;\;\;\;\frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\ \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.08e-72) (* (/ PI (* a (* b a))) 0.5) (/ (/ PI b) (* (+ a a) b))))
        assert(a < b);
        double code(double a, double b) {
        	double tmp;
        	if (b <= 1.08e-72) {
        		tmp = (((double) M_PI) / (a * (b * a))) * 0.5;
        	} else {
        		tmp = (((double) M_PI) / b) / ((a + a) * b);
        	}
        	return tmp;
        }
        
        assert a < b;
        public static double code(double a, double b) {
        	double tmp;
        	if (b <= 1.08e-72) {
        		tmp = (Math.PI / (a * (b * a))) * 0.5;
        	} else {
        		tmp = (Math.PI / b) / ((a + a) * b);
        	}
        	return tmp;
        }
        
        [a, b] = sort([a, b])
        def code(a, b):
        	tmp = 0
        	if b <= 1.08e-72:
        		tmp = (math.pi / (a * (b * a))) * 0.5
        	else:
        		tmp = (math.pi / b) / ((a + a) * b)
        	return tmp
        
        a, b = sort([a, b])
        function code(a, b)
        	tmp = 0.0
        	if (b <= 1.08e-72)
        		tmp = Float64(Float64(pi / Float64(a * Float64(b * a))) * 0.5);
        	else
        		tmp = Float64(Float64(pi / b) / Float64(Float64(a + a) * b));
        	end
        	return tmp
        end
        
        a, b = num2cell(sort([a, b])){:}
        function tmp_2 = code(a, b)
        	tmp = 0.0;
        	if (b <= 1.08e-72)
        		tmp = (pi / (a * (b * a))) * 0.5;
        	else
        		tmp = (pi / b) / ((a + a) * b);
        	end
        	tmp_2 = tmp;
        end
        
        NOTE: a and b should be sorted in increasing order before calling this function.
        code[a_, b_] := If[LessEqual[b, 1.08e-72], N[(N[(Pi / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] / N[(N[(a + a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        [a, b] = \mathsf{sort}([a, b])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
        \;\;\;\;\frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot b}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if b < 1.07999999999999998e-72

          1. Initial program 78.5%

            \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
          2. Taylor expanded in a around inf

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

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

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

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

              \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
            5. lower-*.f64N/A

              \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
            6. pow2N/A

              \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
            7. lift-*.f6479.7

              \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
          4. Applied rewrites79.7%

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

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

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

              \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
            4. lower-*.f64N/A

              \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
            5. *-commutativeN/A

              \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot \frac{1}{2} \]
            6. lower-*.f6491.0

              \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5 \]
          6. Applied rewrites91.0%

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

          if 1.07999999999999998e-72 < b

          1. Initial program 78.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\frac{\frac{\pi}{2}}{\color{blue}{a + b}}}{1 \cdot b - a \cdot 1} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
            16. *-lft-identityN/A

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

              \[\leadsto \frac{\frac{\frac{\pi}{2}}{a + b}}{b - \color{blue}{a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
            18. lower--.f6488.6

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

            \[\leadsto \color{blue}{\frac{\frac{\frac{\pi}{2}}{a + b}}{b - a}} \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
          4. Applied rewrites98.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\frac{\pi}{b}}{\color{blue}{\left(2 \cdot a\right) \cdot \left(b + a\right)}} \]
            18. count-2-revN/A

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

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

              \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
            21. lower-+.f6499.4

              \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{\left(a + b\right)}} \]
          6. Applied rewrites99.4%

            \[\leadsto \color{blue}{\frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \left(a + b\right)}} \]
          7. Taylor expanded in a around 0

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

              \[\leadsto \frac{\frac{\pi}{b}}{\left(a + a\right) \cdot \color{blue}{b}} \]
          9. Recombined 2 regimes into one program.
          10. Add Preprocessing

          Alternative 9: 84.0% accurate, 1.9× speedup?

          \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\ \;\;\;\;\frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\ \end{array} \end{array} \]
          NOTE: a and b should be sorted in increasing order before calling this function.
          (FPCore (a b)
           :precision binary64
           (if (<= b 1.08e-72)
             (* (/ PI (* a (* b a))) 0.5)
             (* (/ PI (* (* b b) a)) 0.5)))
          assert(a < b);
          double code(double a, double b) {
          	double tmp;
          	if (b <= 1.08e-72) {
          		tmp = (((double) M_PI) / (a * (b * a))) * 0.5;
          	} else {
          		tmp = (((double) M_PI) / ((b * b) * a)) * 0.5;
          	}
          	return tmp;
          }
          
          assert a < b;
          public static double code(double a, double b) {
          	double tmp;
          	if (b <= 1.08e-72) {
          		tmp = (Math.PI / (a * (b * a))) * 0.5;
          	} else {
          		tmp = (Math.PI / ((b * b) * a)) * 0.5;
          	}
          	return tmp;
          }
          
          [a, b] = sort([a, b])
          def code(a, b):
          	tmp = 0
          	if b <= 1.08e-72:
          		tmp = (math.pi / (a * (b * a))) * 0.5
          	else:
          		tmp = (math.pi / ((b * b) * a)) * 0.5
          	return tmp
          
          a, b = sort([a, b])
          function code(a, b)
          	tmp = 0.0
          	if (b <= 1.08e-72)
          		tmp = Float64(Float64(pi / Float64(a * Float64(b * a))) * 0.5);
          	else
          		tmp = Float64(Float64(pi / Float64(Float64(b * b) * a)) * 0.5);
          	end
          	return tmp
          end
          
          a, b = num2cell(sort([a, b])){:}
          function tmp_2 = code(a, b)
          	tmp = 0.0;
          	if (b <= 1.08e-72)
          		tmp = (pi / (a * (b * a))) * 0.5;
          	else
          		tmp = (pi / ((b * b) * a)) * 0.5;
          	end
          	tmp_2 = tmp;
          end
          
          NOTE: a and b should be sorted in increasing order before calling this function.
          code[a_, b_] := If[LessEqual[b, 1.08e-72], N[(N[(Pi / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(Pi / N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
          
          \begin{array}{l}
          [a, b] = \mathsf{sort}([a, b])\\
          \\
          \begin{array}{l}
          \mathbf{if}\;b \leq 1.08 \cdot 10^{-72}:\\
          \;\;\;\;\frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if b < 1.07999999999999998e-72

            1. Initial program 78.5%

              \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
            2. Taylor expanded in a around inf

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

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

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

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

                \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
              5. lower-*.f64N/A

                \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
              6. pow2N/A

                \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
              7. lift-*.f6479.7

                \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
            4. Applied rewrites79.7%

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

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

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

                \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
              4. lower-*.f64N/A

                \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
              5. *-commutativeN/A

                \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot \frac{1}{2} \]
              6. lower-*.f6491.0

                \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5 \]
            6. Applied rewrites91.0%

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

            if 1.07999999999999998e-72 < b

            1. Initial program 78.7%

              \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
            2. Taylor expanded in a around 0

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

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

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

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

                \[\leadsto \frac{\pi}{a \cdot {b}^{2}} \cdot \frac{1}{2} \]
              5. *-commutativeN/A

                \[\leadsto \frac{\pi}{{b}^{2} \cdot a} \cdot \frac{1}{2} \]
              6. lower-*.f64N/A

                \[\leadsto \frac{\pi}{{b}^{2} \cdot a} \cdot \frac{1}{2} \]
              7. pow2N/A

                \[\leadsto \frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot \frac{1}{2} \]
              8. lift-*.f6477.7

                \[\leadsto \frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5 \]
            4. Applied rewrites77.7%

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

          Alternative 10: 62.8% accurate, 2.4× speedup?

          \[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5 \end{array} \]
          NOTE: a and b should be sorted in increasing order before calling this function.
          (FPCore (a b) :precision binary64 (* (/ PI (* a (* b a))) 0.5))
          assert(a < b);
          double code(double a, double b) {
          	return (((double) M_PI) / (a * (b * a))) * 0.5;
          }
          
          assert a < b;
          public static double code(double a, double b) {
          	return (Math.PI / (a * (b * a))) * 0.5;
          }
          
          [a, b] = sort([a, b])
          def code(a, b):
          	return (math.pi / (a * (b * a))) * 0.5
          
          a, b = sort([a, b])
          function code(a, b)
          	return Float64(Float64(pi / Float64(a * Float64(b * a))) * 0.5)
          end
          
          a, b = num2cell(sort([a, b])){:}
          function tmp = code(a, b)
          	tmp = (pi / (a * (b * a))) * 0.5;
          end
          
          NOTE: a and b should be sorted in increasing order before calling this function.
          code[a_, b_] := N[(N[(Pi / N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
          
          \begin{array}{l}
          [a, b] = \mathsf{sort}([a, b])\\
          \\
          \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5
          \end{array}
          
          Derivation
          1. Initial program 78.6%

            \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
          2. Taylor expanded in a around inf

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

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

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

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

              \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
            5. lower-*.f64N/A

              \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
            6. pow2N/A

              \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
            7. lift-*.f6457.2

              \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
          4. Applied rewrites57.2%

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

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

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

              \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
            4. lower-*.f64N/A

              \[\leadsto \frac{\pi}{a \cdot \left(a \cdot b\right)} \cdot \frac{1}{2} \]
            5. *-commutativeN/A

              \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot \frac{1}{2} \]
            6. lower-*.f6462.8

              \[\leadsto \frac{\pi}{a \cdot \left(b \cdot a\right)} \cdot 0.5 \]
          6. Applied rewrites62.8%

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

          Reproduce

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