NMSE Section 6.1 mentioned, B

Percentage Accurate: 78.5% → 99.7%
Time: 11.0s
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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.9× speedup?

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

\\
\frac{\frac{\pi}{2 \cdot \left(a + b\right)}}{a \cdot b}
\end{array}
Derivation
  1. Initial program 78.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{+.f64}\left(b, a\right)\right), \left(1 \cdot b - a \cdot 1\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(1, a\right), \mathsf{/.f64}\left(1, b\right)\right)\right) \]
    11. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 74.9% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -5.9 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{\frac{\pi}{2}}{a}}{a \cdot b}\\

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


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

    1. Initial program 86.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. 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-*.f6478.8%

        \[\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. Simplified78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.8999999999999998e-27 < a

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{+.f64}\left(b, a\right)\right), \left(1 \cdot b - a \cdot 1\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(1, a\right), \mathsf{/.f64}\left(1, b\right)\right)\right) \]
      11. *-lft-identityN/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{+.f64}\left(b, a\right)\right), \left(b - a\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(1, a\right), \mathsf{/.f64}\left(1, b\right)\right)\right) \]
      13. --lowering--.f6487.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), \mathsf{*.f64}\left(b, 2\right)\right), \mathsf{*.f64}\left(a, b\right)\right) \]
    9. Simplified70.3%

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

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

Alternative 3: 75.0% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.10000000000000019e-20 < a

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{+.f64}\left(b, a\right)\right), \left(1 \cdot b - a \cdot 1\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(1, a\right), \mathsf{/.f64}\left(1, b\right)\right)\right) \]
      11. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 75.0% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.6000000000000005e-20 < a

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.0% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.10000000000000019e-20 < a

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 75.0% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.5000000000000001e-20 < a

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 99.1% accurate, 1.9× speedup?

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

\\
\frac{\frac{\pi}{2}}{\left(a + b\right) \cdot \left(a \cdot b\right)}
\end{array}
Derivation
  1. Initial program 78.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{+.f64}\left(b, a\right)\right), \left(1 \cdot b - a \cdot 1\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(1, a\right), \mathsf{/.f64}\left(1, b\right)\right)\right) \]
    11. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 99.1% accurate, 1.9× speedup?

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

\\
\pi \cdot \frac{0.5}{\left(a + b\right) \cdot \left(a \cdot b\right)}
\end{array}
Derivation
  1. Initial program 78.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{PI.f64}\left(\right), 2\right), \mathsf{+.f64}\left(b, a\right)\right), \left(1 \cdot b - a \cdot 1\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(1, a\right), \mathsf{/.f64}\left(1, b\right)\right)\right) \]
    11. *-lft-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{0.5}{\left(a \cdot b\right) \cdot \left(a + b\right)} \cdot \pi} \]
  11. Final simplification99.0%

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

Alternative 9: 63.5% accurate, 2.3× speedup?

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

\\
\frac{\pi}{a} \cdot \frac{\frac{0.5}{b}}{a}
\end{array}
Derivation
  1. Initial program 78.3%

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

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

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

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

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

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

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

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

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

      \[\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. Simplified56.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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