Complex division, imag part

Percentage Accurate: 61.1% → 82.3%
Time: 8.7s
Alternatives: 12
Speedup: 1.5×

Specification

?
\[\begin{array}{l} \\ \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\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 12 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: 61.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d):
	return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d)
	return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function tmp = code(a, b, c, d)
	tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}

Alternative 1: 82.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -1.05 \cdot 10^{+62}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{d \cdot \left(-a\right)}{t\_0}\right)\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-101}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\ \mathbf{elif}\;d \leq 4 \cdot 10^{+88}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot t\_0}, \frac{-d}{t\_0}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d d (* c c))) (t_1 (/ (fma c (/ b d) (- a)) d)))
   (if (<= d -1.05e+62)
     t_1
     (if (<= d -5.2e-104)
       (fma (/ c t_0) b (/ (* d (- a)) t_0))
       (if (<= d 3e-101)
         (/ (fma (- d) (/ a c) b) c)
         (if (<= d 4e+88) (* a (fma b (/ c (* a t_0)) (/ (- d) t_0))) t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, d, (c * c));
	double t_1 = fma(c, (b / d), -a) / d;
	double tmp;
	if (d <= -1.05e+62) {
		tmp = t_1;
	} else if (d <= -5.2e-104) {
		tmp = fma((c / t_0), b, ((d * -a) / t_0));
	} else if (d <= 3e-101) {
		tmp = fma(-d, (a / c), b) / c;
	} else if (d <= 4e+88) {
		tmp = a * fma(b, (c / (a * t_0)), (-d / t_0));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, d, Float64(c * c))
	t_1 = Float64(fma(c, Float64(b / d), Float64(-a)) / d)
	tmp = 0.0
	if (d <= -1.05e+62)
		tmp = t_1;
	elseif (d <= -5.2e-104)
		tmp = fma(Float64(c / t_0), b, Float64(Float64(d * Float64(-a)) / t_0));
	elseif (d <= 3e-101)
		tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c);
	elseif (d <= 4e+88)
		tmp = Float64(a * fma(b, Float64(c / Float64(a * t_0)), Float64(Float64(-d) / t_0)));
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.05e+62], t$95$1, If[LessEqual[d, -5.2e-104], N[(N[(c / t$95$0), $MachinePrecision] * b + N[(N[(d * (-a)), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3e-101], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 4e+88], N[(a * N[(b * N[(c / N[(a * t$95$0), $MachinePrecision]), $MachinePrecision] + N[((-d) / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+62}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{d \cdot \left(-a\right)}{t\_0}\right)\\

\mathbf{elif}\;d \leq 3 \cdot 10^{-101}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\

\mathbf{elif}\;d \leq 4 \cdot 10^{+88}:\\
\;\;\;\;a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot t\_0}, \frac{-d}{t\_0}\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.05e62 or 3.99999999999999984e88 < d

    1. Initial program 40.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + \left(\mathsf{neg}\left(a\right)\right)}{d} \]
      11. mul-1-negN/A

        \[\leadsto \frac{c \cdot \frac{b}{d} + \color{blue}{-1 \cdot a}}{d} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
      15. lower-neg.f6486.7

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{-a}\right)}{d} \]
    5. Applied rewrites86.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}} \]

    if -1.05e62 < d < -5.20000000000000005e-104

    1. Initial program 80.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot c} - a \cdot d}{c \cdot c + d \cdot d} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - \color{blue}{a \cdot d}}{c \cdot c + d \cdot d} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c} + d \cdot d} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + \color{blue}{d \cdot d}} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c + d \cdot d}} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      7. sub-negN/A

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

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

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

        \[\leadsto \color{blue}{\frac{c}{c \cdot c + d \cdot d} \cdot b} + \left(\mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{c \cdot c + d \cdot d}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right)} \]
      12. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{c}{c \cdot c + d \cdot d}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      13. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{c \cdot c + d \cdot d}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      14. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{d \cdot d + c \cdot c}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      15. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{d \cdot d} + c \cdot c}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      16. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      17. distribute-neg-frac2N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}, b, \color{blue}{\frac{a \cdot d}{\mathsf{neg}\left(\left(c \cdot c + d \cdot d\right)\right)}}\right) \]
    4. Applied rewrites83.6%

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

    if -5.20000000000000005e-104 < d < 3.0000000000000003e-101

    1. Initial program 69.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6491.2

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
    5. Applied rewrites91.2%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{b + \left(\mathsf{neg}\left(\frac{d \cdot a}{c}\right)\right)}}{c} \]
      4. +-commutativeN/A

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

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

        \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{c}\right)\right) + b}{c} \]
      7. associate-/l*N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{c}}\right)\right) + b}{c} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{c}} + b}{c} \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), \frac{a}{c}, b\right)}}{c} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(d\right)}, \frac{a}{c}, b\right)}{c} \]
      11. lower-/.f6491.2

        \[\leadsto \frac{\mathsf{fma}\left(-d, \color{blue}{\frac{a}{c}}, b\right)}{c} \]
    7. Applied rewrites91.2%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}}{c} \]

    if 3.0000000000000003e-101 < d < 3.99999999999999984e88

    1. Initial program 83.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot c} - a \cdot d}{c \cdot c + d \cdot d} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - \color{blue}{a \cdot d}}{c \cdot c + d \cdot d} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c} + d \cdot d} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + \color{blue}{d \cdot d}} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c + d \cdot d}} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      7. sub-negN/A

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

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

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

        \[\leadsto \color{blue}{\frac{c}{c \cdot c + d \cdot d} \cdot b} + \left(\mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{c \cdot c + d \cdot d}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right)} \]
      12. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{c}{c \cdot c + d \cdot d}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      13. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{c \cdot c + d \cdot d}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      14. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{d \cdot d + c \cdot c}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      15. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{d \cdot d} + c \cdot c}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      16. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      17. distribute-neg-frac2N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}, b, \color{blue}{\frac{a \cdot d}{\mathsf{neg}\left(\left(c \cdot c + d \cdot d\right)\right)}}\right) \]
    4. Applied rewrites84.0%

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \color{blue}{\left({d}^{2} + {c}^{2}\right)}}, -1 \cdot \frac{d}{{c}^{2} + {d}^{2}}\right) \]
      8. unpow2N/A

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

        \[\leadsto a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}}, -1 \cdot \frac{d}{{c}^{2} + {d}^{2}}\right) \]
      10. unpow2N/A

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

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

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

        \[\leadsto a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \mathsf{fma}\left(d, d, c \cdot c\right)}, \color{blue}{\frac{-1 \cdot d}{{c}^{2} + {d}^{2}}}\right) \]
      14. mul-1-negN/A

        \[\leadsto a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{\mathsf{neg}\left(d\right)}}{{c}^{2} + {d}^{2}}\right) \]
      15. lower-neg.f64N/A

        \[\leadsto a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\color{blue}{\mathsf{neg}\left(d\right)}}{{c}^{2} + {d}^{2}}\right) \]
      16. +-commutativeN/A

        \[\leadsto a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\mathsf{neg}\left(d\right)}{\color{blue}{{d}^{2} + {c}^{2}}}\right) \]
      17. unpow2N/A

        \[\leadsto a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\mathsf{neg}\left(d\right)}{\color{blue}{d \cdot d} + {c}^{2}}\right) \]
      18. lower-fma.f64N/A

        \[\leadsto a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{\mathsf{neg}\left(d\right)}{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}}\right) \]
    7. Applied rewrites86.8%

      \[\leadsto \color{blue}{a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{-d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification87.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.05 \cdot 10^{+62}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}, b, \frac{d \cdot \left(-a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)\\ \mathbf{elif}\;d \leq 3 \cdot 10^{-101}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\ \mathbf{elif}\;d \leq 4 \cdot 10^{+88}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(b, \frac{c}{a \cdot \mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{-d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 82.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -1.05 \cdot 10^{+62}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{d \cdot \left(-a\right)}{t\_0}\right)\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-101}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+88}:\\ \;\;\;\;\mathsf{fma}\left(-d, \frac{a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d d (* c c))) (t_1 (/ (fma c (/ b d) (- a)) d)))
   (if (<= d -1.05e+62)
     t_1
     (if (<= d -5.2e-104)
       (fma (/ c t_0) b (/ (* d (- a)) t_0))
       (if (<= d 2.4e-101)
         (/ (fma (- d) (/ a c) b) c)
         (if (<= d 2.7e+88) (fma (- d) (/ a t_0) (/ (* c b) t_0)) t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, d, (c * c));
	double t_1 = fma(c, (b / d), -a) / d;
	double tmp;
	if (d <= -1.05e+62) {
		tmp = t_1;
	} else if (d <= -5.2e-104) {
		tmp = fma((c / t_0), b, ((d * -a) / t_0));
	} else if (d <= 2.4e-101) {
		tmp = fma(-d, (a / c), b) / c;
	} else if (d <= 2.7e+88) {
		tmp = fma(-d, (a / t_0), ((c * b) / t_0));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, d, Float64(c * c))
	t_1 = Float64(fma(c, Float64(b / d), Float64(-a)) / d)
	tmp = 0.0
	if (d <= -1.05e+62)
		tmp = t_1;
	elseif (d <= -5.2e-104)
		tmp = fma(Float64(c / t_0), b, Float64(Float64(d * Float64(-a)) / t_0));
	elseif (d <= 2.4e-101)
		tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c);
	elseif (d <= 2.7e+88)
		tmp = fma(Float64(-d), Float64(a / t_0), Float64(Float64(c * b) / t_0));
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.05e+62], t$95$1, If[LessEqual[d, -5.2e-104], N[(N[(c / t$95$0), $MachinePrecision] * b + N[(N[(d * (-a)), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.4e-101], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.7e+88], N[((-d) * N[(a / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+62}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_0}, b, \frac{d \cdot \left(-a\right)}{t\_0}\right)\\

\mathbf{elif}\;d \leq 2.4 \cdot 10^{-101}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\

\mathbf{elif}\;d \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;\mathsf{fma}\left(-d, \frac{a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.05e62 or 2.70000000000000016e88 < d

    1. Initial program 40.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + \left(\mathsf{neg}\left(a\right)\right)}{d} \]
      11. mul-1-negN/A

        \[\leadsto \frac{c \cdot \frac{b}{d} + \color{blue}{-1 \cdot a}}{d} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
      15. lower-neg.f6486.7

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{-a}\right)}{d} \]
    5. Applied rewrites86.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}} \]

    if -1.05e62 < d < -5.20000000000000005e-104

    1. Initial program 80.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot c} - a \cdot d}{c \cdot c + d \cdot d} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - \color{blue}{a \cdot d}}{c \cdot c + d \cdot d} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c} + d \cdot d} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + \color{blue}{d \cdot d}} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c + d \cdot d}} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      7. sub-negN/A

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

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

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

        \[\leadsto \color{blue}{\frac{c}{c \cdot c + d \cdot d} \cdot b} + \left(\mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      11. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{c \cdot c + d \cdot d}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right)} \]
      12. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{c}{c \cdot c + d \cdot d}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      13. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{c \cdot c + d \cdot d}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      14. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{d \cdot d + c \cdot c}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      15. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{d \cdot d} + c \cdot c}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      16. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}, b, \mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right) \]
      17. distribute-neg-frac2N/A

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}, b, \color{blue}{\frac{a \cdot d}{\mathsf{neg}\left(\left(c \cdot c + d \cdot d\right)\right)}}\right) \]
    4. Applied rewrites83.6%

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

    if -5.20000000000000005e-104 < d < 2.4e-101

    1. Initial program 69.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6491.2

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
    5. Applied rewrites91.2%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{b + \left(\mathsf{neg}\left(\frac{d \cdot a}{c}\right)\right)}}{c} \]
      4. +-commutativeN/A

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

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

        \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{c}\right)\right) + b}{c} \]
      7. associate-/l*N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{c}}\right)\right) + b}{c} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{c}} + b}{c} \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), \frac{a}{c}, b\right)}}{c} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(d\right)}, \frac{a}{c}, b\right)}{c} \]
      11. lower-/.f6491.2

        \[\leadsto \frac{\mathsf{fma}\left(-d, \color{blue}{\frac{a}{c}}, b\right)}{c} \]
    7. Applied rewrites91.2%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}}{c} \]

    if 2.4e-101 < d < 2.70000000000000016e88

    1. Initial program 83.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot c} - a \cdot d}{c \cdot c + d \cdot d} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - \color{blue}{a \cdot d}}{c \cdot c + d \cdot d} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c} + d \cdot d} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + \color{blue}{d \cdot d}} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c + d \cdot d}} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      7. sub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(\mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right)} \]
      8. +-commutativeN/A

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

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

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{c \cdot c + d \cdot d}\right)\right) + \frac{b \cdot c}{c \cdot c + d \cdot d} \]
      11. associate-/l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{c \cdot c + d \cdot d}}\right)\right) + \frac{b \cdot c}{c \cdot c + d \cdot d} \]
      12. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{c \cdot c + d \cdot d}} + \frac{b \cdot c}{c \cdot c + d \cdot d} \]
      13. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), \frac{a}{c \cdot c + d \cdot d}, \frac{b \cdot c}{c \cdot c + d \cdot d}\right)} \]
    4. Applied rewrites85.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-d, \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{c \cdot b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification87.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.05 \cdot 10^{+62}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}, b, \frac{d \cdot \left(-a\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-101}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+88}:\\ \;\;\;\;\mathsf{fma}\left(-d, \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{c \cdot b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ t_1 := \mathsf{fma}\left(-d, \frac{a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\ t_2 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -3.6 \cdot 10^{+62}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;d \leq -2.8 \cdot 10^{-97}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-101}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+88}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d d (* c c)))
        (t_1 (fma (- d) (/ a t_0) (/ (* c b) t_0)))
        (t_2 (/ (fma c (/ b d) (- a)) d)))
   (if (<= d -3.6e+62)
     t_2
     (if (<= d -2.8e-97)
       t_1
       (if (<= d 2.4e-101)
         (/ (fma (- d) (/ a c) b) c)
         (if (<= d 2.7e+88) t_1 t_2))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, d, (c * c));
	double t_1 = fma(-d, (a / t_0), ((c * b) / t_0));
	double t_2 = fma(c, (b / d), -a) / d;
	double tmp;
	if (d <= -3.6e+62) {
		tmp = t_2;
	} else if (d <= -2.8e-97) {
		tmp = t_1;
	} else if (d <= 2.4e-101) {
		tmp = fma(-d, (a / c), b) / c;
	} else if (d <= 2.7e+88) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, d, Float64(c * c))
	t_1 = fma(Float64(-d), Float64(a / t_0), Float64(Float64(c * b) / t_0))
	t_2 = Float64(fma(c, Float64(b / d), Float64(-a)) / d)
	tmp = 0.0
	if (d <= -3.6e+62)
		tmp = t_2;
	elseif (d <= -2.8e-97)
		tmp = t_1;
	elseif (d <= 2.4e-101)
		tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c);
	elseif (d <= 2.7e+88)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-d) * N[(a / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3.6e+62], t$95$2, If[LessEqual[d, -2.8e-97], t$95$1, If[LessEqual[d, 2.4e-101], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.7e+88], t$95$1, t$95$2]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \mathsf{fma}\left(-d, \frac{a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\
t_2 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -3.6 \cdot 10^{+62}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;d \leq -2.8 \cdot 10^{-97}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;d \leq 2.4 \cdot 10^{-101}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\

\mathbf{elif}\;d \leq 2.7 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.6e62 or 2.70000000000000016e88 < d

    1. Initial program 40.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + \left(\mathsf{neg}\left(a\right)\right)}{d} \]
      11. mul-1-negN/A

        \[\leadsto \frac{c \cdot \frac{b}{d} + \color{blue}{-1 \cdot a}}{d} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
      15. lower-neg.f6486.7

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{-a}\right)}{d} \]
    5. Applied rewrites86.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}} \]

    if -3.6e62 < d < -2.8000000000000002e-97 or 2.4e-101 < d < 2.70000000000000016e88

    1. Initial program 81.5%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot c} - a \cdot d}{c \cdot c + d \cdot d} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - \color{blue}{a \cdot d}}{c \cdot c + d \cdot d} \]
      3. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c} + d \cdot d} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + \color{blue}{d \cdot d}} \]
      5. lift-+.f64N/A

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{c \cdot c + d \cdot d}} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      7. sub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(\mathsf{neg}\left(\frac{a \cdot d}{c \cdot c + d \cdot d}\right)\right)} \]
      8. +-commutativeN/A

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

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

        \[\leadsto \left(\mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{c \cdot c + d \cdot d}\right)\right) + \frac{b \cdot c}{c \cdot c + d \cdot d} \]
      11. associate-/l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{c \cdot c + d \cdot d}}\right)\right) + \frac{b \cdot c}{c \cdot c + d \cdot d} \]
      12. distribute-lft-neg-inN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{c \cdot c + d \cdot d}} + \frac{b \cdot c}{c \cdot c + d \cdot d} \]
      13. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), \frac{a}{c \cdot c + d \cdot d}, \frac{b \cdot c}{c \cdot c + d \cdot d}\right)} \]
    4. Applied rewrites83.8%

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

    if -2.8000000000000002e-97 < d < 2.4e-101

    1. Initial program 70.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6490.5

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
    5. Applied rewrites90.5%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{b + \left(\mathsf{neg}\left(\frac{d \cdot a}{c}\right)\right)}}{c} \]
      4. +-commutativeN/A

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

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

        \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{c}\right)\right) + b}{c} \]
      7. associate-/l*N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{c}}\right)\right) + b}{c} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{c}} + b}{c} \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), \frac{a}{c}, b\right)}}{c} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(d\right)}, \frac{a}{c}, b\right)}{c} \]
      11. lower-/.f6490.5

        \[\leadsto \frac{\mathsf{fma}\left(-d, \color{blue}{\frac{a}{c}}, b\right)}{c} \]
    7. Applied rewrites90.5%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}}{c} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 4: 82.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -9.2 \cdot 10^{+61}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-102}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{+78}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
        (t_1 (/ (fma c (/ b d) (- a)) d)))
   (if (<= d -9.2e+61)
     t_1
     (if (<= d -5.2e-104)
       t_0
       (if (<= d 2.6e-102)
         (/ (fma (- d) (/ a c) b) c)
         (if (<= d 3.2e+78) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = fma(c, (b / d), -a) / d;
	double tmp;
	if (d <= -9.2e+61) {
		tmp = t_1;
	} else if (d <= -5.2e-104) {
		tmp = t_0;
	} else if (d <= 2.6e-102) {
		tmp = fma(-d, (a / c), b) / c;
	} else if (d <= 3.2e+78) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(fma(c, Float64(b / d), Float64(-a)) / d)
	tmp = 0.0
	if (d <= -9.2e+61)
		tmp = t_1;
	elseif (d <= -5.2e-104)
		tmp = t_0;
	elseif (d <= 2.6e-102)
		tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c);
	elseif (d <= 3.2e+78)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -9.2e+61], t$95$1, If[LessEqual[d, -5.2e-104], t$95$0, If[LessEqual[d, 2.6e-102], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.2e+78], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -9.2 \cdot 10^{+61}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 2.6 \cdot 10^{-102}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\

\mathbf{elif}\;d \leq 3.2 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -9.1999999999999998e61 or 3.19999999999999994e78 < d

    1. Initial program 40.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + \left(\mathsf{neg}\left(a\right)\right)}{d} \]
      11. mul-1-negN/A

        \[\leadsto \frac{c \cdot \frac{b}{d} + \color{blue}{-1 \cdot a}}{d} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
      15. lower-neg.f6486.7

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{-a}\right)}{d} \]
    5. Applied rewrites86.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}} \]

    if -9.1999999999999998e61 < d < -5.20000000000000005e-104 or 2.59999999999999986e-102 < d < 3.19999999999999994e78

    1. Initial program 82.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing

    if -5.20000000000000005e-104 < d < 2.59999999999999986e-102

    1. Initial program 69.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6491.2

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
    5. Applied rewrites91.2%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{b + \left(\mathsf{neg}\left(\frac{d \cdot a}{c}\right)\right)}}{c} \]
      4. +-commutativeN/A

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

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

        \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{c}\right)\right) + b}{c} \]
      7. associate-/l*N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{c}}\right)\right) + b}{c} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{c}} + b}{c} \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), \frac{a}{c}, b\right)}}{c} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(d\right)}, \frac{a}{c}, b\right)}{c} \]
      11. lower-/.f6491.2

        \[\leadsto \frac{\mathsf{fma}\left(-d, \color{blue}{\frac{a}{c}}, b\right)}{c} \]
    7. Applied rewrites91.2%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}}{c} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9.2 \cdot 10^{+61}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{-104}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-102}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{+78}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 64.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\ \;\;\;\;\frac{-1}{\frac{d}{a}}\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{-67}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{+88}:\\ \;\;\;\;a \cdot \frac{-d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{-d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -5.3e+45)
   (/ -1.0 (/ d a))
   (if (<= d 6.5e-67)
     (/ b c)
     (if (<= d 3.8e+88) (* a (/ (- d) (fma c c (* d d)))) (/ a (- d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -5.3e+45) {
		tmp = -1.0 / (d / a);
	} else if (d <= 6.5e-67) {
		tmp = b / c;
	} else if (d <= 3.8e+88) {
		tmp = a * (-d / fma(c, c, (d * d)));
	} else {
		tmp = a / -d;
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -5.3e+45)
		tmp = Float64(-1.0 / Float64(d / a));
	elseif (d <= 6.5e-67)
		tmp = Float64(b / c);
	elseif (d <= 3.8e+88)
		tmp = Float64(a * Float64(Float64(-d) / fma(c, c, Float64(d * d))));
	else
		tmp = Float64(a / Float64(-d));
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.3e+45], N[(-1.0 / N[(d / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.5e-67], N[(b / c), $MachinePrecision], If[LessEqual[d, 3.8e+88], N[(a * N[((-d) / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\
\;\;\;\;\frac{-1}{\frac{d}{a}}\\

\mathbf{elif}\;d \leq 6.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{elif}\;d \leq 3.8 \cdot 10^{+88}:\\
\;\;\;\;a \cdot \frac{-d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -5.29999999999999991e45

    1. Initial program 42.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

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

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(c, b, \frac{c \cdot \left(c \cdot a\right)}{d}\right)}{d} - a}{d}} \]
    5. Taylor expanded in c around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot a}}{d} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
      2. lower-neg.f6472.5

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Applied rewrites72.5%

      \[\leadsto \frac{\color{blue}{-a}}{d} \]
    8. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a\right)\right)\right)}{\mathsf{neg}\left(d\right)}} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      4. div-invN/A

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

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

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

        \[\leadsto \color{blue}{a \cdot \frac{1}{\mathsf{neg}\left(d\right)}} \]
      8. metadata-evalN/A

        \[\leadsto a \cdot \frac{\color{blue}{\mathsf{neg}\left(-1\right)}}{\mathsf{neg}\left(d\right)} \]
      9. frac-2negN/A

        \[\leadsto a \cdot \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto a \cdot \frac{\mathsf{neg}\left(\color{blue}{1}\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)} \]
      11. metadata-evalN/A

        \[\leadsto a \cdot \frac{\color{blue}{-1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)} \]
      12. lift-neg.f64N/A

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

        \[\leadsto a \cdot \frac{-1}{\color{blue}{d}} \]
      14. lower-/.f6472.3

        \[\leadsto a \cdot \color{blue}{\frac{-1}{d}} \]
    9. Applied rewrites72.3%

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

        \[\leadsto \color{blue}{\frac{a \cdot -1}{d}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{d}{a \cdot -1}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{-1 \cdot a}}} \]
      4. neg-mul-1N/A

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{\mathsf{neg}\left(a\right)}}} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{\mathsf{neg}\left(a\right)}}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{d}{\mathsf{neg}\left(a\right)}}} \]
      7. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\frac{d}{\mathsf{neg}\left(a\right)}\right)}} \]
      8. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{-1}}{\mathsf{neg}\left(\frac{d}{\mathsf{neg}\left(a\right)}\right)} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-1}{\mathsf{neg}\left(\frac{d}{\mathsf{neg}\left(a\right)}\right)}} \]
      10. lift-/.f64N/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\color{blue}{\frac{d}{\mathsf{neg}\left(a\right)}}\right)} \]
      11. lift-neg.f64N/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\frac{d}{\color{blue}{\mathsf{neg}\left(a\right)}}\right)} \]
      12. distribute-frac-neg2N/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{d}{a}\right)\right)}\right)} \]
      13. remove-double-negN/A

        \[\leadsto \frac{-1}{\color{blue}{\frac{d}{a}}} \]
      14. lower-/.f6473.2

        \[\leadsto \frac{-1}{\color{blue}{\frac{d}{a}}} \]
    11. Applied rewrites73.2%

      \[\leadsto \color{blue}{\frac{-1}{\frac{d}{a}}} \]

    if -5.29999999999999991e45 < d < 6.4999999999999997e-67

    1. Initial program 73.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f6467.4

        \[\leadsto \color{blue}{\frac{b}{c}} \]
    5. Applied rewrites67.4%

      \[\leadsto \color{blue}{\frac{b}{c}} \]

    if 6.4999999999999997e-67 < d < 3.7999999999999997e88

    1. Initial program 84.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2} + {d}^{2}}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{a \cdot d}{{c}^{2} + {d}^{2}}\right)} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \color{blue}{\frac{a \cdot d}{\mathsf{neg}\left(\left({c}^{2} + {d}^{2}\right)\right)}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{a \cdot d}{\mathsf{neg}\left(\left({c}^{2} + {d}^{2}\right)\right)}} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{d \cdot a}}{\mathsf{neg}\left(\left({c}^{2} + {d}^{2}\right)\right)} \]
      5. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{d \cdot a}}{\mathsf{neg}\left(\left({c}^{2} + {d}^{2}\right)\right)} \]
      6. lower-neg.f64N/A

        \[\leadsto \frac{d \cdot a}{\color{blue}{\mathsf{neg}\left(\left({c}^{2} + {d}^{2}\right)\right)}} \]
      7. +-commutativeN/A

        \[\leadsto \frac{d \cdot a}{\mathsf{neg}\left(\color{blue}{\left({d}^{2} + {c}^{2}\right)}\right)} \]
      8. unpow2N/A

        \[\leadsto \frac{d \cdot a}{\mathsf{neg}\left(\left(\color{blue}{d \cdot d} + {c}^{2}\right)\right)} \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{d \cdot a}{\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}\right)} \]
      10. unpow2N/A

        \[\leadsto \frac{d \cdot a}{\mathsf{neg}\left(\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)\right)} \]
      11. lower-*.f6473.7

        \[\leadsto \frac{d \cdot a}{-\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)} \]
    5. Applied rewrites73.7%

      \[\leadsto \color{blue}{\frac{d \cdot a}{-\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{a \cdot d}{\mathsf{neg}\left(\left(d \cdot d + \color{blue}{c \cdot c}\right)\right)} \]
      3. lift-fma.f64N/A

        \[\leadsto \frac{a \cdot d}{\mathsf{neg}\left(\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)} \]
      4. lift-neg.f64N/A

        \[\leadsto \frac{a \cdot d}{\color{blue}{\mathsf{neg}\left(\mathsf{fma}\left(d, d, c \cdot c\right)\right)}} \]
      5. associate-/l*N/A

        \[\leadsto \color{blue}{a \cdot \frac{d}{\mathsf{neg}\left(\mathsf{fma}\left(d, d, c \cdot c\right)\right)}} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{a \cdot \frac{d}{\mathsf{neg}\left(\mathsf{fma}\left(d, d, c \cdot c\right)\right)}} \]
      7. frac-2negN/A

        \[\leadsto a \cdot \color{blue}{\frac{\mathsf{neg}\left(d\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\mathsf{fma}\left(d, d, c \cdot c\right)\right)\right)\right)}} \]
      8. lift-neg.f64N/A

        \[\leadsto a \cdot \frac{\mathsf{neg}\left(d\right)}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\mathsf{fma}\left(d, d, c \cdot c\right)\right)\right)}\right)} \]
      9. remove-double-negN/A

        \[\leadsto a \cdot \frac{\mathsf{neg}\left(d\right)}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      10. lower-/.f64N/A

        \[\leadsto a \cdot \color{blue}{\frac{\mathsf{neg}\left(d\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      11. lower-neg.f6477.5

        \[\leadsto a \cdot \frac{\color{blue}{-d}}{\mathsf{fma}\left(d, d, c \cdot c\right)} \]
      12. lift-fma.f64N/A

        \[\leadsto a \cdot \frac{\mathsf{neg}\left(d\right)}{\color{blue}{d \cdot d + c \cdot c}} \]
      13. +-commutativeN/A

        \[\leadsto a \cdot \frac{\mathsf{neg}\left(d\right)}{\color{blue}{c \cdot c + d \cdot d}} \]
      14. lift-*.f64N/A

        \[\leadsto a \cdot \frac{\mathsf{neg}\left(d\right)}{\color{blue}{c \cdot c} + d \cdot d} \]
      15. lower-fma.f64N/A

        \[\leadsto a \cdot \frac{\mathsf{neg}\left(d\right)}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      16. lower-*.f6477.5

        \[\leadsto a \cdot \frac{-d}{\mathsf{fma}\left(c, c, \color{blue}{d \cdot d}\right)} \]
    7. Applied rewrites77.5%

      \[\leadsto \color{blue}{a \cdot \frac{-d}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]

    if 3.7999999999999997e88 < d

    1. Initial program 42.8%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{a}{d}\right)} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \color{blue}{\frac{a}{\mathsf{neg}\left(d\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{a}{\color{blue}{-1 \cdot d}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{a}{-1 \cdot d}} \]
      5. mul-1-negN/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      6. lower-neg.f6476.1

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    5. Applied rewrites76.1%

      \[\leadsto \color{blue}{\frac{a}{-d}} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 6: 76.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -6.2 \cdot 10^{+42}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma c (/ b d) (- a)) d)))
   (if (<= d -6.2e+42)
     t_0
     (if (<= d 2.3e-41) (/ (fma (- d) (/ a c) b) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(c, (b / d), -a) / d;
	double tmp;
	if (d <= -6.2e+42) {
		tmp = t_0;
	} else if (d <= 2.3e-41) {
		tmp = fma(-d, (a / c), b) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(c, Float64(b / d), Float64(-a)) / d)
	tmp = 0.0
	if (d <= -6.2e+42)
		tmp = t_0;
	elseif (d <= 2.3e-41)
		tmp = Float64(fma(Float64(-d), Float64(a / c), b) / c);
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6.2e+42], t$95$0, If[LessEqual[d, 2.3e-41], N[(N[((-d) * N[(a / c), $MachinePrecision] + b), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -6.2 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}{c}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -6.2000000000000003e42 or 2.3000000000000001e-41 < d

    1. Initial program 49.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + \left(\mathsf{neg}\left(a\right)\right)}{d} \]
      11. mul-1-negN/A

        \[\leadsto \frac{c \cdot \frac{b}{d} + \color{blue}{-1 \cdot a}}{d} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
      15. lower-neg.f6482.2

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{-a}\right)}{d} \]
    5. Applied rewrites82.2%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}} \]

    if -6.2000000000000003e42 < d < 2.3000000000000001e-41

    1. Initial program 73.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6484.2

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
    5. Applied rewrites84.2%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      3. sub-negN/A

        \[\leadsto \frac{\color{blue}{b + \left(\mathsf{neg}\left(\frac{d \cdot a}{c}\right)\right)}}{c} \]
      4. +-commutativeN/A

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

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

        \[\leadsto \frac{\left(\mathsf{neg}\left(\frac{\color{blue}{d \cdot a}}{c}\right)\right) + b}{c} \]
      7. associate-/l*N/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\color{blue}{d \cdot \frac{a}{c}}\right)\right) + b}{c} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(d\right)\right) \cdot \frac{a}{c}} + b}{c} \]
      9. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(d\right), \frac{a}{c}, b\right)}}{c} \]
      10. lower-neg.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(d\right)}, \frac{a}{c}, b\right)}{c} \]
      11. lower-/.f6484.3

        \[\leadsto \frac{\mathsf{fma}\left(-d, \color{blue}{\frac{a}{c}}, b\right)}{c} \]
    7. Applied rewrites84.3%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-d, \frac{a}{c}, b\right)}}{c} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 77.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -3.9 \cdot 10^{+42}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (fma c (/ b d) (- a)) d)))
   (if (<= d -3.9e+42) t_0 (if (<= d 2.3e-41) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(c, (b / d), -a) / d;
	double tmp;
	if (d <= -3.9e+42) {
		tmp = t_0;
	} else if (d <= 2.3e-41) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(fma(c, Float64(b / d), Float64(-a)) / d)
	tmp = 0.0
	if (d <= -3.9e+42)
		tmp = t_0;
	elseif (d <= 2.3e-41)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3.9e+42], t$95$0, If[LessEqual[d, 2.3e-41], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -3.9 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.8999999999999997e42 or 2.3000000000000001e-41 < d

    1. Initial program 49.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{b \cdot c}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{a}{d}\right)\right)} \]
      3. unsub-negN/A

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow2N/A

        \[\leadsto \frac{b \cdot c}{\color{blue}{d \cdot d}} - \frac{a}{d} \]
      5. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-subN/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      8. sub-negN/A

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + \left(\mathsf{neg}\left(a\right)\right)}}{d} \]
      9. *-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{c \cdot \frac{b}{d}} + \left(\mathsf{neg}\left(a\right)\right)}{d} \]
      11. mul-1-negN/A

        \[\leadsto \frac{c \cdot \frac{b}{d} + \color{blue}{-1 \cdot a}}{d} \]
      12. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. lower-/.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \color{blue}{\frac{b}{d}}, -1 \cdot a\right)}{d} \]
      14. mul-1-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{\mathsf{neg}\left(a\right)}\right)}{d} \]
      15. lower-neg.f6482.2

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{-a}\right)}{d} \]
    5. Applied rewrites82.2%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}} \]

    if -3.8999999999999997e42 < d < 2.3000000000000001e-41

    1. Initial program 73.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6484.2

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
    5. Applied rewrites84.2%

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

Alternative 8: 75.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;d \leq -3.9 \cdot 10^{+42}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (/ (* c b) d) a) d)))
   (if (<= d -3.9e+42) t_0 (if (<= d 2.3e-41) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = (((c * b) / d) - a) / d;
	double tmp;
	if (d <= -3.9e+42) {
		tmp = t_0;
	} else if (d <= 2.3e-41) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (((c * b) / d) - a) / d
    if (d <= (-3.9d+42)) then
        tmp = t_0
    else if (d <= 2.3d-41) then
        tmp = (b - ((d * a) / c)) / c
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = (((c * b) / d) - a) / d;
	double tmp;
	if (d <= -3.9e+42) {
		tmp = t_0;
	} else if (d <= 2.3e-41) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (((c * b) / d) - a) / d
	tmp = 0
	if d <= -3.9e+42:
		tmp = t_0
	elif d <= 2.3e-41:
		tmp = (b - ((d * a) / c)) / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(Float64(c * b) / d) - a) / d)
	tmp = 0.0
	if (d <= -3.9e+42)
		tmp = t_0;
	elseif (d <= 2.3e-41)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (((c * b) / d) - a) / d;
	tmp = 0.0;
	if (d <= -3.9e+42)
		tmp = t_0;
	elseif (d <= 2.3e-41)
		tmp = (b - ((d * a) / c)) / c;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3.9e+42], t$95$0, If[LessEqual[d, 2.3e-41], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{if}\;d \leq -3.9 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.8999999999999997e42 or 2.3000000000000001e-41 < d

    1. Initial program 49.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + c \cdot \left(\frac{b}{{d}^{2}} + \frac{a \cdot c}{{d}^{3}}\right)} \]
    4. Applied rewrites65.7%

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(c, b, \frac{c \cdot \left(c \cdot a\right)}{d}\right)}{d} - a}{d}} \]
    5. Taylor expanded in c around 0

      \[\leadsto \frac{\frac{\color{blue}{b \cdot c}}{d} - a}{d} \]
    6. Step-by-step derivation
      1. lower-*.f6475.2

        \[\leadsto \frac{\frac{\color{blue}{b \cdot c}}{d} - a}{d} \]
    7. Applied rewrites75.2%

      \[\leadsto \frac{\frac{\color{blue}{b \cdot c}}{d} - a}{d} \]

    if -3.8999999999999997e42 < d < 2.3000000000000001e-41

    1. Initial program 73.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6484.2

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
    5. Applied rewrites84.2%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.9 \cdot 10^{+42}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 71.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\ \;\;\;\;\frac{-1}{\frac{d}{a}}\\ \mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{-d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -5.3e+45)
   (/ -1.0 (/ d a))
   (if (<= d 2.3e-41) (/ (- b (/ (* d a) c)) c) (/ a (- d)))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -5.3e+45) {
		tmp = -1.0 / (d / a);
	} else if (d <= 2.3e-41) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = a / -d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (d <= (-5.3d+45)) then
        tmp = (-1.0d0) / (d / a)
    else if (d <= 2.3d-41) then
        tmp = (b - ((d * a) / c)) / c
    else
        tmp = a / -d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -5.3e+45) {
		tmp = -1.0 / (d / a);
	} else if (d <= 2.3e-41) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = a / -d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -5.3e+45:
		tmp = -1.0 / (d / a)
	elif d <= 2.3e-41:
		tmp = (b - ((d * a) / c)) / c
	else:
		tmp = a / -d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -5.3e+45)
		tmp = Float64(-1.0 / Float64(d / a));
	elseif (d <= 2.3e-41)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	else
		tmp = Float64(a / Float64(-d));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (d <= -5.3e+45)
		tmp = -1.0 / (d / a);
	elseif (d <= 2.3e-41)
		tmp = (b - ((d * a) / c)) / c;
	else
		tmp = a / -d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.3e+45], N[(-1.0 / N[(d / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.3e-41], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\
\;\;\;\;\frac{-1}{\frac{d}{a}}\\

\mathbf{elif}\;d \leq 2.3 \cdot 10^{-41}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -5.29999999999999991e45

    1. Initial program 42.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

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

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(c, b, \frac{c \cdot \left(c \cdot a\right)}{d}\right)}{d} - a}{d}} \]
    5. Taylor expanded in c around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot a}}{d} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
      2. lower-neg.f6472.5

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Applied rewrites72.5%

      \[\leadsto \frac{\color{blue}{-a}}{d} \]
    8. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a\right)\right)\right)}{\mathsf{neg}\left(d\right)}} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      4. div-invN/A

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

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

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

        \[\leadsto \color{blue}{a \cdot \frac{1}{\mathsf{neg}\left(d\right)}} \]
      8. metadata-evalN/A

        \[\leadsto a \cdot \frac{\color{blue}{\mathsf{neg}\left(-1\right)}}{\mathsf{neg}\left(d\right)} \]
      9. frac-2negN/A

        \[\leadsto a \cdot \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto a \cdot \frac{\mathsf{neg}\left(\color{blue}{1}\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)} \]
      11. metadata-evalN/A

        \[\leadsto a \cdot \frac{\color{blue}{-1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)} \]
      12. lift-neg.f64N/A

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

        \[\leadsto a \cdot \frac{-1}{\color{blue}{d}} \]
      14. lower-/.f6472.3

        \[\leadsto a \cdot \color{blue}{\frac{-1}{d}} \]
    9. Applied rewrites72.3%

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

        \[\leadsto \color{blue}{\frac{a \cdot -1}{d}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{d}{a \cdot -1}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{-1 \cdot a}}} \]
      4. neg-mul-1N/A

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{\mathsf{neg}\left(a\right)}}} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{\mathsf{neg}\left(a\right)}}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{d}{\mathsf{neg}\left(a\right)}}} \]
      7. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\frac{d}{\mathsf{neg}\left(a\right)}\right)}} \]
      8. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{-1}}{\mathsf{neg}\left(\frac{d}{\mathsf{neg}\left(a\right)}\right)} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-1}{\mathsf{neg}\left(\frac{d}{\mathsf{neg}\left(a\right)}\right)}} \]
      10. lift-/.f64N/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\color{blue}{\frac{d}{\mathsf{neg}\left(a\right)}}\right)} \]
      11. lift-neg.f64N/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\frac{d}{\color{blue}{\mathsf{neg}\left(a\right)}}\right)} \]
      12. distribute-frac-neg2N/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{d}{a}\right)\right)}\right)} \]
      13. remove-double-negN/A

        \[\leadsto \frac{-1}{\color{blue}{\frac{d}{a}}} \]
      14. lower-/.f6473.2

        \[\leadsto \frac{-1}{\color{blue}{\frac{d}{a}}} \]
    11. Applied rewrites73.2%

      \[\leadsto \color{blue}{\frac{-1}{\frac{d}{a}}} \]

    if -5.29999999999999991e45 < d < 2.3000000000000001e-41

    1. Initial program 74.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
      2. mul-1-negN/A

        \[\leadsto \frac{b + \color{blue}{\left(\mathsf{neg}\left(\frac{a \cdot d}{c}\right)\right)}}{c} \]
      3. unsub-negN/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      4. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. lower-/.f64N/A

        \[\leadsto \frac{b - \color{blue}{\frac{a \cdot d}{c}}}{c} \]
      6. *-commutativeN/A

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
      7. lower-*.f6483.7

        \[\leadsto \frac{b - \frac{\color{blue}{d \cdot a}}{c}}{c} \]
    5. Applied rewrites83.7%

      \[\leadsto \color{blue}{\frac{b - \frac{d \cdot a}{c}}{c}} \]

    if 2.3000000000000001e-41 < d

    1. Initial program 54.6%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{a}{d}\right)} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \color{blue}{\frac{a}{\mathsf{neg}\left(d\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{a}{\color{blue}{-1 \cdot d}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{a}{-1 \cdot d}} \]
      5. mul-1-negN/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      6. lower-neg.f6470.2

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    5. Applied rewrites70.2%

      \[\leadsto \color{blue}{\frac{a}{-d}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 63.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\ \;\;\;\;\frac{-1}{\frac{d}{a}}\\ \mathbf{elif}\;d \leq 9.8 \cdot 10^{-61}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{-d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= d -5.3e+45) (/ -1.0 (/ d a)) (if (<= d 9.8e-61) (/ b c) (/ a (- d)))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -5.3e+45) {
		tmp = -1.0 / (d / a);
	} else if (d <= 9.8e-61) {
		tmp = b / c;
	} else {
		tmp = a / -d;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (d <= (-5.3d+45)) then
        tmp = (-1.0d0) / (d / a)
    else if (d <= 9.8d-61) then
        tmp = b / c
    else
        tmp = a / -d
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (d <= -5.3e+45) {
		tmp = -1.0 / (d / a);
	} else if (d <= 9.8e-61) {
		tmp = b / c;
	} else {
		tmp = a / -d;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if d <= -5.3e+45:
		tmp = -1.0 / (d / a)
	elif d <= 9.8e-61:
		tmp = b / c
	else:
		tmp = a / -d
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (d <= -5.3e+45)
		tmp = Float64(-1.0 / Float64(d / a));
	elseif (d <= 9.8e-61)
		tmp = Float64(b / c);
	else
		tmp = Float64(a / Float64(-d));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (d <= -5.3e+45)
		tmp = -1.0 / (d / a);
	elseif (d <= 9.8e-61)
		tmp = b / c;
	else
		tmp = a / -d;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.3e+45], N[(-1.0 / N[(d / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.8e-61], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\
\;\;\;\;\frac{-1}{\frac{d}{a}}\\

\mathbf{elif}\;d \leq 9.8 \cdot 10^{-61}:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -5.29999999999999991e45

    1. Initial program 42.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

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

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(c, b, \frac{c \cdot \left(c \cdot a\right)}{d}\right)}{d} - a}{d}} \]
    5. Taylor expanded in c around 0

      \[\leadsto \frac{\color{blue}{-1 \cdot a}}{d} \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
      2. lower-neg.f6472.5

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    7. Applied rewrites72.5%

      \[\leadsto \frac{\color{blue}{-a}}{d} \]
    8. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(a\right)}}{d} \]
      2. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a\right)\right)\right)}{\mathsf{neg}\left(d\right)}} \]
      3. lift-neg.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(a\right)\right)\right)}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      4. div-invN/A

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

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

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

        \[\leadsto \color{blue}{a \cdot \frac{1}{\mathsf{neg}\left(d\right)}} \]
      8. metadata-evalN/A

        \[\leadsto a \cdot \frac{\color{blue}{\mathsf{neg}\left(-1\right)}}{\mathsf{neg}\left(d\right)} \]
      9. frac-2negN/A

        \[\leadsto a \cdot \color{blue}{\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(-1\right)\right)\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)}} \]
      10. metadata-evalN/A

        \[\leadsto a \cdot \frac{\mathsf{neg}\left(\color{blue}{1}\right)}{\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)} \]
      11. metadata-evalN/A

        \[\leadsto a \cdot \frac{\color{blue}{-1}}{\mathsf{neg}\left(\left(\mathsf{neg}\left(d\right)\right)\right)} \]
      12. lift-neg.f64N/A

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

        \[\leadsto a \cdot \frac{-1}{\color{blue}{d}} \]
      14. lower-/.f6472.3

        \[\leadsto a \cdot \color{blue}{\frac{-1}{d}} \]
    9. Applied rewrites72.3%

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

        \[\leadsto \color{blue}{\frac{a \cdot -1}{d}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{d}{a \cdot -1}}} \]
      3. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{-1 \cdot a}}} \]
      4. neg-mul-1N/A

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{\mathsf{neg}\left(a\right)}}} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{1}{\frac{d}{\color{blue}{\mathsf{neg}\left(a\right)}}} \]
      6. lift-/.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\frac{d}{\mathsf{neg}\left(a\right)}}} \]
      7. frac-2negN/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(1\right)}{\mathsf{neg}\left(\frac{d}{\mathsf{neg}\left(a\right)}\right)}} \]
      8. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{-1}}{\mathsf{neg}\left(\frac{d}{\mathsf{neg}\left(a\right)}\right)} \]
      9. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-1}{\mathsf{neg}\left(\frac{d}{\mathsf{neg}\left(a\right)}\right)}} \]
      10. lift-/.f64N/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\color{blue}{\frac{d}{\mathsf{neg}\left(a\right)}}\right)} \]
      11. lift-neg.f64N/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\frac{d}{\color{blue}{\mathsf{neg}\left(a\right)}}\right)} \]
      12. distribute-frac-neg2N/A

        \[\leadsto \frac{-1}{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\frac{d}{a}\right)\right)}\right)} \]
      13. remove-double-negN/A

        \[\leadsto \frac{-1}{\color{blue}{\frac{d}{a}}} \]
      14. lower-/.f6473.2

        \[\leadsto \frac{-1}{\color{blue}{\frac{d}{a}}} \]
    11. Applied rewrites73.2%

      \[\leadsto \color{blue}{\frac{-1}{\frac{d}{a}}} \]

    if -5.29999999999999991e45 < d < 9.80000000000000004e-61

    1. Initial program 73.5%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f6467.2

        \[\leadsto \color{blue}{\frac{b}{c}} \]
    5. Applied rewrites67.2%

      \[\leadsto \color{blue}{\frac{b}{c}} \]

    if 9.80000000000000004e-61 < d

    1. Initial program 56.6%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{a}{d}\right)} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \color{blue}{\frac{a}{\mathsf{neg}\left(d\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{a}{\color{blue}{-1 \cdot d}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{a}{-1 \cdot d}} \]
      5. mul-1-negN/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      6. lower-neg.f6467.5

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    5. Applied rewrites67.5%

      \[\leadsto \color{blue}{\frac{a}{-d}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 11: 63.5% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{-d}\\ \mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 9.8 \cdot 10^{-61}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ a (- d))))
   (if (<= d -5.3e+45) t_0 (if (<= d 9.8e-61) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = a / -d;
	double tmp;
	if (d <= -5.3e+45) {
		tmp = t_0;
	} else if (d <= 9.8e-61) {
		tmp = b / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = a / -d
    if (d <= (-5.3d+45)) then
        tmp = t_0
    else if (d <= 9.8d-61) then
        tmp = b / c
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = a / -d;
	double tmp;
	if (d <= -5.3e+45) {
		tmp = t_0;
	} else if (d <= 9.8e-61) {
		tmp = b / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = a / -d
	tmp = 0
	if d <= -5.3e+45:
		tmp = t_0
	elif d <= 9.8e-61:
		tmp = b / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(a / Float64(-d))
	tmp = 0.0
	if (d <= -5.3e+45)
		tmp = t_0;
	elseif (d <= 9.8e-61)
		tmp = Float64(b / c);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = a / -d;
	tmp = 0.0;
	if (d <= -5.3e+45)
		tmp = t_0;
	elseif (d <= 9.8e-61)
		tmp = b / c;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -5.3e+45], t$95$0, If[LessEqual[d, 9.8e-61], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{a}{-d}\\
\mathbf{if}\;d \leq -5.3 \cdot 10^{+45}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 9.8 \cdot 10^{-61}:\\
\;\;\;\;\frac{b}{c}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.29999999999999991e45 or 9.80000000000000004e-61 < d

    1. Initial program 50.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around 0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{a}{d}\right)} \]
      2. distribute-neg-frac2N/A

        \[\leadsto \color{blue}{\frac{a}{\mathsf{neg}\left(d\right)}} \]
      3. mul-1-negN/A

        \[\leadsto \frac{a}{\color{blue}{-1 \cdot d}} \]
      4. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{a}{-1 \cdot d}} \]
      5. mul-1-negN/A

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      6. lower-neg.f6469.7

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    5. Applied rewrites69.7%

      \[\leadsto \color{blue}{\frac{a}{-d}} \]

    if -5.29999999999999991e45 < d < 9.80000000000000004e-61

    1. Initial program 73.5%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Taylor expanded in c around inf

      \[\leadsto \color{blue}{\frac{b}{c}} \]
    4. Step-by-step derivation
      1. lower-/.f6467.2

        \[\leadsto \color{blue}{\frac{b}{c}} \]
    5. Applied rewrites67.2%

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

Alternative 12: 43.4% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \frac{b}{c} \end{array} \]
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
	return b / c;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = b / c
end function
public static double code(double a, double b, double c, double d) {
	return b / c;
}
def code(a, b, c, d):
	return b / c
function code(a, b, c, d)
	return Float64(b / c)
end
function tmp = code(a, b, c, d)
	tmp = b / c;
end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}

\\
\frac{b}{c}
\end{array}
Derivation
  1. Initial program 62.2%

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Add Preprocessing
  3. Taylor expanded in c around inf

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  4. Step-by-step derivation
    1. lower-/.f6444.7

      \[\leadsto \color{blue}{\frac{b}{c}} \]
  5. Applied rewrites44.7%

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  6. Add Preprocessing

Developer Target 1: 99.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (< (fabs d) (fabs c))
   (/ (- b (* a (/ d c))) (+ c (* d (/ d c))))
   (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (abs(d) < abs(c)) then
        tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (Math.abs(d) < Math.abs(c)) {
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (abs(d) < abs(c))
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (abs(d) < abs(c))
		tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024214 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))

  (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))