NMSE Section 6.1 mentioned, B

Percentage Accurate: 78.7% → 99.7%
Time: 12.1s
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.7% 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{0.5 \cdot \frac{\pi}{b}}{a}}{b + a} \end{array} \]
(FPCore (a b) :precision binary64 (/ (/ (* 0.5 (/ PI b)) a) (+ b a)))
double code(double a, double b) {
	return ((0.5 * (((double) M_PI) / b)) / a) / (b + a);
}
public static double code(double a, double b) {
	return ((0.5 * (Math.PI / b)) / a) / (b + a);
}
def code(a, b):
	return ((0.5 * (math.pi / b)) / a) / (b + a)
function code(a, b)
	return Float64(Float64(Float64(0.5 * Float64(pi / b)) / a) / Float64(b + a))
end
function tmp = code(a, b)
	tmp = ((0.5 * (pi / b)) / a) / (b + a);
end
code[a_, b_] := N[(N[(N[(0.5 * N[(Pi / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 74.8% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.5999999999999999e-77 < a

    1. Initial program 79.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 \frac{\frac{\mathsf{PI}\left(\right)}{2}}{b \cdot b - a \cdot a} \cdot \left(\color{blue}{\frac{1}{a}} - \frac{1}{b}\right) \]
      2. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 74.8% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.39999999999999999e-77 < a

    1. Initial program 79.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 \frac{\frac{\mathsf{PI}\left(\right)}{2}}{b \cdot b - a \cdot a} \cdot \left(\color{blue}{\frac{1}{a}} - \frac{1}{b}\right) \]
      2. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 74.8% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.39999999999999999e-77 < a

    1. Initial program 79.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 \frac{\frac{\mathsf{PI}\left(\right)}{2}}{b \cdot b - a \cdot a} \cdot \left(\color{blue}{\frac{1}{a}} - \frac{1}{b}\right) \]
      2. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, b\right), \left(\frac{\left(\mathsf{neg}\left(-1\right)\right) \cdot b}{\frac{\mathsf{PI}\left(\right)}{a}}\right)\right) \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, b\right), \left(\frac{\mathsf{neg}\left(-1 \cdot b\right)}{\frac{\color{blue}{\mathsf{PI}\left(\right)}}{a}}\right)\right) \]
      18. neg-mul-1N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, b\right), \left(\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(b\right)\right)\right)}{\frac{\mathsf{PI}\left(\right)}{a}}\right)\right) \]
      19. remove-double-negN/A

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

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

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

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

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

Alternative 5: 74.6% accurate, 1.5× speedup?

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

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

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


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

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.3000000000000002e-78 < a

    1. Initial program 79.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 \frac{\frac{\mathsf{PI}\left(\right)}{2}}{b \cdot b - a \cdot a} \cdot \left(\color{blue}{\frac{1}{a}} - \frac{1}{b}\right) \]
      2. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 68.8% accurate, 1.5× speedup?

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

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

\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 a < -5.30000000000000015e-77

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.30000000000000015e-77 < a

    1. Initial program 79.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 \frac{\frac{\mathsf{PI}\left(\right)}{2}}{b \cdot b - a \cdot a} \cdot \left(\color{blue}{\frac{1}{a}} - \frac{1}{b}\right) \]
      2. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 68.7% accurate, 1.5× speedup?

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

\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 a < -6.80000000000000023e-78

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.80000000000000023e-78 < a

    1. Initial program 79.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 \frac{\frac{\mathsf{PI}\left(\right)}{2}}{b \cdot b - a \cdot a} \cdot \left(\color{blue}{\frac{1}{a}} - \frac{1}{b}\right) \]
      2. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 68.7% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -1.5 \cdot 10^{-77}:\\ \;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(b \cdot a\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 (<= a -1.5e-77)
   (* PI (/ 0.5 (* a (* b a))))
   (* PI (/ 0.5 (* a (* b b))))))
double code(double a, double b) {
	double tmp;
	if (a <= -1.5e-77) {
		tmp = ((double) M_PI) * (0.5 / (a * (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 <= -1.5e-77) {
		tmp = Math.PI * (0.5 / (a * (b * a)));
	} else {
		tmp = Math.PI * (0.5 / (a * (b * b)));
	}
	return tmp;
}
def code(a, b):
	tmp = 0
	if a <= -1.5e-77:
		tmp = math.pi * (0.5 / (a * (b * a)))
	else:
		tmp = math.pi * (0.5 / (a * (b * b)))
	return tmp
function code(a, b)
	tmp = 0.0
	if (a <= -1.5e-77)
		tmp = Float64(pi * Float64(0.5 / Float64(a * Float64(b * a))));
	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 (a <= -1.5e-77)
		tmp = pi * (0.5 / (a * (b * a)));
	else
		tmp = pi * (0.5 / (a * (b * b)));
	end
	tmp_2 = tmp;
end
code[a_, b_] := If[LessEqual[a, -1.5e-77], N[(Pi * N[(0.5 / N[(a * N[(b * a), $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}\;a \leq -1.5 \cdot 10^{-77}:\\
\;\;\;\;\pi \cdot \frac{0.5}{a \cdot \left(b \cdot a\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 a < -1.50000000000000008e-77

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.50000000000000008e-77 < a

    1. Initial program 79.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 \frac{\frac{\mathsf{PI}\left(\right)}{2}}{b \cdot b - a \cdot a} \cdot \left(\color{blue}{\frac{1}{a}} - \frac{1}{b}\right) \]
      2. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 61.8% accurate, 2.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\pi \cdot \frac{0.5}{a \cdot \left(a \cdot b\right)}} \]
  8. Final simplification59.3%

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

Reproduce

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