NMSE Section 6.1 mentioned, B

Percentage Accurate: 78.4% → 99.3%
Time: 10.0s
Alternatives: 7
Speedup: 1.5×

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 7 alternatives:

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

Initial Program: 78.4% 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.3% accurate, 1.3× speedup?

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

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


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

    1. Initial program 84.9%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(2 \cdot \left(b \cdot \left({a}^{2} + \color{blue}{a \cdot b}\right)\right)\right)\right) \]
      6. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(2 \cdot \left(b \cdot \left(a \cdot a + \color{blue}{a} \cdot b\right)\right)\right)\right) \]
      7. distribute-lft-outN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(2 \cdot \left(\left(b \cdot \left(a + b\right)\right) \cdot \color{blue}{a}\right)\right)\right) \]
      10. distribute-rgt-outN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \left(2 \cdot \left(\left(a \cdot b + b \cdot b\right) \cdot a\right)\right)\right) \]
      11. unpow2N/A

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(a, \color{blue}{\left(2 \cdot \left(a \cdot b\right) + 2 \cdot {b}^{2}\right)}\right)\right) \]
      16. distribute-lft-outN/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(2, \color{blue}{\left(a \cdot b + {b}^{2}\right)}\right)\right)\right) \]
      18. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(2, \left(a \cdot b + b \cdot \color{blue}{b}\right)\right)\right)\right) \]
      19. distribute-rgt-outN/A

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

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

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

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

    if 1.27999999999999995e137 < b

    1. Initial program 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \left(\left(\frac{\frac{1}{2}}{a} + \frac{\frac{-1}{2}}{b}\right) \cdot \frac{1}{b \cdot b - a \cdot a}\right) \]
    4. Applied egg-rr70.0%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \color{blue}{\left({b}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 89.9% accurate, 1.5× speedup?

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

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


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

    1. Initial program 81.8%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. 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-*.f6481.0%

        \[\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. Simplified81.0%

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\frac{1}{\frac{2}{\mathsf{PI}\left(\right)}}}{a}}{a}}{b} \]
      5. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9999999999999999e-47 < a

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \left(\left(\frac{\frac{1}{2}}{a} + \frac{\frac{-1}{2}}{b}\right) \cdot \frac{1}{b \cdot b - a \cdot a}\right) \]
    4. Applied egg-rr83.3%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \color{blue}{\left({b}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

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

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

      \[\leadsto \frac{\pi}{\color{blue}{2 \cdot \left(a \cdot \left(b \cdot b\right)\right)}} \]
    8. Step-by-step derivation
      1. *-un-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 89.8% accurate, 1.5× speedup?

\[\begin{array}{l} [a, b] = \mathsf{sort}([a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \leq -5.6 \cdot 10^{-47}:\\ \;\;\;\;\frac{\frac{\pi}{\frac{a}{0.5}}}{b \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\pi}{b} \cdot \frac{0.5}{a}}{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 -5.6e-47)
   (/ (/ 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 <= -5.6e-47) {
		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 <= -5.6e-47) {
		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 <= -5.6e-47:
		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 <= -5.6e-47)
		tmp = Float64(Float64(pi / Float64(a / 0.5)) / Float64(b * a));
	else
		tmp = Float64(Float64(Float64(pi / b) * Float64(0.5 / a)) / b);
	end
	return tmp
end
a, b = num2cell(sort([a, b])){:}
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -5.6e-47)
		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, -5.6e-47], N[(N[(Pi / N[(a / 0.5), $MachinePrecision]), $MachinePrecision] / N[(b * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.6 \cdot 10^{-47}:\\
\;\;\;\;\frac{\frac{\pi}{\frac{a}{0.5}}}{b \cdot a}\\

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


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

    1. Initial program 81.8%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. 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-*.f6481.0%

        \[\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. Simplified81.0%

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\frac{1}{\frac{2}{\mathsf{PI}\left(\right)}}}{a}}{a}}{b} \]
      5. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.59999999999999986e-47 < a

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \left(\left(\frac{\frac{1}{2}}{a} + \frac{\frac{-1}{2}}{b}\right) \cdot \frac{1}{b \cdot b - a \cdot a}\right) \]
    4. Applied egg-rr83.3%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \color{blue}{\left({b}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 81.8%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. 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-*.f6481.0%

        \[\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. Simplified81.0%

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\frac{1}{\frac{2}{\mathsf{PI}\left(\right)}}}{a}}{a}}{b} \]
      5. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.59999999999999986e-47 < a

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \left(\left(\frac{\frac{1}{2}}{a} + \frac{\frac{-1}{2}}{b}\right) \cdot \frac{1}{b \cdot b - a \cdot a}\right) \]
    4. Applied egg-rr83.3%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \color{blue}{\left({b}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 81.8%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. 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-*.f6481.0%

        \[\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. Simplified81.0%

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\frac{1}{\frac{2}{\mathsf{PI}\left(\right)}}}{a}}{a}}{b} \]
      5. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.5000000000000002e-47 < a

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \left(\left(\frac{\frac{1}{2}}{a} + \frac{\frac{-1}{2}}{b}\right) \cdot \frac{1}{b \cdot b - a \cdot a}\right) \]
    4. Applied egg-rr83.3%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \color{blue}{\left({b}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 89.6% accurate, 1.5× speedup?

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

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


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

    1. Initial program 81.8%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \left(\left(\frac{\frac{1}{2}}{a} + \frac{\frac{-1}{2}}{b}\right) \cdot \frac{1}{b \cdot b - a \cdot a}\right) \]
    4. Applied egg-rr81.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right)\right)\right) \]
    7. Simplified88.8%

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

    if -2.79999999999999993e-47 < a

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \left(\left(\frac{\frac{1}{2}}{a} + \frac{\frac{-1}{2}}{b}\right) \cdot \frac{1}{b \cdot b - a \cdot a}\right) \]
    4. Applied egg-rr83.3%

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \color{blue}{\left({b}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 62.4% accurate, 2.3× speedup?

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

    \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \color{blue}{\left({b}^{2}\right)}\right)\right)\right) \]
    3. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \left(b \cdot \color{blue}{b}\right)\right)\right)\right) \]
    4. *-lowering-*.f6454.0%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(2, \mathsf{*.f64}\left(a, \mathsf{*.f64}\left(b, \color{blue}{b}\right)\right)\right)\right) \]
  7. Simplified54.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{0.5}{b} \cdot \frac{\pi}{a \cdot b}} \]
  10. Final simplification59.3%

    \[\leadsto \frac{0.5}{b} \cdot \frac{\pi}{b \cdot a} \]
  11. Add Preprocessing

Reproduce

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