NMSE Section 6.1 mentioned, B

Percentage Accurate: 78.3% → 99.7%
Time: 10.9s
Alternatives: 9
Speedup: 2.4×

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.3% 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, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.1% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.32 \cdot 10^{+138}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{a \cdot \left(a \cdot b\right)}\\

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


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

    1. Initial program 46.2%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}{\color{blue}{a \cdot \left(a \cdot b\right)}} \]
      8. lower-*.f6499.9

        \[\leadsto \frac{0.5 \cdot \pi}{a \cdot \color{blue}{\left(a \cdot b\right)}} \]
    5. Simplified99.9%

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

    if -1.32000000000000001e138 < a

    1. Initial program 81.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.5}{\left(a \cdot \color{blue}{\left(b + a\right)}\right) \cdot b} \cdot \pi \]
    10. Applied egg-rr95.6%

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

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

Alternative 3: 71.0% accurate, 2.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.8 \cdot 10^{-60}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{a \cdot \left(a \cdot b\right)}\\

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


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

    1. Initial program 78.1%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}{\color{blue}{a \cdot \left(a \cdot b\right)}} \]
      8. lower-*.f6472.0

        \[\leadsto \frac{0.5 \cdot \pi}{a \cdot \color{blue}{\left(a \cdot b\right)}} \]
    5. Simplified72.0%

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

    if 1.8e-60 < b

    1. Initial program 77.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 inf

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

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

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

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

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

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

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

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

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

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

Alternative 4: 71.0% accurate, 2.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.8 \cdot 10^{-60}:\\
\;\;\;\;\frac{\pi \cdot 0.5}{a \cdot \left(a \cdot b\right)}\\

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


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

    1. Initial program 78.1%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}{\color{blue}{a \cdot \left(a \cdot b\right)}} \]
      8. lower-*.f6472.0

        \[\leadsto \frac{0.5 \cdot \pi}{a \cdot \color{blue}{\left(a \cdot b\right)}} \]
    5. Simplified72.0%

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

    if 1.8e-60 < b

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.5}{a \cdot \color{blue}{\left(b \cdot b\right)}} \cdot \pi \]
    11. Simplified83.5%

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

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

Alternative 5: 71.0% accurate, 2.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.8 \cdot 10^{-60}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(a \cdot b\right)}\\

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


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

    1. Initial program 78.1%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{2} \cdot \mathsf{PI}\left(\right)}{\color{blue}{a \cdot \left(a \cdot b\right)}} \]
      8. lower-*.f6472.0

        \[\leadsto \frac{0.5 \cdot \pi}{a \cdot \color{blue}{\left(a \cdot b\right)}} \]
    5. Simplified72.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \pi \cdot \frac{0.5}{b \cdot \color{blue}{\left(a \cdot a\right)}} \]
    7. Applied egg-rr63.1%

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

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

        \[\leadsto \mathsf{PI}\left(\right) \cdot \frac{\frac{1}{2}}{\color{blue}{\left(b \cdot a\right)} \cdot a} \]
      3. lower-*.f6472.0

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

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

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

        \[\leadsto \pi \cdot \frac{0.5}{\color{blue}{\left(a \cdot b\right)} \cdot a} \]
    9. Applied egg-rr72.0%

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

    if 1.8e-60 < b

    1. Initial program 77.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{0.5}{a \cdot \color{blue}{\left(b \cdot b\right)}} \cdot \pi \]
    11. Simplified83.5%

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

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

Alternative 6: 99.0% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \frac{\pi \cdot 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(Float64(pi * 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[(N[(Pi * 0.5), $MachinePrecision] / N[(N[(a + b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 93.2% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \pi \cdot \frac{0.5}{a \cdot \left(b \cdot \left(a + b\right)\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(a * Float64(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[(a * N[(b * N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 62.5% accurate, 2.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \pi \cdot \frac{0.5}{b \cdot \color{blue}{\left(a \cdot a\right)}} \]
  7. Applied egg-rr55.3%

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

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

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

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

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

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

      \[\leadsto \pi \cdot \frac{0.5}{\color{blue}{\left(a \cdot b\right)} \cdot a} \]
  9. Applied egg-rr61.5%

    \[\leadsto \pi \cdot \frac{0.5}{\color{blue}{\left(a \cdot b\right) \cdot a}} \]
  10. Final simplification61.5%

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

Alternative 9: 56.8% accurate, 2.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \pi \cdot \frac{0.5}{b \cdot \color{blue}{\left(a \cdot a\right)}} \]
  7. Applied egg-rr55.3%

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

Reproduce

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