NMSE Section 6.1 mentioned, B

Percentage Accurate: 77.6% → 99.7%
Time: 11.3s
Alternatives: 9
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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 77.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.7% accurate, 1.9× speedup?

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

    \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
  4. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
  5. Step-by-step derivation
    1. associate-/l/N/A

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\left(\left(\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}\right) \cdot \frac{\frac{1}{2}}{b - a}\right), \color{blue}{\left(b + a\right)}\right) \]
  6. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{\frac{b - a}{0.5}}}{a + b}} \]
  7. Taylor expanded in a around 0

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right), b\right), \mathsf{+.f64}\left(a, b\right)\right) \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), a\right)\right), b\right), \mathsf{+.f64}\left(a, b\right)\right) \]
    6. PI-lowering-PI.f6499.7%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right), b\right), \mathsf{+.f64}\left(a, b\right)\right) \]
  9. Simplified99.7%

    \[\leadsto \frac{\color{blue}{\frac{0.5 \cdot \frac{\pi}{a}}{b}}}{a + b} \]
  10. Add Preprocessing

Alternative 2: 91.3% accurate, 1.3× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -6.5 \cdot 10^{-27}:\\ \;\;\;\;\frac{\frac{-0.5 \cdot \frac{\pi}{b}}{a}}{b - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{a \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 (<= a -6.5e-27)
   (/ (/ (* -0.5 (/ PI b)) a) (- b a))
   (* (/ PI b) (/ 0.5 (* a b)))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (a <= -6.5e-27) {
		tmp = ((-0.5 * (((double) M_PI) / b)) / a) / (b - a);
	} else {
		tmp = (((double) M_PI) / b) * (0.5 / (a * b));
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (a <= -6.5e-27) {
		tmp = ((-0.5 * (Math.PI / b)) / a) / (b - a);
	} else {
		tmp = (Math.PI / b) * (0.5 / (a * b));
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if a <= -6.5e-27:
		tmp = ((-0.5 * (math.pi / b)) / a) / (b - a)
	else:
		tmp = (math.pi / b) * (0.5 / (a * b))
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (a <= -6.5e-27)
		tmp = Float64(Float64(Float64(-0.5 * Float64(pi / b)) / a) / Float64(b - a));
	else
		tmp = Float64(Float64(pi / b) * Float64(0.5 / Float64(a * b)));
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -6.5e-27)
		tmp = ((-0.5 * (pi / b)) / a) / (b - a);
	else
		tmp = (pi / b) * (0.5 / (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, -6.5e-27], N[(N[(N[(-0.5 * N[(Pi / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.5 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{-0.5 \cdot \frac{\pi}{b}}{a}}{b - a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -6.50000000000000025e-27

    1. Initial program 76.3%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
    5. Taylor expanded in a around inf

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{-1}{2} \cdot \frac{\mathsf{PI}\left(\right)}{b}}{a}\right), \mathsf{\_.f64}\left(b, a\right)\right) \]
      5. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), b\right)\right), a\right), \mathsf{\_.f64}\left(b, a\right)\right) \]
      8. PI-lowering-PI.f6494.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right)\right), a\right), \mathsf{\_.f64}\left(b, a\right)\right) \]
    7. Simplified94.1%

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

    if -6.50000000000000025e-27 < a

    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. Add Preprocessing
    3. Step-by-step derivation
      1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
    5. Taylor expanded in a around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      10. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left({b}^{2}\right)\right)\right), a\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left(b \cdot b\right)\right)\right), a\right) \]
      13. *-lowering-*.f6468.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right)\right), a\right) \]
    7. Simplified68.7%

      \[\leadsto \color{blue}{\frac{\pi \cdot \frac{0.5}{b \cdot b}}{a}} \]
    8. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \color{blue}{a}\right)\right) \]
      7. PI-lowering-PI.f6468.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \color{blue}{\frac{0.5}{b \cdot b} \cdot \frac{\pi}{a}} \]
    10. Step-by-step derivation
      1. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(a \cdot b\right)}\right)\right) \]
      12. *-lowering-*.f6476.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    11. Applied egg-rr76.7%

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

Alternative 3: 89.9% accurate, 1.5× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -4.6 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{\frac{\frac{\pi}{a}}{2}}{b}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{a \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 (<= a -4.6e-26)
   (/ (/ (/ (/ PI a) 2.0) b) a)
   (* (/ PI b) (/ 0.5 (* a b)))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (a <= -4.6e-26) {
		tmp = (((((double) M_PI) / a) / 2.0) / b) / a;
	} else {
		tmp = (((double) M_PI) / b) * (0.5 / (a * b));
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (a <= -4.6e-26) {
		tmp = (((Math.PI / a) / 2.0) / b) / a;
	} else {
		tmp = (Math.PI / b) * (0.5 / (a * b));
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if a <= -4.6e-26:
		tmp = (((math.pi / a) / 2.0) / b) / a
	else:
		tmp = (math.pi / b) * (0.5 / (a * b))
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (a <= -4.6e-26)
		tmp = Float64(Float64(Float64(Float64(pi / a) / 2.0) / b) / a);
	else
		tmp = Float64(Float64(pi / b) * Float64(0.5 / Float64(a * b)));
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -4.6e-26)
		tmp = (((pi / a) / 2.0) / b) / a;
	else
		tmp = (pi / b) * (0.5 / (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, -4.6e-26], N[(N[(N[(N[(Pi / a), $MachinePrecision] / 2.0), $MachinePrecision] / b), $MachinePrecision] / a), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{\frac{\frac{\pi}{a}}{2}}{b}}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -4.60000000000000018e-26

    1. Initial program 76.3%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2}}\right)\right), b\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      6. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(a \cdot a\right)\right)\right), b\right) \]
      8. *-lowering-*.f6471.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(a, a\right)\right)\right), b\right) \]
    5. Simplified71.1%

      \[\leadsto \color{blue}{\frac{0.5 \cdot \frac{\pi}{a \cdot a}}{b}} \]
    6. Step-by-step derivation
      1. associate-/l*N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \left(a \cdot b\right)\right), \frac{1}{2}\right) \]
      10. *-lowering-*.f6483.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \mathsf{*.f64}\left(a, b\right)\right), \frac{1}{2}\right) \]
    7. Applied egg-rr83.0%

      \[\leadsto \color{blue}{\frac{\frac{\pi}{a}}{a \cdot b} \cdot 0.5} \]
    8. Step-by-step derivation
      1. associate-*l/N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{\frac{\mathsf{PI}\left(\right)}{a}}{2}\right), b\right), a\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{\mathsf{PI}\left(\right)}{a}\right), 2\right), b\right), a\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI}\left(\right), a\right), 2\right), b\right), a\right) \]
      10. PI-lowering-PI.f6483.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), 2\right), b\right), a\right) \]
    9. Applied egg-rr83.1%

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

    if -4.60000000000000018e-26 < a

    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. Add Preprocessing
    3. Step-by-step derivation
      1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
    5. Taylor expanded in a around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      10. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left({b}^{2}\right)\right)\right), a\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left(b \cdot b\right)\right)\right), a\right) \]
      13. *-lowering-*.f6468.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right)\right), a\right) \]
    7. Simplified68.7%

      \[\leadsto \color{blue}{\frac{\pi \cdot \frac{0.5}{b \cdot b}}{a}} \]
    8. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \color{blue}{a}\right)\right) \]
      7. PI-lowering-PI.f6468.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \color{blue}{\frac{0.5}{b \cdot b} \cdot \frac{\pi}{a}} \]
    10. Step-by-step derivation
      1. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(a \cdot b\right)}\right)\right) \]
      12. *-lowering-*.f6476.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    11. Applied egg-rr76.7%

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

Alternative 4: 89.8% accurate, 1.5× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -2.5 \cdot 10^{-25}:\\ \;\;\;\;0.5 \cdot \frac{\frac{\pi}{a}}{a \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{a \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 (<= a -2.5e-25)
   (* 0.5 (/ (/ PI a) (* a b)))
   (* (/ PI b) (/ 0.5 (* a b)))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (a <= -2.5e-25) {
		tmp = 0.5 * ((((double) M_PI) / a) / (a * b));
	} else {
		tmp = (((double) M_PI) / b) * (0.5 / (a * b));
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (a <= -2.5e-25) {
		tmp = 0.5 * ((Math.PI / a) / (a * b));
	} else {
		tmp = (Math.PI / b) * (0.5 / (a * b));
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if a <= -2.5e-25:
		tmp = 0.5 * ((math.pi / a) / (a * b))
	else:
		tmp = (math.pi / b) * (0.5 / (a * b))
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (a <= -2.5e-25)
		tmp = Float64(0.5 * Float64(Float64(pi / a) / Float64(a * b)));
	else
		tmp = Float64(Float64(pi / b) * Float64(0.5 / Float64(a * b)));
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -2.5e-25)
		tmp = 0.5 * ((pi / a) / (a * b));
	else
		tmp = (pi / b) * (0.5 / (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, -2.5e-25], N[(0.5 * N[(N[(Pi / a), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.5 \cdot 10^{-25}:\\
\;\;\;\;0.5 \cdot \frac{\frac{\pi}{a}}{a \cdot b}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.49999999999999981e-25

    1. Initial program 76.3%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2}}\right)\right), b\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      6. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(a \cdot a\right)\right)\right), b\right) \]
      8. *-lowering-*.f6471.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(a, a\right)\right)\right), b\right) \]
    5. Simplified71.1%

      \[\leadsto \color{blue}{\frac{0.5 \cdot \frac{\pi}{a \cdot a}}{b}} \]
    6. Step-by-step derivation
      1. associate-/l*N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \left(a \cdot b\right)\right), \frac{1}{2}\right) \]
      10. *-lowering-*.f6483.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \mathsf{*.f64}\left(a, b\right)\right), \frac{1}{2}\right) \]
    7. Applied egg-rr83.0%

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

    if -2.49999999999999981e-25 < a

    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. Add Preprocessing
    3. Step-by-step derivation
      1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
    5. Taylor expanded in a around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      10. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left({b}^{2}\right)\right)\right), a\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left(b \cdot b\right)\right)\right), a\right) \]
      13. *-lowering-*.f6468.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right)\right), a\right) \]
    7. Simplified68.7%

      \[\leadsto \color{blue}{\frac{\pi \cdot \frac{0.5}{b \cdot b}}{a}} \]
    8. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \color{blue}{a}\right)\right) \]
      7. PI-lowering-PI.f6468.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \color{blue}{\frac{0.5}{b \cdot b} \cdot \frac{\pi}{a}} \]
    10. Step-by-step derivation
      1. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(a \cdot b\right)}\right)\right) \]
      12. *-lowering-*.f6476.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    11. Applied egg-rr76.7%

      \[\leadsto \color{blue}{\frac{\pi}{b} \cdot \frac{0.5}{a \cdot b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -2.5 \cdot 10^{-25}:\\ \;\;\;\;0.5 \cdot \frac{\frac{\pi}{a}}{a \cdot b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{a \cdot b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 89.8% accurate, 1.5× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -4.6 \cdot 10^{-26}:\\ \;\;\;\;\frac{\pi}{a} \cdot \frac{\frac{0.5}{b}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{a \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 (<= a -4.6e-26)
   (* (/ PI a) (/ (/ 0.5 b) a))
   (* (/ PI b) (/ 0.5 (* a b)))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (a <= -4.6e-26) {
		tmp = (((double) M_PI) / a) * ((0.5 / b) / a);
	} else {
		tmp = (((double) M_PI) / b) * (0.5 / (a * b));
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (a <= -4.6e-26) {
		tmp = (Math.PI / a) * ((0.5 / b) / a);
	} else {
		tmp = (Math.PI / b) * (0.5 / (a * b));
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if a <= -4.6e-26:
		tmp = (math.pi / a) * ((0.5 / b) / a)
	else:
		tmp = (math.pi / b) * (0.5 / (a * b))
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (a <= -4.6e-26)
		tmp = Float64(Float64(pi / a) * Float64(Float64(0.5 / b) / a));
	else
		tmp = Float64(Float64(pi / b) * Float64(0.5 / Float64(a * b)));
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -4.6e-26)
		tmp = (pi / a) * ((0.5 / b) / a);
	else
		tmp = (pi / b) * (0.5 / (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, -4.6e-26], N[(N[(Pi / a), $MachinePrecision] * N[(N[(0.5 / b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.6 \cdot 10^{-26}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{\frac{0.5}{b}}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -4.60000000000000018e-26

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{PI}\left(\right) \cdot \frac{\frac{-1}{2}}{a} + \mathsf{PI}\left(\right) \cdot \frac{\frac{1}{2}}{b}\right), \left({a}^{2}\right)\right) \]
      8. distribute-lft-outN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\frac{-1}{2}}{a} + \frac{\frac{1}{2}}{b}\right)\right), \left({a}^{2}\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{+.f64}\left(\left(\frac{\frac{-1}{2}}{a}\right), \left(\frac{\frac{1}{2}}{b}\right)\right)\right), \left({a}^{2}\right)\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{-1}{2}, a\right), \left(\frac{\frac{1}{2}}{b}\right)\right)\right), \left({a}^{2}\right)\right) \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{-1}{2}, a\right), \mathsf{/.f64}\left(\frac{1}{2}, b\right)\right)\right), \left({a}^{2}\right)\right) \]
      14. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{-1}{2}, a\right), \mathsf{/.f64}\left(\frac{1}{2}, b\right)\right)\right), \left(a \cdot \color{blue}{a}\right)\right) \]
      15. *-lowering-*.f6467.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{-1}{2}, a\right), \mathsf{/.f64}\left(\frac{1}{2}, b\right)\right)\right), \mathsf{*.f64}\left(a, \color{blue}{a}\right)\right) \]
    5. Simplified67.7%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\left(\frac{\frac{-1}{2}}{a}\right), \left(\frac{\frac{1}{2}}{b}\right)\right), a\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
      6. /-lowering-/.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{-1}{2}, a\right), \mathsf{/.f64}\left(\frac{1}{2}, b\right)\right), a\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{-1}{2}, a\right), \mathsf{/.f64}\left(\frac{1}{2}, b\right)\right), a\right), \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \color{blue}{a}\right)\right) \]
      9. PI-lowering-PI.f6479.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(\mathsf{/.f64}\left(\frac{-1}{2}, a\right), \mathsf{/.f64}\left(\frac{1}{2}, b\right)\right), a\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
    7. Applied egg-rr79.6%

      \[\leadsto \color{blue}{\frac{\frac{-0.5}{a} + \frac{0.5}{b}}{a} \cdot \frac{\pi}{a}} \]
    8. Taylor expanded in a around inf

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{\frac{1}{2}}{b}\right), a\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
      7. /-lowering-/.f6483.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, b\right), a\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
    10. Simplified83.0%

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

    if -4.60000000000000018e-26 < a

    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. Add Preprocessing
    3. Step-by-step derivation
      1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
    5. Taylor expanded in a around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      10. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left({b}^{2}\right)\right)\right), a\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left(b \cdot b\right)\right)\right), a\right) \]
      13. *-lowering-*.f6468.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right)\right), a\right) \]
    7. Simplified68.7%

      \[\leadsto \color{blue}{\frac{\pi \cdot \frac{0.5}{b \cdot b}}{a}} \]
    8. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \color{blue}{a}\right)\right) \]
      7. PI-lowering-PI.f6468.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \color{blue}{\frac{0.5}{b \cdot b} \cdot \frac{\pi}{a}} \]
    10. Step-by-step derivation
      1. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(a \cdot b\right)}\right)\right) \]
      12. *-lowering-*.f6476.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    11. Applied egg-rr76.7%

      \[\leadsto \color{blue}{\frac{\pi}{b} \cdot \frac{0.5}{a \cdot b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -4.6 \cdot 10^{-26}:\\ \;\;\;\;\frac{\pi}{a} \cdot \frac{\frac{0.5}{b}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{a \cdot b}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 89.8% accurate, 1.5× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} t_0 := \frac{0.5}{a \cdot b}\\ \mathbf{if}\;a \leq -7.2 \cdot 10^{-26}:\\ \;\;\;\;\frac{\pi}{a} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{b} \cdot t\_0\\ \end{array} \end{array} \]
NOTE: a and b should be sorted in increasing order before calling this function.
(FPCore (a b)
 :precision binary64
 (let* ((t_0 (/ 0.5 (* a b))))
   (if (<= a -7.2e-26) (* (/ PI a) t_0) (* (/ PI b) t_0))))
assert(a < b);
double code(double a, double b) {
	double t_0 = 0.5 / (a * b);
	double tmp;
	if (a <= -7.2e-26) {
		tmp = (((double) M_PI) / a) * t_0;
	} else {
		tmp = (((double) M_PI) / b) * t_0;
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double t_0 = 0.5 / (a * b);
	double tmp;
	if (a <= -7.2e-26) {
		tmp = (Math.PI / a) * t_0;
	} else {
		tmp = (Math.PI / b) * t_0;
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	t_0 = 0.5 / (a * b)
	tmp = 0
	if a <= -7.2e-26:
		tmp = (math.pi / a) * t_0
	else:
		tmp = (math.pi / b) * t_0
	return tmp
a, b = sort([a, b])
function code(a, b)
	t_0 = Float64(0.5 / Float64(a * b))
	tmp = 0.0
	if (a <= -7.2e-26)
		tmp = Float64(Float64(pi / a) * t_0);
	else
		tmp = Float64(Float64(pi / b) * t_0);
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	t_0 = 0.5 / (a * b);
	tmp = 0.0;
	if (a <= -7.2e-26)
		tmp = (pi / a) * t_0;
	else
		tmp = (pi / b) * t_0;
	end
	tmp_2 = tmp;
end
NOTE: a and b should be sorted in increasing order before calling this function.
code[a_, b_] := Block[{t$95$0 = N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -7.2e-26], N[(N[(Pi / a), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := \frac{0.5}{a \cdot b}\\
\mathbf{if}\;a \leq -7.2 \cdot 10^{-26}:\\
\;\;\;\;\frac{\pi}{a} \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{\pi}{b} \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -7.2000000000000003e-26

    1. Initial program 76.3%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2}}\right)\right), b\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      6. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(a \cdot a\right)\right)\right), b\right) \]
      8. *-lowering-*.f6471.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(a, a\right)\right)\right), b\right) \]
    5. Simplified71.1%

      \[\leadsto \color{blue}{\frac{0.5 \cdot \frac{\pi}{a \cdot a}}{b}} \]
    6. Step-by-step derivation
      1. associate-/l*N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \left(a \cdot b\right)\right), \frac{1}{2}\right) \]
      10. *-lowering-*.f6483.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \mathsf{*.f64}\left(a, b\right)\right), \frac{1}{2}\right) \]
    7. Applied egg-rr83.0%

      \[\leadsto \color{blue}{\frac{\frac{\pi}{a}}{a \cdot b} \cdot 0.5} \]
    8. Step-by-step derivation
      1. associate-*l/N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(a \cdot b\right)}\right)\right) \]
      7. *-lowering-*.f6483.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    9. Applied egg-rr83.1%

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

    if -7.2000000000000003e-26 < a

    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. Add Preprocessing
    3. Step-by-step derivation
      1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
    5. Taylor expanded in a around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      10. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left({b}^{2}\right)\right)\right), a\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left(b \cdot b\right)\right)\right), a\right) \]
      13. *-lowering-*.f6468.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right)\right), a\right) \]
    7. Simplified68.7%

      \[\leadsto \color{blue}{\frac{\pi \cdot \frac{0.5}{b \cdot b}}{a}} \]
    8. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \color{blue}{a}\right)\right) \]
      7. PI-lowering-PI.f6468.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \color{blue}{\frac{0.5}{b \cdot b} \cdot \frac{\pi}{a}} \]
    10. Step-by-step derivation
      1. frac-timesN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(a \cdot b\right)}\right)\right) \]
      12. *-lowering-*.f6476.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    11. Applied egg-rr76.7%

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

Alternative 7: 89.8% accurate, 1.5× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -1.6 \cdot 10^{-25}:\\ \;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{a \cdot b}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{\pi}{b}}{a \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 (<= a -1.6e-25)
   (* (/ PI a) (/ 0.5 (* a b)))
   (* 0.5 (/ (/ PI b) (* a b)))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (a <= -1.6e-25) {
		tmp = (((double) M_PI) / a) * (0.5 / (a * b));
	} else {
		tmp = 0.5 * ((((double) M_PI) / b) / (a * b));
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (a <= -1.6e-25) {
		tmp = (Math.PI / a) * (0.5 / (a * b));
	} else {
		tmp = 0.5 * ((Math.PI / b) / (a * b));
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if a <= -1.6e-25:
		tmp = (math.pi / a) * (0.5 / (a * b))
	else:
		tmp = 0.5 * ((math.pi / b) / (a * b))
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (a <= -1.6e-25)
		tmp = Float64(Float64(pi / a) * Float64(0.5 / Float64(a * b)));
	else
		tmp = Float64(0.5 * Float64(Float64(pi / b) / 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.6e-25)
		tmp = (pi / a) * (0.5 / (a * b));
	else
		tmp = 0.5 * ((pi / b) / (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.6e-25], N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(Pi / b), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{-25}:\\
\;\;\;\;\frac{\pi}{a} \cdot \frac{0.5}{a \cdot b}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -1.6000000000000001e-25

    1. Initial program 76.3%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2}}\right)\right), b\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      6. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(a \cdot a\right)\right)\right), b\right) \]
      8. *-lowering-*.f6471.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(a, a\right)\right)\right), b\right) \]
    5. Simplified71.1%

      \[\leadsto \color{blue}{\frac{0.5 \cdot \frac{\pi}{a \cdot a}}{b}} \]
    6. Step-by-step derivation
      1. associate-/l*N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \left(a \cdot b\right)\right), \frac{1}{2}\right) \]
      10. *-lowering-*.f6483.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \mathsf{*.f64}\left(a, b\right)\right), \frac{1}{2}\right) \]
    7. Applied egg-rr83.0%

      \[\leadsto \color{blue}{\frac{\frac{\pi}{a}}{a \cdot b} \cdot 0.5} \]
    8. Step-by-step derivation
      1. associate-*l/N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(a \cdot b\right)}\right)\right) \]
      7. *-lowering-*.f6483.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    9. Applied egg-rr83.1%

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

    if -1.6000000000000001e-25 < a

    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. Add Preprocessing
    3. Step-by-step derivation
      1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
    5. Taylor expanded in a around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      10. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left({b}^{2}\right)\right)\right), a\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left(b \cdot b\right)\right)\right), a\right) \]
      13. *-lowering-*.f6468.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right)\right), a\right) \]
    7. Simplified68.7%

      \[\leadsto \color{blue}{\frac{\pi \cdot \frac{0.5}{b \cdot b}}{a}} \]
    8. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \color{blue}{a}\right)\right) \]
      7. PI-lowering-PI.f6468.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \color{blue}{\frac{0.5}{b \cdot b} \cdot \frac{\pi}{a}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \left(a \cdot b\right)\right)\right) \]
      12. *-lowering-*.f6476.7%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    11. Applied egg-rr76.7%

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

Alternative 8: 89.6% accurate, 1.5× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -2.3 \cdot 10^{-25}:\\ \;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(a \cdot b\right)}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{\frac{\pi}{b}}{a \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 (<= a -2.3e-25)
   (* PI (/ 0.5 (* a (* a b))))
   (* 0.5 (/ (/ PI b) (* a b)))))
assert(a < b);
double code(double a, double b) {
	double tmp;
	if (a <= -2.3e-25) {
		tmp = ((double) M_PI) * (0.5 / (a * (a * b)));
	} else {
		tmp = 0.5 * ((((double) M_PI) / b) / (a * b));
	}
	return tmp;
}
assert a < b;
public static double code(double a, double b) {
	double tmp;
	if (a <= -2.3e-25) {
		tmp = Math.PI * (0.5 / (a * (a * b)));
	} else {
		tmp = 0.5 * ((Math.PI / b) / (a * b));
	}
	return tmp;
}
[a, b] = sort([a, b])
def code(a, b):
	tmp = 0
	if a <= -2.3e-25:
		tmp = math.pi * (0.5 / (a * (a * b)))
	else:
		tmp = 0.5 * ((math.pi / b) / (a * b))
	return tmp
a, b = sort([a, b])
function code(a, b)
	tmp = 0.0
	if (a <= -2.3e-25)
		tmp = Float64(pi * Float64(0.5 / Float64(a * Float64(a * b))));
	else
		tmp = Float64(0.5 * Float64(Float64(pi / b) / Float64(a * b)));
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -2.3e-25)
		tmp = pi * (0.5 / (a * (a * b)));
	else
		tmp = 0.5 * ((pi / b) / (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, -2.3e-25], N[(Pi * N[(0.5 / N[(a * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(Pi / b), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.3 \cdot 10^{-25}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(a \cdot b\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -2.2999999999999999e-25

    1. Initial program 76.3%

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2}}\right)\right), b\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      6. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left({a}^{2}\right)\right)\right), b\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(a \cdot a\right)\right)\right), b\right) \]
      8. *-lowering-*.f6471.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(a, a\right)\right)\right), b\right) \]
    5. Simplified71.1%

      \[\leadsto \color{blue}{\frac{0.5 \cdot \frac{\pi}{a \cdot a}}{b}} \]
    6. Step-by-step derivation
      1. associate-/l*N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \left(a \cdot b\right)\right), \frac{1}{2}\right) \]
      10. *-lowering-*.f6483.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right), \mathsf{*.f64}\left(a, b\right)\right), \frac{1}{2}\right) \]
    7. Applied egg-rr83.0%

      \[\leadsto \color{blue}{\frac{\frac{\pi}{a}}{a \cdot b} \cdot 0.5} \]
    8. Step-by-step derivation
      1. associate-/l/N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{2}\right), \mathsf{*.f64}\left(a, \color{blue}{\left(a \cdot b\right)}\right)\right) \]
      8. *-lowering-*.f6484.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \frac{1}{2}\right), \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    9. Applied egg-rr84.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, b\right)\right)\right), \mathsf{PI}\left(\right)\right) \]
      7. PI-lowering-PI.f6484.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(a, b\right)\right)\right), \mathsf{PI.f64}\left(\right)\right) \]
    11. Applied egg-rr84.2%

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

    if -2.2999999999999999e-25 < a

    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. Add Preprocessing
    3. Step-by-step derivation
      1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
    5. Taylor expanded in a around 0

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      10. PI-lowering-PI.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left({b}^{2}\right)\right)\right), a\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left(b \cdot b\right)\right)\right), a\right) \]
      13. *-lowering-*.f6468.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right)\right), a\right) \]
    7. Simplified68.7%

      \[\leadsto \color{blue}{\frac{\pi \cdot \frac{0.5}{b \cdot b}}{a}} \]
    8. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \color{blue}{a}\right)\right) \]
      7. PI-lowering-PI.f6468.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
    9. Applied egg-rr68.7%

      \[\leadsto \color{blue}{\frac{0.5}{b \cdot b} \cdot \frac{\pi}{a}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \left(a \cdot b\right)\right)\right) \]
      12. *-lowering-*.f6476.7%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
    11. Applied egg-rr76.7%

      \[\leadsto \color{blue}{0.5 \cdot \frac{\frac{\pi}{b}}{a \cdot b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.5%

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

Alternative 9: 63.1% accurate, 2.3× speedup?

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

    \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\mathsf{PI}\left(\right)}{a} - \frac{\mathsf{PI}\left(\right)}{b}}{2}}{b + a}\right), \color{blue}{\left(1 \cdot b - a \cdot 1\right)}\right) \]
  4. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2}}{b + a}}{b - a}} \]
  5. Taylor expanded in a around 0

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
    10. PI-lowering-PI.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \left(\frac{\frac{1}{2}}{{b}^{2}}\right)\right), a\right) \]
    11. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left({b}^{2}\right)\right)\right), a\right) \]
    12. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \left(b \cdot b\right)\right)\right), a\right) \]
    13. *-lowering-*.f6463.1%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right)\right), a\right) \]
  7. Simplified63.1%

    \[\leadsto \color{blue}{\frac{\pi \cdot \frac{0.5}{b \cdot b}}{a}} \]
  8. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \left(\frac{\mathsf{PI}\left(\right)}{a}\right)\right) \]
    6. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI}\left(\right), \color{blue}{a}\right)\right) \]
    7. PI-lowering-PI.f6463.1%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(b, b\right)\right), \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), a\right)\right) \]
  9. Applied egg-rr63.1%

    \[\leadsto \color{blue}{\frac{0.5}{b \cdot b} \cdot \frac{\pi}{a}} \]
  10. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \left(a \cdot b\right)\right)\right) \]
    12. *-lowering-*.f6469.2%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), b\right), \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right) \]
  11. Applied egg-rr69.2%

    \[\leadsto \color{blue}{0.5 \cdot \frac{\frac{\pi}{b}}{a \cdot b}} \]
  12. Add Preprocessing

Reproduce

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