Complex division, imag part

Percentage Accurate: 61.4% → 83.7%
Time: 8.2s
Alternatives: 11
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 11 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.4% 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: 83.7% 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(\frac{c}{t\_0}, b, -\frac{d \cdot a}{t\_0}\right)\\ t_2 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -3.2 \cdot 10^{+81}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;d \leq -4.3 \cdot 10^{-91}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 1.85 \cdot 10^{-82}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+39}:\\ \;\;\;\;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 (/ c t_0) b (- (/ (* d a) t_0))))
        (t_2 (/ (fma c (/ b d) (- a)) d)))
   (if (<= d -3.2e+81)
     t_2
     (if (<= d -4.3e-91)
       t_1
       (if (<= d 1.85e-82)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 7e+39) 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((c / t_0), b, -((d * a) / t_0));
	double t_2 = fma(c, (b / d), -a) / d;
	double tmp;
	if (d <= -3.2e+81) {
		tmp = t_2;
	} else if (d <= -4.3e-91) {
		tmp = t_1;
	} else if (d <= 1.85e-82) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 7e+39) {
		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(c / t_0), b, Float64(-Float64(Float64(d * a) / t_0)))
	t_2 = Float64(fma(c, Float64(b / d), Float64(-a)) / d)
	tmp = 0.0
	if (d <= -3.2e+81)
		tmp = t_2;
	elseif (d <= -4.3e-91)
		tmp = t_1;
	elseif (d <= 1.85e-82)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 7e+39)
		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[(N[(c / t$95$0), $MachinePrecision] * b + (-N[(N[(d * a), $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.2e+81], t$95$2, If[LessEqual[d, -4.3e-91], t$95$1, If[LessEqual[d, 1.85e-82], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7e+39], 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(\frac{c}{t\_0}, b, -\frac{d \cdot a}{t\_0}\right)\\
t_2 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{if}\;d \leq -3.2 \cdot 10^{+81}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;d \leq -4.3 \cdot 10^{-91}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 7 \cdot 10^{+39}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.2e81 or 7.0000000000000003e39 < d

    1. Initial program 43.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} + \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.f6485.8

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

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

    if -3.2e81 < d < -4.3e-91 or 1.85e-82 < d < 7.0000000000000003e39

    1. Initial program 80.0%

      \[\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 \color{blue}{\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}} \]
      2. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{c \cdot c + d \cdot d} \]
      3. 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}} \]
      4. 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)} \]
      5. 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) \]
      6. 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) \]
      7. *-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) \]
      8. 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)} \]
      9. 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) \]
      10. 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) \]
      11. +-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) \]
      12. 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) \]
      13. 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) \]
      14. 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) \]
      15. lower-/.f64N/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) \]
      16. lift-*.f64N/A

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

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

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

      \[\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 -4.3e-91 < d < 1.85e-82

    1. Initial program 67.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 + -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-*.f6498.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.2 \cdot 10^{+81}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -4.3 \cdot 10^{-91}:\\ \;\;\;\;\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)\\ \mathbf{elif}\;d \leq 1.85 \cdot 10^{-82}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+39}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 81.0% 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 -9 \cdot 10^{+70}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-85}:\\ \;\;\;\;\mathsf{fma}\left(-d, \frac{a}{t\_0}, \frac{b \cdot c}{t\_0}\right)\\ \mathbf{elif}\;d \leq 5800000:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \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 -9e+70)
     t_1
     (if (<= d -1e-85)
       (fma (- d) (/ a t_0) (/ (* b c) t_0))
       (if (<= d 5800000.0) (/ (- b (/ (* d a) c)) c) 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 <= -9e+70) {
		tmp = t_1;
	} else if (d <= -1e-85) {
		tmp = fma(-d, (a / t_0), ((b * c) / t_0));
	} else if (d <= 5800000.0) {
		tmp = (b - ((d * a) / c)) / c;
	} 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 <= -9e+70)
		tmp = t_1;
	elseif (d <= -1e-85)
		tmp = fma(Float64(-d), Float64(a / t_0), Float64(Float64(b * c) / t_0));
	elseif (d <= 5800000.0)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	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, -9e+70], t$95$1, If[LessEqual[d, -1e-85], N[((-d) * N[(a / t$95$0), $MachinePrecision] + N[(N[(b * c), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5800000.0], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $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 -9 \cdot 10^{+70}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 5800000:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -8.9999999999999999e70 or 5.8e6 < d

    1. Initial program 45.5%

      \[\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.f6484.1

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

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

    if -8.9999999999999999e70 < d < -9.9999999999999998e-86

    1. Initial program 82.2%

      \[\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 \color{blue}{\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}} \]
      2. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{c \cdot c + d \cdot d} \]
      3. 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}} \]
      4. 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)} \]
      5. +-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}} \]
      6. 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} \]
      7. *-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} \]
      8. 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} \]
      9. 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} \]
      10. 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)} \]
      11. lower-neg.f64N/A

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

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

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

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

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

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

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

      \[\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 -9.9999999999999998e-86 < d < 5.8e6

    1. Initial program 69.3%

      \[\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-*.f6492.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -9 \cdot 10^{+70}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-85}:\\ \;\;\;\;\mathsf{fma}\left(-d, \frac{a}{\mathsf{fma}\left(d, d, c \cdot c\right)}, \frac{b \cdot c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\right)\\ \mathbf{elif}\;d \leq 5800000:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.0% accurate, 0.8× 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.5 \cdot 10^{+70}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-85}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 5800000:\\ \;\;\;\;\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 -6.5e+70)
     t_0
     (if (<= d -1e-85)
       (/ (- (* b c) (* d a)) (+ (* c c) (* d d)))
       (if (<= d 5800000.0) (/ (- 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 <= -6.5e+70) {
		tmp = t_0;
	} else if (d <= -1e-85) {
		tmp = ((b * c) - (d * a)) / ((c * c) + (d * d));
	} else if (d <= 5800000.0) {
		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 <= -6.5e+70)
		tmp = t_0;
	elseif (d <= -1e-85)
		tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (d <= 5800000.0)
		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, -6.5e+70], t$95$0, If[LessEqual[d, -1e-85], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5800000.0], 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 -6.5 \cdot 10^{+70}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq -1 \cdot 10^{-85}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\

\mathbf{elif}\;d \leq 5800000:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.49999999999999978e70 or 5.8e6 < d

    1. Initial program 45.5%

      \[\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.f6484.1

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

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

    if -6.49999999999999978e70 < d < -9.9999999999999998e-86

    1. Initial program 82.2%

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

    if -9.9999999999999998e-86 < d < 5.8e6

    1. Initial program 69.3%

      \[\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-*.f6492.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6.5 \cdot 10^{+70}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-85}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 5800000:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{-d}\\ \mathbf{if}\;d \leq -1.3 \cdot 10^{+108}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -5 \cdot 10^{+30}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq 15500000:\\ \;\;\;\;\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 (/ a (- d))))
   (if (<= d -1.3e+108)
     t_0
     (if (<= d -5e+30)
       (/ (- (* b c) (* d a)) (* d d))
       (if (<= d 15500000.0) (/ (- b (/ (* d a) c)) c) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = a / -d;
	double tmp;
	if (d <= -1.3e+108) {
		tmp = t_0;
	} else if (d <= -5e+30) {
		tmp = ((b * c) - (d * a)) / (d * d);
	} else if (d <= 15500000.0) {
		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 = a / -d
    if (d <= (-1.3d+108)) then
        tmp = t_0
    else if (d <= (-5d+30)) then
        tmp = ((b * c) - (d * a)) / (d * d)
    else if (d <= 15500000.0d0) 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 = a / -d;
	double tmp;
	if (d <= -1.3e+108) {
		tmp = t_0;
	} else if (d <= -5e+30) {
		tmp = ((b * c) - (d * a)) / (d * d);
	} else if (d <= 15500000.0) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = a / -d
	tmp = 0
	if d <= -1.3e+108:
		tmp = t_0
	elif d <= -5e+30:
		tmp = ((b * c) - (d * a)) / (d * d)
	elif d <= 15500000.0:
		tmp = (b - ((d * a) / c)) / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(a / Float64(-d))
	tmp = 0.0
	if (d <= -1.3e+108)
		tmp = t_0;
	elseif (d <= -5e+30)
		tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(d * d));
	elseif (d <= 15500000.0)
		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 = a / -d;
	tmp = 0.0;
	if (d <= -1.3e+108)
		tmp = t_0;
	elseif (d <= -5e+30)
		tmp = ((b * c) - (d * a)) / (d * d);
	elseif (d <= 15500000.0)
		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[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -1.3e+108], t$95$0, If[LessEqual[d, -5e+30], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 15500000.0], 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{a}{-d}\\
\mathbf{if}\;d \leq -1.3 \cdot 10^{+108}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq -5 \cdot 10^{+30}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\

\mathbf{elif}\;d \leq 15500000:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.3000000000000001e108 or 1.55e7 < 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.f6473.2

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

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

    if -1.3000000000000001e108 < d < -4.9999999999999998e30

    1. Initial program 92.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 \frac{b \cdot c - a \cdot d}{\color{blue}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

    if -4.9999999999999998e30 < d < 1.55e7

    1. Initial program 70.3%

      \[\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-*.f6488.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.3 \cdot 10^{+108}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;d \leq -5 \cdot 10^{+30}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq 15500000:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{-d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 64.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{-d}\\ \mathbf{if}\;d \leq -1.3 \cdot 10^{+108}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -4.8 \cdot 10^{+30}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq -1.35 \cdot 10^{-118}:\\ \;\;\;\;d \cdot \frac{-a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 4800000:\\ \;\;\;\;\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 -1.3e+108)
     t_0
     (if (<= d -4.8e+30)
       (/ (- (* b c) (* d a)) (* d d))
       (if (<= d -1.35e-118)
         (* d (/ (- a) (fma d d (* c c))))
         (if (<= d 4800000.0) (/ b c) t_0))))))
double code(double a, double b, double c, double d) {
	double t_0 = a / -d;
	double tmp;
	if (d <= -1.3e+108) {
		tmp = t_0;
	} else if (d <= -4.8e+30) {
		tmp = ((b * c) - (d * a)) / (d * d);
	} else if (d <= -1.35e-118) {
		tmp = d * (-a / fma(d, d, (c * c)));
	} else if (d <= 4800000.0) {
		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 <= -1.3e+108)
		tmp = t_0;
	elseif (d <= -4.8e+30)
		tmp = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(d * d));
	elseif (d <= -1.35e-118)
		tmp = Float64(d * Float64(Float64(-a) / fma(d, d, Float64(c * c))));
	elseif (d <= 4800000.0)
		tmp = Float64(b / c);
	else
		tmp = t_0;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -1.3e+108], t$95$0, If[LessEqual[d, -4.8e+30], N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.35e-118], N[(d * N[((-a) / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4800000.0], N[(b / c), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -4.8 \cdot 10^{+30}:\\
\;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\

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

\mathbf{elif}\;d \leq 4800000:\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -1.3000000000000001e108 or 4.8e6 < 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.f6473.2

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

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

    if -1.3000000000000001e108 < d < -4.7999999999999999e30

    1. Initial program 92.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 \frac{b \cdot c - a \cdot d}{\color{blue}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. unpow2N/A

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

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

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

    if -4.7999999999999999e30 < d < -1.34999999999999997e-118

    1. Initial program 82.3%

      \[\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. lower-neg.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-a \cdot \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
    6. Step-by-step derivation
      1. Applied rewrites64.5%

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

      if -1.34999999999999997e-118 < d < 4.8e6

      1. Initial program 67.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-/.f6481.6

          \[\leadsto \color{blue}{\frac{b}{c}} \]
      5. Applied rewrites81.6%

        \[\leadsto \color{blue}{\frac{b}{c}} \]
    7. Recombined 4 regimes into one program.
    8. Final simplification76.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.3 \cdot 10^{+108}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;d \leq -4.8 \cdot 10^{+30}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq -1.35 \cdot 10^{-118}:\\ \;\;\;\;d \cdot \frac{-a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 4800000:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{-d}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 6: 78.5% 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 -5 \cdot 10^{+30}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 5800000:\\ \;\;\;\;\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 -5e+30) t_0 (if (<= d 5800000.0) (/ (- 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 <= -5e+30) {
    		tmp = t_0;
    	} else if (d <= 5800000.0) {
    		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 <= -5e+30)
    		tmp = t_0;
    	elseif (d <= 5800000.0)
    		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, -5e+30], t$95$0, If[LessEqual[d, 5800000.0], 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 -5 \cdot 10^{+30}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;d \leq 5800000:\\
    \;\;\;\;\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 < -4.9999999999999998e30 or 5.8e6 < d

      1. Initial program 48.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.f6484.3

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

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

      if -4.9999999999999998e30 < d < 5.8e6

      1. Initial program 70.3%

        \[\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-*.f6488.2

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

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

    Alternative 7: 76.4% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{if}\;d \leq -5 \cdot 10^{+30}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 5800000:\\ \;\;\;\;\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 (/ (- (/ (* b c) d) a) d)))
       (if (<= d -5e+30) t_0 (if (<= d 5800000.0) (/ (- b (/ (* d a) c)) c) t_0))))
    double code(double a, double b, double c, double d) {
    	double t_0 = (((b * c) / d) - a) / d;
    	double tmp;
    	if (d <= -5e+30) {
    		tmp = t_0;
    	} else if (d <= 5800000.0) {
    		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 = (((b * c) / d) - a) / d
        if (d <= (-5d+30)) then
            tmp = t_0
        else if (d <= 5800000.0d0) 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 = (((b * c) / d) - a) / d;
    	double tmp;
    	if (d <= -5e+30) {
    		tmp = t_0;
    	} else if (d <= 5800000.0) {
    		tmp = (b - ((d * a) / c)) / c;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(a, b, c, d):
    	t_0 = (((b * c) / d) - a) / d
    	tmp = 0
    	if d <= -5e+30:
    		tmp = t_0
    	elif d <= 5800000.0:
    		tmp = (b - ((d * a) / c)) / c
    	else:
    		tmp = t_0
    	return tmp
    
    function code(a, b, c, d)
    	t_0 = Float64(Float64(Float64(Float64(b * c) / d) - a) / d)
    	tmp = 0.0
    	if (d <= -5e+30)
    		tmp = t_0;
    	elseif (d <= 5800000.0)
    		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 = (((b * c) / d) - a) / d;
    	tmp = 0.0;
    	if (d <= -5e+30)
    		tmp = t_0;
    	elseif (d <= 5800000.0)
    		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[(b * c), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -5e+30], t$95$0, If[LessEqual[d, 5800000.0], 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{b \cdot c}{d} - a}{d}\\
    \mathbf{if}\;d \leq -5 \cdot 10^{+30}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;d \leq 5800000:\\
    \;\;\;\;\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 < -4.9999999999999998e30 or 5.8e6 < d

      1. Initial program 48.8%

        \[\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-/.f6419.2

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

        \[\leadsto \color{blue}{\frac{b}{c}} \]
      6. Taylor expanded in d around inf

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

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

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

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

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

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

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

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

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

      if -4.9999999999999998e30 < d < 5.8e6

      1. Initial program 70.3%

        \[\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-*.f6488.2

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

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

    Alternative 8: 64.9% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{-d}\\ \mathbf{if}\;d \leq -1.58 \cdot 10^{+72}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -1.35 \cdot 10^{-118}:\\ \;\;\;\;d \cdot \frac{-a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 4800000:\\ \;\;\;\;\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 -1.58e+72)
         t_0
         (if (<= d -1.35e-118)
           (* d (/ (- a) (fma d d (* c c))))
           (if (<= d 4800000.0) (/ b c) t_0)))))
    double code(double a, double b, double c, double d) {
    	double t_0 = a / -d;
    	double tmp;
    	if (d <= -1.58e+72) {
    		tmp = t_0;
    	} else if (d <= -1.35e-118) {
    		tmp = d * (-a / fma(d, d, (c * c)));
    	} else if (d <= 4800000.0) {
    		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 <= -1.58e+72)
    		tmp = t_0;
    	elseif (d <= -1.35e-118)
    		tmp = Float64(d * Float64(Float64(-a) / fma(d, d, Float64(c * c))));
    	elseif (d <= 4800000.0)
    		tmp = Float64(b / c);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -1.58e+72], t$95$0, If[LessEqual[d, -1.35e-118], N[(d * N[((-a) / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4800000.0], N[(b / c), $MachinePrecision], t$95$0]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{a}{-d}\\
    \mathbf{if}\;d \leq -1.58 \cdot 10^{+72}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;d \leq -1.35 \cdot 10^{-118}:\\
    \;\;\;\;d \cdot \frac{-a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
    
    \mathbf{elif}\;d \leq 4800000:\\
    \;\;\;\;\frac{b}{c}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if d < -1.58000000000000006e72 or 4.8e6 < d

      1. Initial program 46.0%

        \[\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.f6471.3

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

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

      if -1.58000000000000006e72 < d < -1.34999999999999997e-118

      1. Initial program 83.3%

        \[\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. lower-neg.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-a \cdot \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      6. Step-by-step derivation
        1. Applied rewrites58.8%

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

        if -1.34999999999999997e-118 < d < 4.8e6

        1. Initial program 67.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-/.f6481.6

            \[\leadsto \color{blue}{\frac{b}{c}} \]
        5. Applied rewrites81.6%

          \[\leadsto \color{blue}{\frac{b}{c}} \]
      7. Recombined 3 regimes into one program.
      8. Final simplification74.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.58 \cdot 10^{+72}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;d \leq -1.35 \cdot 10^{-118}:\\ \;\;\;\;d \cdot \frac{-a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 4800000:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{-d}\\ \end{array} \]
      9. Add Preprocessing

      Alternative 9: 65.3% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{-d}\\ \mathbf{if}\;d \leq -1.58 \cdot 10^{+72}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -4.4 \cdot 10^{-112}:\\ \;\;\;\;a \cdot \frac{-d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 4800000:\\ \;\;\;\;\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 -1.58e+72)
           t_0
           (if (<= d -4.4e-112)
             (* a (/ (- d) (fma d d (* c c))))
             (if (<= d 4800000.0) (/ b c) t_0)))))
      double code(double a, double b, double c, double d) {
      	double t_0 = a / -d;
      	double tmp;
      	if (d <= -1.58e+72) {
      		tmp = t_0;
      	} else if (d <= -4.4e-112) {
      		tmp = a * (-d / fma(d, d, (c * c)));
      	} else if (d <= 4800000.0) {
      		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 <= -1.58e+72)
      		tmp = t_0;
      	elseif (d <= -4.4e-112)
      		tmp = Float64(a * Float64(Float64(-d) / fma(d, d, Float64(c * c))));
      	elseif (d <= 4800000.0)
      		tmp = Float64(b / c);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -1.58e+72], t$95$0, If[LessEqual[d, -4.4e-112], N[(a * N[((-d) / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4800000.0], N[(b / c), $MachinePrecision], t$95$0]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{a}{-d}\\
      \mathbf{if}\;d \leq -1.58 \cdot 10^{+72}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;d \leq -4.4 \cdot 10^{-112}:\\
      \;\;\;\;a \cdot \frac{-d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
      
      \mathbf{elif}\;d \leq 4800000:\\
      \;\;\;\;\frac{b}{c}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if d < -1.58000000000000006e72 or 4.8e6 < d

        1. Initial program 46.0%

          \[\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.f6471.3

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

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

        if -1.58000000000000006e72 < d < -4.40000000000000042e-112

        1. Initial program 82.3%

          \[\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. lower-neg.f64N/A

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

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

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

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

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

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

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

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

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

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

        if -4.40000000000000042e-112 < d < 4.8e6

        1. Initial program 68.0%

          \[\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-/.f6481.0

            \[\leadsto \color{blue}{\frac{b}{c}} \]
        5. Applied rewrites81.0%

          \[\leadsto \color{blue}{\frac{b}{c}} \]
      3. Recombined 3 regimes into one program.
      4. Final simplification74.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.58 \cdot 10^{+72}:\\ \;\;\;\;\frac{a}{-d}\\ \mathbf{elif}\;d \leq -4.4 \cdot 10^{-112}:\\ \;\;\;\;a \cdot \frac{-d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 4800000:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{-d}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 10: 64.8% accurate, 1.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{a}{-d}\\ \mathbf{if}\;d \leq -8.8 \cdot 10^{+17}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 4800000:\\ \;\;\;\;\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 -8.8e+17) t_0 (if (<= d 4800000.0) (/ b c) t_0))))
      double code(double a, double b, double c, double d) {
      	double t_0 = a / -d;
      	double tmp;
      	if (d <= -8.8e+17) {
      		tmp = t_0;
      	} else if (d <= 4800000.0) {
      		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 <= (-8.8d+17)) then
              tmp = t_0
          else if (d <= 4800000.0d0) 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 <= -8.8e+17) {
      		tmp = t_0;
      	} else if (d <= 4800000.0) {
      		tmp = b / c;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(a, b, c, d):
      	t_0 = a / -d
      	tmp = 0
      	if d <= -8.8e+17:
      		tmp = t_0
      	elif d <= 4800000.0:
      		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 <= -8.8e+17)
      		tmp = t_0;
      	elseif (d <= 4800000.0)
      		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 <= -8.8e+17)
      		tmp = t_0;
      	elseif (d <= 4800000.0)
      		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, -8.8e+17], t$95$0, If[LessEqual[d, 4800000.0], N[(b / c), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{a}{-d}\\
      \mathbf{if}\;d \leq -8.8 \cdot 10^{+17}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;d \leq 4800000:\\
      \;\;\;\;\frac{b}{c}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if d < -8.8e17 or 4.8e6 < d

        1. Initial program 49.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}} \]
        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.f6468.2

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

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

        if -8.8e17 < d < 4.8e6

        1. Initial program 70.3%

          \[\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-/.f6475.8

            \[\leadsto \color{blue}{\frac{b}{c}} \]
        5. Applied rewrites75.8%

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

      Alternative 11: 43.3% 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 60.6%

        \[\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-/.f6449.5

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

        \[\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 2024232 
      (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))))