NMSE Section 6.1 mentioned, B

Percentage Accurate: 78.4% → 99.6%
Time: 11.2s
Alternatives: 9
Speedup: 1.9×

Specification

?
\[\begin{array}{l} \\ \left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \end{array} \]
(FPCore (a b)
 :precision binary64
 (* (* (/ PI 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))
double code(double a, double b) {
	return ((((double) M_PI) / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
public static double code(double a, double b) {
	return ((Math.PI / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
}
def code(a, b):
	return ((math.pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b))
function code(a, b)
	return Float64(Float64(Float64(pi / 2.0) * Float64(1.0 / Float64(Float64(b * b) - Float64(a * a)))) * Float64(Float64(1.0 / a) - Float64(1.0 / b)))
end
function tmp = code(a, b)
	tmp = ((pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
end
code[a_, b_] := N[(N[(N[(Pi / 2.0), $MachinePrecision] * N[(1.0 / N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] - N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

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

\[\begin{array}{l} \\ \frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2 \cdot \left(b - a\right)}}{a + b} \end{array} \]
(FPCore (a b)
 :precision binary64
 (/ (/ (- (/ PI a) (/ PI b)) (* 2.0 (- b a))) (+ a b)))
double code(double a, double b) {
	return (((((double) M_PI) / a) - (((double) M_PI) / b)) / (2.0 * (b - a))) / (a + b);
}
public static double code(double a, double b) {
	return (((Math.PI / a) - (Math.PI / b)) / (2.0 * (b - a))) / (a + b);
}
def code(a, b):
	return (((math.pi / a) - (math.pi / b)) / (2.0 * (b - a))) / (a + b)
function code(a, b)
	return Float64(Float64(Float64(Float64(pi / a) - Float64(pi / b)) / Float64(2.0 * Float64(b - a))) / Float64(a + b))
end
function tmp = code(a, b)
	tmp = (((pi / a) - (pi / b)) / (2.0 * (b - a))) / (a + b);
end
code[a_, b_] := N[(N[(N[(N[(Pi / a), $MachinePrecision] - N[(Pi / b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2 \cdot \left(b - a\right)}}{a + b}
\end{array}
Derivation
  1. Initial program 75.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. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2 \cdot \left(b - a\right)}}{b + a}} \]
  5. Final simplification99.7%

    \[\leadsto \frac{\frac{\frac{\pi}{a} - \frac{\pi}{b}}{2 \cdot \left(b - a\right)}}{a + b} \]
  6. Add Preprocessing

Alternative 2: 96.9% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -6 \cdot 10^{+107}:\\ \;\;\;\;\frac{\frac{0.5}{a}}{\frac{a \cdot b}{\pi}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{a \cdot \left(a + b\right)}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -6e+107)
   (/ (/ 0.5 a) (/ (* a b) PI))
   (* (/ PI b) (/ 0.5 (* a (+ a b))))))
double code(double a, double b) {
	double tmp;
	if (a <= -6e+107) {
		tmp = (0.5 / a) / ((a * b) / ((double) M_PI));
	} else {
		tmp = (((double) M_PI) / b) * (0.5 / (a * (a + b)));
	}
	return tmp;
}
public static double code(double a, double b) {
	double tmp;
	if (a <= -6e+107) {
		tmp = (0.5 / a) / ((a * b) / Math.PI);
	} else {
		tmp = (Math.PI / b) * (0.5 / (a * (a + b)));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -6e+107:
		tmp = (0.5 / a) / ((a * b) / math.pi)
	else:
		tmp = (math.pi / b) * (0.5 / (a * (a + b)))
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -6e+107)
		tmp = Float64(Float64(0.5 / a) / Float64(Float64(a * b) / pi));
	else
		tmp = Float64(Float64(pi / b) * Float64(0.5 / Float64(a * Float64(a + b))));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -6e+107)
		tmp = (0.5 / a) / ((a * b) / pi);
	else
		tmp = (pi / b) * (0.5 / (a * (a + b)));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -6e+107], N[(N[(0.5 / a), $MachinePrecision] / N[(N[(a * b), $MachinePrecision] / Pi), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / N[(a * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -6 \cdot 10^{+107}:\\
\;\;\;\;\frac{\frac{0.5}{a}}{\frac{a \cdot b}{\pi}}\\

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


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

    1. Initial program 60.6%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Add Preprocessing
    3. 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{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}{\color{blue}{{a}^{2} \cdot b}} \]
      2. /-lowering-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.00000000000000046e107 < a

    1. Initial program 78.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 74.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -7.3 \cdot 10^{-47}:\\ \;\;\;\;\frac{\frac{\pi}{a \cdot b}}{\frac{a}{0.5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\pi}{a} \cdot \frac{0.5}{b}}{b}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -7.3e-47)
   (/ (/ PI (* a b)) (/ a 0.5))
   (/ (* (/ PI a) (/ 0.5 b)) b)))
double code(double a, double b) {
	double tmp;
	if (a <= -7.3e-47) {
		tmp = (((double) M_PI) / (a * b)) / (a / 0.5);
	} else {
		tmp = ((((double) M_PI) / a) * (0.5 / b)) / b;
	}
	return tmp;
}
public static double code(double a, double b) {
	double tmp;
	if (a <= -7.3e-47) {
		tmp = (Math.PI / (a * b)) / (a / 0.5);
	} else {
		tmp = ((Math.PI / a) * (0.5 / b)) / b;
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -7.3e-47:
		tmp = (math.pi / (a * b)) / (a / 0.5)
	else:
		tmp = ((math.pi / a) * (0.5 / b)) / b
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -7.3e-47)
		tmp = Float64(Float64(pi / Float64(a * b)) / Float64(a / 0.5));
	else
		tmp = Float64(Float64(Float64(pi / a) * Float64(0.5 / b)) / b);
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -7.3e-47)
		tmp = (pi / (a * b)) / (a / 0.5);
	else
		tmp = ((pi / a) * (0.5 / b)) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -7.3e-47], N[(N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision] / N[(a / 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.3 \cdot 10^{-47}:\\
\;\;\;\;\frac{\frac{\pi}{a \cdot b}}{\frac{a}{0.5}}\\

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


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

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.30000000000000042e-47 < a

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), a\right)\right), \left({b}^{2}\right)\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), a\right)\right), \left({b}^{2}\right)\right) \]
      7. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 74.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -2.35 \cdot 10^{-45}:\\ \;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\pi}{a} \cdot \frac{0.5}{b}}{b}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -2.35e-45)
   (* (/ 0.5 a) (/ (/ PI a) b))
   (/ (* (/ PI a) (/ 0.5 b)) b)))
double code(double a, double b) {
	double tmp;
	if (a <= -2.35e-45) {
		tmp = (0.5 / a) * ((((double) M_PI) / a) / b);
	} else {
		tmp = ((((double) M_PI) / a) * (0.5 / b)) / b;
	}
	return tmp;
}
public static double code(double a, double b) {
	double tmp;
	if (a <= -2.35e-45) {
		tmp = (0.5 / a) * ((Math.PI / a) / b);
	} else {
		tmp = ((Math.PI / a) * (0.5 / b)) / b;
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -2.35e-45:
		tmp = (0.5 / a) * ((math.pi / a) / b)
	else:
		tmp = ((math.pi / a) * (0.5 / b)) / b
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -2.35e-45)
		tmp = Float64(Float64(0.5 / a) * Float64(Float64(pi / a) / b));
	else
		tmp = Float64(Float64(Float64(pi / a) * Float64(0.5 / b)) / b);
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -2.35e-45)
		tmp = (0.5 / a) * ((pi / a) / b);
	else
		tmp = ((pi / a) * (0.5 / b)) / b;
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -2.35e-45], N[(N[(0.5 / a), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(Pi / a), $MachinePrecision] * N[(0.5 / b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.35 \cdot 10^{-45}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}\\

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


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

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.3499999999999999e-45 < a

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), a\right)\right), \left({b}^{2}\right)\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), a\right)\right), \left({b}^{2}\right)\right) \]
      7. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 74.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -2.45 \cdot 10^{-45}:\\ \;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi \cdot \frac{0.5}{b}}{a \cdot b}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -2.45e-45)
   (* (/ 0.5 a) (/ (/ PI a) b))
   (/ (* PI (/ 0.5 b)) (* a b))))
double code(double a, double b) {
	double tmp;
	if (a <= -2.45e-45) {
		tmp = (0.5 / a) * ((((double) M_PI) / a) / b);
	} else {
		tmp = (((double) M_PI) * (0.5 / b)) / (a * b);
	}
	return tmp;
}
public static double code(double a, double b) {
	double tmp;
	if (a <= -2.45e-45) {
		tmp = (0.5 / a) * ((Math.PI / a) / b);
	} else {
		tmp = (Math.PI * (0.5 / b)) / (a * b);
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -2.45e-45:
		tmp = (0.5 / a) * ((math.pi / a) / b)
	else:
		tmp = (math.pi * (0.5 / b)) / (a * b)
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -2.45e-45)
		tmp = Float64(Float64(0.5 / a) * Float64(Float64(pi / a) / b));
	else
		tmp = Float64(Float64(pi * Float64(0.5 / b)) / Float64(a * b));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -2.45e-45)
		tmp = (0.5 / a) * ((pi / a) / b);
	else
		tmp = (pi * (0.5 / b)) / (a * b);
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -2.45e-45], N[(N[(0.5 / a), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(Pi * N[(0.5 / b), $MachinePrecision]), $MachinePrecision] / N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.45 \cdot 10^{-45}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}\\

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


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

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.4499999999999999e-45 < a

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), a\right)\right), \left({b}^{2}\right)\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), a\right)\right), \left({b}^{2}\right)\right) \]
      7. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 74.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -4.5 \cdot 10^{-47}:\\ \;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{b} \cdot \frac{0.5}{a \cdot b}\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -4.5e-47)
   (* (/ 0.5 a) (/ (/ PI a) b))
   (* (/ PI b) (/ 0.5 (* a b)))))
double code(double a, double b) {
	double tmp;
	if (a <= -4.5e-47) {
		tmp = (0.5 / a) * ((((double) M_PI) / a) / b);
	} else {
		tmp = (((double) M_PI) / b) * (0.5 / (a * b));
	}
	return tmp;
}
public static double code(double a, double b) {
	double tmp;
	if (a <= -4.5e-47) {
		tmp = (0.5 / a) * ((Math.PI / a) / b);
	} else {
		tmp = (Math.PI / b) * (0.5 / (a * b));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -4.5e-47:
		tmp = (0.5 / a) * ((math.pi / a) / b)
	else:
		tmp = (math.pi / b) * (0.5 / (a * b))
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -4.5e-47)
		tmp = Float64(Float64(0.5 / a) * Float64(Float64(pi / a) / b));
	else
		tmp = Float64(Float64(pi / b) * Float64(0.5 / Float64(a * b)));
	end
	return tmp
end
function tmp_2 = code(a, b)
	tmp = 0.0;
	if (a <= -4.5e-47)
		tmp = (0.5 / a) * ((pi / a) / b);
	else
		tmp = (pi / b) * (0.5 / (a * b));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -4.5e-47], N[(N[(0.5 / a), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / b), $MachinePrecision] * N[(0.5 / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.5 \cdot 10^{-47}:\\
\;\;\;\;\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}\\

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


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

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.5e-47 < a

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{PI}\left(\right), a\right)\right), \left({b}^{2}\right)\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), a\right)\right), \left({b}^{2}\right)\right) \]
      7. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 99.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \frac{\frac{\frac{\pi}{b} \cdot 0.5}{a}}{a + b} \end{array} \]
(FPCore (a b) :precision binary64 (/ (/ (* (/ PI b) 0.5) a) (+ a b)))
double code(double a, double b) {
	return (((((double) M_PI) / b) * 0.5) / a) / (a + b);
}
public static double code(double a, double b) {
	return (((Math.PI / b) * 0.5) / a) / (a + b);
}
def code(a, b):
	return (((math.pi / b) * 0.5) / a) / (a + b)
function code(a, b)
	return Float64(Float64(Float64(Float64(pi / b) * 0.5) / a) / Float64(a + b))
end
function tmp = code(a, b)
	tmp = (((pi / b) * 0.5) / a) / (a + b);
end
code[a_, b_] := N[(N[(N[(N[(Pi / b), $MachinePrecision] * 0.5), $MachinePrecision] / a), $MachinePrecision] / N[(a + b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{\frac{\pi}{b} \cdot 0.5}{a}}{a + b}
\end{array}
Derivation
  1. Initial program 75.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. un-div-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 62.8% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b} \end{array} \]
(FPCore (a b) :precision binary64 (* (/ 0.5 a) (/ (/ PI a) b)))
double code(double a, double b) {
	return (0.5 / a) * ((((double) M_PI) / a) / b);
}
public static double code(double a, double b) {
	return (0.5 / a) * ((Math.PI / a) / b);
}
def code(a, b):
	return (0.5 / a) * ((math.pi / a) / b)
function code(a, b)
	return Float64(Float64(0.5 / a) * Float64(Float64(pi / a) / b))
end
function tmp = code(a, b)
	tmp = (0.5 / a) * ((pi / a) / b);
end
code[a_, b_] := N[(N[(0.5 / a), $MachinePrecision] * N[(N[(Pi / a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{0.5}{a} \cdot \frac{\frac{\pi}{a}}{b}
\end{array}
Derivation
  1. Initial program 75.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. 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{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}{\color{blue}{{a}^{2} \cdot b}} \]
    2. /-lowering-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 62.8% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \frac{0.5}{a} \cdot \frac{\pi}{a \cdot b} \end{array} \]
(FPCore (a b) :precision binary64 (* (/ 0.5 a) (/ PI (* a b))))
double code(double a, double b) {
	return (0.5 / a) * (((double) M_PI) / (a * b));
}
public static double code(double a, double b) {
	return (0.5 / a) * (Math.PI / (a * b));
}
def code(a, b):
	return (0.5 / a) * (math.pi / (a * b))
function code(a, b)
	return Float64(Float64(0.5 / a) * Float64(pi / Float64(a * b)))
end
function tmp = code(a, b)
	tmp = (0.5 / a) * (pi / (a * b));
end
code[a_, b_] := N[(N[(0.5 / a), $MachinePrecision] * N[(Pi / N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{0.5}{a} \cdot \frac{\pi}{a \cdot b}
\end{array}
Derivation
  1. Initial program 75.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. 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{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}{\color{blue}{{a}^{2} \cdot b}} \]
    2. /-lowering-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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