NMSE Section 6.1 mentioned, B

Percentage Accurate: 78.9% → 99.1%
Time: 6.9s
Alternatives: 7
Speedup: N/A×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 78.9% 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.1% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{a} - \frac{1}{b}\\ t_1 := \left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot t\_0\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{-272}:\\ \;\;\;\;\left(\frac{\frac{\pi}{2}}{b + a} \cdot \frac{1}{b - a}\right) \cdot t\_0\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;\frac{\frac{\pi}{{\left(a \cdot b\right)}^{2}}}{\left({a}^{-1} + {b}^{-1}\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{2} \cdot \left({\left(\left(b + a\right) \cdot \left(b - a\right)\right)}^{-1} \cdot \left({a}^{-1} - {b}^{-1}\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (let* ((t_0 (- (/ 1.0 a) (/ 1.0 b)))
        (t_1 (* (* (/ PI 2.0) (/ 1.0 (- (* b b) (* a a)))) t_0)))
   (if (<= t_1 -5e-272)
     (* (* (/ (/ PI 2.0) (+ b a)) (/ 1.0 (- b a))) t_0)
     (if (<= t_1 0.0)
       (/ (/ PI (pow (* a b) 2.0)) (* (+ (pow a -1.0) (pow b -1.0)) 2.0))
       (*
        (/ PI 2.0)
        (* (pow (* (+ b a) (- b a)) -1.0) (- (pow a -1.0) (pow b -1.0))))))))
double code(double a, double b) {
	double t_0 = (1.0 / a) - (1.0 / b);
	double t_1 = ((((double) M_PI) / 2.0) * (1.0 / ((b * b) - (a * a)))) * t_0;
	double tmp;
	if (t_1 <= -5e-272) {
		tmp = (((((double) M_PI) / 2.0) / (b + a)) * (1.0 / (b - a))) * t_0;
	} else if (t_1 <= 0.0) {
		tmp = (((double) M_PI) / pow((a * b), 2.0)) / ((pow(a, -1.0) + pow(b, -1.0)) * 2.0);
	} else {
		tmp = (((double) M_PI) / 2.0) * (pow(((b + a) * (b - a)), -1.0) * (pow(a, -1.0) - pow(b, -1.0)));
	}
	return tmp;
}
public static double code(double a, double b) {
	double t_0 = (1.0 / a) - (1.0 / b);
	double t_1 = ((Math.PI / 2.0) * (1.0 / ((b * b) - (a * a)))) * t_0;
	double tmp;
	if (t_1 <= -5e-272) {
		tmp = (((Math.PI / 2.0) / (b + a)) * (1.0 / (b - a))) * t_0;
	} else if (t_1 <= 0.0) {
		tmp = (Math.PI / Math.pow((a * b), 2.0)) / ((Math.pow(a, -1.0) + Math.pow(b, -1.0)) * 2.0);
	} else {
		tmp = (Math.PI / 2.0) * (Math.pow(((b + a) * (b - a)), -1.0) * (Math.pow(a, -1.0) - Math.pow(b, -1.0)));
	}
	return tmp;
}
def code(a, b):
	t_0 = (1.0 / a) - (1.0 / b)
	t_1 = ((math.pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * t_0
	tmp = 0
	if t_1 <= -5e-272:
		tmp = (((math.pi / 2.0) / (b + a)) * (1.0 / (b - a))) * t_0
	elif t_1 <= 0.0:
		tmp = (math.pi / math.pow((a * b), 2.0)) / ((math.pow(a, -1.0) + math.pow(b, -1.0)) * 2.0)
	else:
		tmp = (math.pi / 2.0) * (math.pow(((b + a) * (b - a)), -1.0) * (math.pow(a, -1.0) - math.pow(b, -1.0)))
	return tmp
function code(a, b)
	t_0 = Float64(Float64(1.0 / a) - Float64(1.0 / b))
	t_1 = Float64(Float64(Float64(pi / 2.0) * Float64(1.0 / Float64(Float64(b * b) - Float64(a * a)))) * t_0)
	tmp = 0.0
	if (t_1 <= -5e-272)
		tmp = Float64(Float64(Float64(Float64(pi / 2.0) / Float64(b + a)) * Float64(1.0 / Float64(b - a))) * t_0);
	elseif (t_1 <= 0.0)
		tmp = Float64(Float64(pi / (Float64(a * b) ^ 2.0)) / Float64(Float64((a ^ -1.0) + (b ^ -1.0)) * 2.0));
	else
		tmp = Float64(Float64(pi / 2.0) * Float64((Float64(Float64(b + a) * Float64(b - a)) ^ -1.0) * Float64((a ^ -1.0) - (b ^ -1.0))));
	end
	return tmp
end
function tmp_2 = code(a, b)
	t_0 = (1.0 / a) - (1.0 / b);
	t_1 = ((pi / 2.0) * (1.0 / ((b * b) - (a * a)))) * t_0;
	tmp = 0.0;
	if (t_1 <= -5e-272)
		tmp = (((pi / 2.0) / (b + a)) * (1.0 / (b - a))) * t_0;
	elseif (t_1 <= 0.0)
		tmp = (pi / ((a * b) ^ 2.0)) / (((a ^ -1.0) + (b ^ -1.0)) * 2.0);
	else
		tmp = (pi / 2.0) * ((((b + a) * (b - a)) ^ -1.0) * ((a ^ -1.0) - (b ^ -1.0)));
	end
	tmp_2 = tmp;
end
code[a_, b_] := Block[{t$95$0 = N[(N[(1.0 / a), $MachinePrecision] - N[(1.0 / b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(Pi / 2.0), $MachinePrecision] * N[(1.0 / N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-272], N[(N[(N[(N[(Pi / 2.0), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(Pi / N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Power[a, -1.0], $MachinePrecision] + N[Power[b, -1.0], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / 2.0), $MachinePrecision] * N[(N[Power[N[(N[(b + a), $MachinePrecision] * N[(b - a), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision] * N[(N[Power[a, -1.0], $MachinePrecision] - N[Power[b, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{a} - \frac{1}{b}\\
t_1 := \left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{-272}:\\
\;\;\;\;\left(\frac{\frac{\pi}{2}}{b + a} \cdot \frac{1}{b - a}\right) \cdot t\_0\\

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\frac{\pi}{{\left(a \cdot b\right)}^{2}}}{\left({a}^{-1} + {b}^{-1}\right) \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\pi}{2} \cdot \left({\left(\left(b + a\right) \cdot \left(b - a\right)\right)}^{-1} \cdot \left({a}^{-1} - {b}^{-1}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 (/.f64 (PI.f64) #s(literal 2 binary64)) (/.f64 #s(literal 1 binary64) (-.f64 (*.f64 b b) (*.f64 a a)))) (-.f64 (/.f64 #s(literal 1 binary64) a) (/.f64 #s(literal 1 binary64) b))) < -4.99999999999999982e-272

    1. Initial program 96.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\frac{\pi}{2}}{b + a} \cdot \color{blue}{\frac{1}{b - a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      13. lower--.f6499.4

        \[\leadsto \left(\frac{\frac{\pi}{2}}{b + a} \cdot \frac{1}{\color{blue}{b - a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    4. Applied rewrites99.4%

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

    if -4.99999999999999982e-272 < (*.f64 (*.f64 (/.f64 (PI.f64) #s(literal 2 binary64)) (/.f64 #s(literal 1 binary64) (-.f64 (*.f64 b b) (*.f64 a a)))) (-.f64 (/.f64 #s(literal 1 binary64) a) (/.f64 #s(literal 1 binary64) b))) < -0.0

    1. Initial program 73.4%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Add Preprocessing
    3. Applied rewrites60.8%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\pi}{{\color{blue}{\left(a \cdot b\right)}}^{2}}}{\left({a}^{-1} + {b}^{-1}\right) \cdot 2} \]
    6. Applied rewrites99.7%

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

    if -0.0 < (*.f64 (*.f64 (/.f64 (PI.f64) #s(literal 2 binary64)) (/.f64 #s(literal 1 binary64) (-.f64 (*.f64 b b) (*.f64 a a)))) (-.f64 (/.f64 #s(literal 1 binary64) a) (/.f64 #s(literal 1 binary64) b)))

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\pi}{2} \cdot \color{blue}{\left(\frac{1}{b \cdot b - a \cdot a} \cdot \left(\frac{1}{a} - \frac{1}{b}\right)\right)} \]
    4. Applied rewrites99.6%

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

Alternative 2: 91.3% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -3.4 \cdot 10^{+146}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\frac{\pi}{2}}{b + a} \cdot \frac{1}{b - a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b -3.4e+146)
   (*
    a
    (fma
     -0.5
     (/ PI (* a (pow b 3.0)))
     (* 0.5 (+ (/ PI (pow (* a b) 2.0)) (/ PI (pow b 4.0))))))
   (* (* (/ (/ PI 2.0) (+ b a)) (/ 1.0 (- b a))) (- (/ 1.0 a) (/ 1.0 b)))))
double code(double a, double b) {
	double tmp;
	if (b <= -3.4e+146) {
		tmp = a * fma(-0.5, (((double) M_PI) / (a * pow(b, 3.0))), (0.5 * ((((double) M_PI) / pow((a * b), 2.0)) + (((double) M_PI) / pow(b, 4.0)))));
	} else {
		tmp = (((((double) M_PI) / 2.0) / (b + a)) * (1.0 / (b - a))) * ((1.0 / a) - (1.0 / b));
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if (b <= -3.4e+146)
		tmp = Float64(a * fma(-0.5, Float64(pi / Float64(a * (b ^ 3.0))), Float64(0.5 * Float64(Float64(pi / (Float64(a * b) ^ 2.0)) + Float64(pi / (b ^ 4.0))))));
	else
		tmp = Float64(Float64(Float64(Float64(pi / 2.0) / Float64(b + a)) * Float64(1.0 / Float64(b - a))) * Float64(Float64(1.0 / a) - Float64(1.0 / b)));
	end
	return tmp
end
code[a_, b_] := If[LessEqual[b, -3.4e+146], N[(a * N[(-0.5 * N[(Pi / N[(a * N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(Pi / N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(Pi / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(Pi / 2.0), $MachinePrecision] / N[(b + a), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / a), $MachinePrecision] - N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.4 \cdot 10^{+146}:\\
\;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -3.39999999999999991e146

    1. Initial program 53.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
      8. lower-*.f64N/A

        \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
    8. Applied rewrites99.8%

      \[\leadsto a \cdot \color{blue}{\mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)} \]

    if -3.39999999999999991e146 < b

    1. Initial program 85.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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{\frac{\pi}{2}}{b + a} \cdot \color{blue}{\frac{1}{b - a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
      13. lower--.f6492.9

        \[\leadsto \left(\frac{\frac{\pi}{2}}{b + a} \cdot \frac{1}{\color{blue}{b - a}}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    4. Applied rewrites92.9%

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

Alternative 3: 90.7% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.3 \cdot 10^{+144} \lor \neg \left(b \leq 7.2 \cdot 10^{+123}\right):\\ \;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\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} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= b -1.3e+144) (not (<= b 7.2e+123)))
   (*
    a
    (fma
     -0.5
     (/ PI (* a (pow b 3.0)))
     (* 0.5 (+ (/ PI (pow (* a b) 2.0)) (/ PI (pow b 4.0))))))
   (* (* (/ PI 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b)))))
double code(double a, double b) {
	double tmp;
	if ((b <= -1.3e+144) || !(b <= 7.2e+123)) {
		tmp = a * fma(-0.5, (((double) M_PI) / (a * pow(b, 3.0))), (0.5 * ((((double) M_PI) / pow((a * b), 2.0)) + (((double) M_PI) / pow(b, 4.0)))));
	} else {
		tmp = ((((double) M_PI) / 2.0) * (1.0 / ((b * b) - (a * a)))) * ((1.0 / a) - (1.0 / b));
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if ((b <= -1.3e+144) || !(b <= 7.2e+123))
		tmp = Float64(a * fma(-0.5, Float64(pi / Float64(a * (b ^ 3.0))), Float64(0.5 * Float64(Float64(pi / (Float64(a * b) ^ 2.0)) + Float64(pi / (b ^ 4.0))))));
	else
		tmp = 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
	return tmp
end
code[a_, b_] := If[Or[LessEqual[b, -1.3e+144], N[Not[LessEqual[b, 7.2e+123]], $MachinePrecision]], N[(a * N[(-0.5 * N[(Pi / N[(a * N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(Pi / N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(Pi / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.3 \cdot 10^{+144} \lor \neg \left(b \leq 7.2 \cdot 10^{+123}\right):\\
\;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.2999999999999999e144 or 7.19999999999999996e123 < b

    1. Initial program 57.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
      8. lower-*.f64N/A

        \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
    8. Applied rewrites99.8%

      \[\leadsto a \cdot \color{blue}{\mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)} \]

    if -1.2999999999999999e144 < b < 7.19999999999999996e123

    1. Initial program 90.5%

      \[\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right) \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification93.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.3 \cdot 10^{+144} \lor \neg \left(b \leq 7.2 \cdot 10^{+123}\right):\\ \;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\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} \]
  5. Add Preprocessing

Alternative 4: 83.6% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -2.9 \cdot 10^{+89}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(b \cdot \frac{\pi}{{a}^{4}}, 0.5, \frac{\pi}{{a}^{3}} \cdot -0.5\right), b, \frac{\pi}{a \cdot a} \cdot 0.5\right)}{b}\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{+90}:\\ \;\;\;\;\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \frac{\mathsf{fma}\left(\frac{a}{b}, -1, 1\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= a -2.9e+89)
   (/
    (fma
     (fma (* b (/ PI (pow a 4.0))) 0.5 (* (/ PI (pow a 3.0)) -0.5))
     b
     (* (/ PI (* a a)) 0.5))
    b)
   (if (<= a 4.5e+90)
     (*
      (* (/ PI 2.0) (/ 1.0 (- (* b b) (* a a))))
      (/ (fma (/ a b) -1.0 1.0) a))
     (* (/ PI (* (* a a) b)) 0.5))))
double code(double a, double b) {
	double tmp;
	if (a <= -2.9e+89) {
		tmp = fma(fma((b * (((double) M_PI) / pow(a, 4.0))), 0.5, ((((double) M_PI) / pow(a, 3.0)) * -0.5)), b, ((((double) M_PI) / (a * a)) * 0.5)) / b;
	} else if (a <= 4.5e+90) {
		tmp = ((((double) M_PI) / 2.0) * (1.0 / ((b * b) - (a * a)))) * (fma((a / b), -1.0, 1.0) / a);
	} else {
		tmp = (((double) M_PI) / ((a * a) * b)) * 0.5;
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if (a <= -2.9e+89)
		tmp = Float64(fma(fma(Float64(b * Float64(pi / (a ^ 4.0))), 0.5, Float64(Float64(pi / (a ^ 3.0)) * -0.5)), b, Float64(Float64(pi / Float64(a * a)) * 0.5)) / b);
	elseif (a <= 4.5e+90)
		tmp = Float64(Float64(Float64(pi / 2.0) * Float64(1.0 / Float64(Float64(b * b) - Float64(a * a)))) * Float64(fma(Float64(a / b), -1.0, 1.0) / a));
	else
		tmp = Float64(Float64(pi / Float64(Float64(a * a) * b)) * 0.5);
	end
	return tmp
end
code[a_, b_] := If[LessEqual[a, -2.9e+89], N[(N[(N[(N[(b * N[(Pi / N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5 + N[(N[(Pi / N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * b + N[(N[(Pi / N[(a * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], If[LessEqual[a, 4.5e+90], N[(N[(N[(Pi / 2.0), $MachinePrecision] * N[(1.0 / N[(N[(b * b), $MachinePrecision] - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(a / b), $MachinePrecision] * -1.0 + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.9 \cdot 10^{+89}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\mathsf{fma}\left(b \cdot \frac{\pi}{{a}^{4}}, 0.5, \frac{\pi}{{a}^{3}} \cdot -0.5\right), b, \frac{\pi}{a \cdot a} \cdot 0.5\right)}{b}\\

\mathbf{elif}\;a \leq 4.5 \cdot 10^{+90}:\\
\;\;\;\;\left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \frac{\mathsf{fma}\left(\frac{a}{b}, -1, 1\right)}{a}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -2.90000000000000025e89

    1. Initial program 55.8%

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

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

        \[\leadsto \frac{\frac{1}{2} \cdot \frac{\mathsf{PI}\left(\right)}{{a}^{2}} + b \cdot \left(\frac{-1}{2} \cdot \frac{\mathsf{PI}\left(\right)}{{a}^{3}} + \frac{1}{2} \cdot \frac{b \cdot \mathsf{PI}\left(\right)}{{a}^{4}}\right)}{\color{blue}{b}} \]
    5. Applied rewrites82.4%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(b \cdot \frac{\pi}{{a}^{4}}, 0.5, \frac{\pi}{{a}^{3}} \cdot -0.5\right), b, \frac{\pi}{a \cdot a} \cdot 0.5\right)}{b}} \]

    if -2.90000000000000025e89 < a < 4.5e90

    1. Initial program 90.8%

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

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

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

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

        \[\leadsto \left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \frac{\frac{a}{b} \cdot -1 + 1}{a} \]
      4. lower-fma.f64N/A

        \[\leadsto \left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \frac{\mathsf{fma}\left(\frac{a}{b}, -1, 1\right)}{a} \]
      5. lower-/.f6490.8

        \[\leadsto \left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \frac{\mathsf{fma}\left(\frac{a}{b}, -1, 1\right)}{a} \]
    5. Applied rewrites90.8%

      \[\leadsto \left(\frac{\pi}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \color{blue}{\frac{\mathsf{fma}\left(\frac{a}{b}, -1, 1\right)}{a}} \]

    if 4.5e90 < a

    1. Initial program 69.6%

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

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

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

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

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

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
      7. lift-*.f6490.1

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
    5. Applied rewrites90.1%

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

Alternative 5: 78.4% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.7 \cdot 10^{+155}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\ \mathbf{elif}\;b \leq -3.2 \cdot 10^{-26} \lor \neg \left(b \leq 58000000\right):\\ \;\;\;\;\frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (<= b -1.7e+155)
   (*
    a
    (fma
     -0.5
     (/ PI (* a (pow b 3.0)))
     (* 0.5 (+ (/ PI (pow (* a b) 2.0)) (/ PI (pow b 4.0))))))
   (if (or (<= b -3.2e-26) (not (<= b 58000000.0)))
     (* (/ PI (* (* b b) a)) 0.5)
     (* (/ PI (* (* a a) b)) 0.5))))
double code(double a, double b) {
	double tmp;
	if (b <= -1.7e+155) {
		tmp = a * fma(-0.5, (((double) M_PI) / (a * pow(b, 3.0))), (0.5 * ((((double) M_PI) / pow((a * b), 2.0)) + (((double) M_PI) / pow(b, 4.0)))));
	} else if ((b <= -3.2e-26) || !(b <= 58000000.0)) {
		tmp = (((double) M_PI) / ((b * b) * a)) * 0.5;
	} else {
		tmp = (((double) M_PI) / ((a * a) * b)) * 0.5;
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if (b <= -1.7e+155)
		tmp = Float64(a * fma(-0.5, Float64(pi / Float64(a * (b ^ 3.0))), Float64(0.5 * Float64(Float64(pi / (Float64(a * b) ^ 2.0)) + Float64(pi / (b ^ 4.0))))));
	elseif ((b <= -3.2e-26) || !(b <= 58000000.0))
		tmp = Float64(Float64(pi / Float64(Float64(b * b) * a)) * 0.5);
	else
		tmp = Float64(Float64(pi / Float64(Float64(a * a) * b)) * 0.5);
	end
	return tmp
end
code[a_, b_] := If[LessEqual[b, -1.7e+155], N[(a * N[(-0.5 * N[(Pi / N[(a * N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(Pi / N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(Pi / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, -3.2e-26], N[Not[LessEqual[b, 58000000.0]], $MachinePrecision]], N[(N[(Pi / N[(N[(b * b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(Pi / N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.7 \cdot 10^{+155}:\\
\;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\

\mathbf{elif}\;b \leq -3.2 \cdot 10^{-26} \lor \neg \left(b \leq 58000000\right):\\
\;\;\;\;\frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -1.7e155

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
      8. lower-*.f64N/A

        \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
    8. Applied rewrites99.8%

      \[\leadsto a \cdot \color{blue}{\mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)} \]

    if -1.7e155 < b < -3.2000000000000001e-26 or 5.8e7 < b

    1. Initial program 83.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 a around 0

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

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

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

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

        \[\leadsto \frac{\pi}{a \cdot {b}^{2}} \cdot \frac{1}{2} \]
      5. *-commutativeN/A

        \[\leadsto \frac{\pi}{{b}^{2} \cdot a} \cdot \frac{1}{2} \]
      6. lower-*.f64N/A

        \[\leadsto \frac{\pi}{{b}^{2} \cdot a} \cdot \frac{1}{2} \]
      7. pow2N/A

        \[\leadsto \frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot \frac{1}{2} \]
      8. lift-*.f6489.6

        \[\leadsto \frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5 \]
    5. Applied rewrites89.6%

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

    if -3.2000000000000001e-26 < b < 5.8e7

    1. Initial program 87.1%

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

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

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

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

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

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
      7. lift-*.f6472.7

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5 \]
    5. Applied rewrites72.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.7 \cdot 10^{+155}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\ \mathbf{elif}\;b \leq -3.2 \cdot 10^{-26} \lor \neg \left(b \leq 58000000\right):\\ \;\;\;\;\frac{\pi}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 77.2% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{+36} \lor \neg \left(b \leq 6.2 \cdot 10^{+14}\right):\\ \;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (a b)
 :precision binary64
 (if (or (<= b -1e+36) (not (<= b 6.2e+14)))
   (*
    a
    (fma
     -0.5
     (/ PI (* a (pow b 3.0)))
     (* 0.5 (+ (/ PI (pow (* a b) 2.0)) (/ PI (pow b 4.0))))))
   (* (/ PI (* (* a a) b)) 0.5)))
double code(double a, double b) {
	double tmp;
	if ((b <= -1e+36) || !(b <= 6.2e+14)) {
		tmp = a * fma(-0.5, (((double) M_PI) / (a * pow(b, 3.0))), (0.5 * ((((double) M_PI) / pow((a * b), 2.0)) + (((double) M_PI) / pow(b, 4.0)))));
	} else {
		tmp = (((double) M_PI) / ((a * a) * b)) * 0.5;
	}
	return tmp;
}
function code(a, b)
	tmp = 0.0
	if ((b <= -1e+36) || !(b <= 6.2e+14))
		tmp = Float64(a * fma(-0.5, Float64(pi / Float64(a * (b ^ 3.0))), Float64(0.5 * Float64(Float64(pi / (Float64(a * b) ^ 2.0)) + Float64(pi / (b ^ 4.0))))));
	else
		tmp = Float64(Float64(pi / Float64(Float64(a * a) * b)) * 0.5);
	end
	return tmp
end
code[a_, b_] := If[Or[LessEqual[b, -1e+36], N[Not[LessEqual[b, 6.2e+14]], $MachinePrecision]], N[(a * N[(-0.5 * N[(Pi / N[(a * N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(Pi / N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(Pi / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Pi / N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+36} \lor \neg \left(b \leq 6.2 \cdot 10^{+14}\right):\\
\;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < -1.00000000000000004e36 or 6.2e14 < b

    1. Initial program 71.4%

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

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

        \[\leadsto \frac{-1 \cdot \frac{\frac{-1}{2} \cdot \frac{a \cdot \mathsf{PI}\left(\right)}{b} + \frac{1}{2} \cdot \mathsf{PI}\left(\right)}{b} + \frac{1}{2} \cdot \frac{\mathsf{PI}\left(\right)}{a}}{\color{blue}{{b}^{2}}} \]
    5. Applied rewrites84.3%

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
      8. lower-*.f64N/A

        \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
    8. Applied rewrites89.7%

      \[\leadsto a \cdot \color{blue}{\mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)} \]

    if -1.00000000000000004e36 < b < 6.2e14

    1. Initial program 88.2%

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

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

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

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

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

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\pi}{{a}^{2} \cdot b} \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot \frac{1}{2} \]
      7. lift-*.f6470.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{+36} \lor \neg \left(b \leq 6.2 \cdot 10^{+14}\right):\\ \;\;\;\;a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\pi}{\left(a \cdot a\right) \cdot b} \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 46.7% accurate, N/A× speedup?

\[\begin{array}{l} \\ a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right) \end{array} \]
(FPCore (a b)
 :precision binary64
 (*
  a
  (fma
   -0.5
   (/ PI (* a (pow b 3.0)))
   (* 0.5 (+ (/ PI (pow (* a b) 2.0)) (/ PI (pow b 4.0)))))))
double code(double a, double b) {
	return a * fma(-0.5, (((double) M_PI) / (a * pow(b, 3.0))), (0.5 * ((((double) M_PI) / pow((a * b), 2.0)) + (((double) M_PI) / pow(b, 4.0)))));
}
function code(a, b)
	return Float64(a * fma(-0.5, Float64(pi / Float64(a * (b ^ 3.0))), Float64(0.5 * Float64(Float64(pi / (Float64(a * b) ^ 2.0)) + Float64(pi / (b ^ 4.0))))))
end
code[a_, b_] := N[(a * N[(-0.5 * N[(Pi / N[(a * N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(Pi / N[Power[N[(a * b), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(Pi / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
a \cdot \mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)
\end{array}
Derivation
  1. Initial program 80.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 -inf

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

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

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

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

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

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

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

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

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

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

      \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
    8. lower-*.f64N/A

      \[\leadsto a \cdot \mathsf{fma}\left(\frac{-1}{2}, \frac{\pi}{a \cdot {b}^{3}}, \frac{1}{2} \cdot \left(\frac{\mathsf{PI}\left(\right)}{{a}^{2} \cdot {b}^{2}} + \frac{\mathsf{PI}\left(\right)}{{b}^{4}}\right)\right) \]
  8. Applied rewrites47.0%

    \[\leadsto a \cdot \color{blue}{\mathsf{fma}\left(-0.5, \frac{\pi}{a \cdot {b}^{3}}, 0.5 \cdot \left(\frac{\pi}{{\left(a \cdot b\right)}^{2}} + \frac{\pi}{{b}^{4}}\right)\right)} \]
  9. Add Preprocessing

Reproduce

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