Complex division, imag part

Percentage Accurate: 62.3% → 80.5%
Time: 7.3s
Alternatives: 8
Speedup: 0.9×

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 8 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: 62.3% 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: 80.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{d}, c, -a\right)}{d}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -3.0000000000000001e-71

    1. Initial program 55.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-/.f6415.8

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

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

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} - a}{d} \]
      11. lower-*.f6486.4

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

      \[\leadsto \color{blue}{\frac{\frac{c \cdot b}{d} - a}{d}} \]
    9. Step-by-step derivation
      1. Applied rewrites89.2%

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

      if -3.0000000000000001e-71 < d < 1.65999999999999993e-130

      1. Initial program 67.4%

        \[\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. lower-*.f6490.6

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

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

      if 1.65999999999999993e-130 < d < 7.60000000000000015e112

      1. Initial program 79.2%

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

      if 7.60000000000000015e112 < d

      1. Initial program 38.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-/.f6410.2

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{c \cdot b}{d} - a}{d}} \]
      9. Step-by-step derivation
        1. Applied rewrites90.8%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{d}, c, -a\right)}{d}\\ \mathbf{elif}\;d \leq 1.66 \cdot 10^{-130}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 7.6 \cdot 10^{+112}:\\ \;\;\;\;\frac{c \cdot b - a \cdot d}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \end{array} \]
      12. Add Preprocessing

      Alternative 2: 72.1% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{+129}:\\ \;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (let* ((t_0 (/ (- a) d)))
         (if (<= d -3e-71)
           t_0
           (if (<= d 1.75e-81)
             (/ (- b (/ (* a d) c)) c)
             (if (<= d 2.5e+129) (* (/ d (fma c c (* d d))) (- a)) t_0)))))
      double code(double a, double b, double c, double d) {
      	double t_0 = -a / d;
      	double tmp;
      	if (d <= -3e-71) {
      		tmp = t_0;
      	} else if (d <= 1.75e-81) {
      		tmp = (b - ((a * d) / c)) / c;
      	} else if (d <= 2.5e+129) {
      		tmp = (d / fma(c, c, (d * d))) * -a;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(a, b, c, d)
      	t_0 = Float64(Float64(-a) / d)
      	tmp = 0.0
      	if (d <= -3e-71)
      		tmp = t_0;
      	elseif (d <= 1.75e-81)
      		tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c);
      	elseif (d <= 2.5e+129)
      		tmp = Float64(Float64(d / fma(c, c, Float64(d * d))) * Float64(-a));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -3e-71], t$95$0, If[LessEqual[d, 1.75e-81], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.5e+129], N[(N[(d / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision], t$95$0]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{-a}{d}\\
      \mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\
      \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
      
      \mathbf{elif}\;d \leq 2.5 \cdot 10^{+129}:\\
      \;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if d < -3.0000000000000001e-71 or 2.5000000000000001e129 < d

        1. Initial program 48.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}} \]
        4. Step-by-step derivation
          1. associate-*r/N/A

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

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

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

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

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

        if -3.0000000000000001e-71 < d < 1.74999999999999993e-81

        1. Initial program 68.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. lower-*.f6488.7

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

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

        if 1.74999999999999993e-81 < d < 2.5000000000000001e129

        1. Initial program 78.6%

          \[\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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{+129}:\\ \;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
      5. Add Preprocessing

      Alternative 3: 63.3% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -2.7 \cdot 10^{-71}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{-170}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 9 \cdot 10^{+113}:\\ \;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (let* ((t_0 (/ (- a) d)))
         (if (<= d -2.7e-71)
           t_0
           (if (<= d 2.7e-170)
             (/ b c)
             (if (<= d 9e+113) (* (/ d (fma c c (* d d))) (- a)) t_0)))))
      double code(double a, double b, double c, double d) {
      	double t_0 = -a / d;
      	double tmp;
      	if (d <= -2.7e-71) {
      		tmp = t_0;
      	} else if (d <= 2.7e-170) {
      		tmp = b / c;
      	} else if (d <= 9e+113) {
      		tmp = (d / fma(c, c, (d * d))) * -a;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(a, b, c, d)
      	t_0 = Float64(Float64(-a) / d)
      	tmp = 0.0
      	if (d <= -2.7e-71)
      		tmp = t_0;
      	elseif (d <= 2.7e-170)
      		tmp = Float64(b / c);
      	elseif (d <= 9e+113)
      		tmp = Float64(Float64(d / fma(c, c, Float64(d * d))) * Float64(-a));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -2.7e-71], t$95$0, If[LessEqual[d, 2.7e-170], N[(b / c), $MachinePrecision], If[LessEqual[d, 9e+113], N[(N[(d / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-a)), $MachinePrecision], t$95$0]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{-a}{d}\\
      \mathbf{if}\;d \leq -2.7 \cdot 10^{-71}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;d \leq 2.7 \cdot 10^{-170}:\\
      \;\;\;\;\frac{b}{c}\\
      
      \mathbf{elif}\;d \leq 9 \cdot 10^{+113}:\\
      \;\;\;\;\frac{d}{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \left(-a\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if d < -2.7000000000000001e-71 or 9.0000000000000001e113 < 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}} \]
        4. Step-by-step derivation
          1. associate-*r/N/A

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

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

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

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

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

        if -2.7000000000000001e-71 < d < 2.6999999999999999e-170

        1. Initial program 67.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}{c}} \]
        4. Step-by-step derivation
          1. lower-/.f6472.7

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

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

        if 2.6999999999999999e-170 < d < 9.0000000000000001e113

        1. Initial program 77.1%

          \[\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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 4: 76.9% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{d}, c, -a\right)}{d}\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \end{array} \end{array} \]
      (FPCore (a b c d)
       :precision binary64
       (if (<= d -3e-71)
         (/ (fma (/ b d) c (- a)) d)
         (if (<= d 1.75e-81) (/ (- b (/ (* a d) c)) c) (/ (fma b (/ c d) (- a)) d))))
      double code(double a, double b, double c, double d) {
      	double tmp;
      	if (d <= -3e-71) {
      		tmp = fma((b / d), c, -a) / d;
      	} else if (d <= 1.75e-81) {
      		tmp = (b - ((a * d) / c)) / c;
      	} else {
      		tmp = fma(b, (c / d), -a) / d;
      	}
      	return tmp;
      }
      
      function code(a, b, c, d)
      	tmp = 0.0
      	if (d <= -3e-71)
      		tmp = Float64(fma(Float64(b / d), c, Float64(-a)) / d);
      	elseif (d <= 1.75e-81)
      		tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c);
      	else
      		tmp = Float64(fma(b, Float64(c / d), Float64(-a)) / d);
      	end
      	return tmp
      end
      
      code[a_, b_, c_, d_] := If[LessEqual[d, -3e-71], N[(N[(N[(b / d), $MachinePrecision] * c + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, 1.75e-81], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(\frac{b}{d}, c, -a\right)}{d}\\
      
      \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\
      \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if d < -3.0000000000000001e-71

        1. Initial program 55.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-/.f6415.8

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

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

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

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

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

            \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} - a}{d} \]
          11. lower-*.f6486.4

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

          \[\leadsto \color{blue}{\frac{\frac{c \cdot b}{d} - a}{d}} \]
        9. Step-by-step derivation
          1. Applied rewrites89.2%

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

          if -3.0000000000000001e-71 < d < 1.74999999999999993e-81

          1. Initial program 68.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. lower-*.f6488.7

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

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

          if 1.74999999999999993e-81 < d

          1. Initial program 59.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-/.f6422.1

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{\frac{c \cdot b}{d} - a}{d}} \]
          9. Step-by-step derivation
            1. Applied rewrites74.1%

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

          Alternative 5: 76.9% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\ \mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (a b c d)
           :precision binary64
           (let* ((t_0 (/ (fma b (/ c d) (- a)) d)))
             (if (<= d -3e-71) t_0 (if (<= d 1.75e-81) (/ (- b (/ (* a d) c)) c) t_0))))
          double code(double a, double b, double c, double d) {
          	double t_0 = fma(b, (c / d), -a) / d;
          	double tmp;
          	if (d <= -3e-71) {
          		tmp = t_0;
          	} else if (d <= 1.75e-81) {
          		tmp = (b - ((a * d) / c)) / c;
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          function code(a, b, c, d)
          	t_0 = Float64(fma(b, Float64(c / d), Float64(-a)) / d)
          	tmp = 0.0
          	if (d <= -3e-71)
          		tmp = t_0;
          	elseif (d <= 1.75e-81)
          		tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c);
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * N[(c / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -3e-71], t$95$0, If[LessEqual[d, 1.75e-81], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{\mathsf{fma}\left(b, \frac{c}{d}, -a\right)}{d}\\
          \mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\
          \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if d < -3.0000000000000001e-71 or 1.74999999999999993e-81 < d

            1. Initial program 57.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-/.f6419.2

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

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

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

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

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

                \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} - a}{d} \]
              11. lower-*.f6477.9

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

              \[\leadsto \color{blue}{\frac{\frac{c \cdot b}{d} - a}{d}} \]
            9. Step-by-step derivation
              1. Applied rewrites81.1%

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

              if -3.0000000000000001e-71 < d < 1.74999999999999993e-81

              1. Initial program 68.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. lower-*.f6488.7

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

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

            Alternative 6: 75.0% 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 \cdot 10^{-71}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{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 -3e-71) t_0 (if (<= d 1.75e-81) (/ (- b (/ (* a d) 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 <= -3e-71) {
            		tmp = t_0;
            	} else if (d <= 1.75e-81) {
            		tmp = (b - ((a * d) / 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 <= (-3d-71)) then
                    tmp = t_0
                else if (d <= 1.75d-81) then
                    tmp = (b - ((a * d) / 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 <= -3e-71) {
            		tmp = t_0;
            	} else if (d <= 1.75e-81) {
            		tmp = (b - ((a * d) / 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 <= -3e-71:
            		tmp = t_0
            	elif d <= 1.75e-81:
            		tmp = (b - ((a * d) / 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 <= -3e-71)
            		tmp = t_0;
            	elseif (d <= 1.75e-81)
            		tmp = Float64(Float64(b - Float64(Float64(a * d) / 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 <= -3e-71)
            		tmp = t_0;
            	elseif (d <= 1.75e-81)
            		tmp = (b - ((a * d) / 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, -3e-71], t$95$0, If[LessEqual[d, 1.75e-81], N[(N[(b - N[(N[(a * d), $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 \cdot 10^{-71}:\\
            \;\;\;\;t\_0\\
            
            \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\
            \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if d < -3.0000000000000001e-71 or 1.74999999999999993e-81 < d

              1. Initial program 57.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. lower--.f64N/A

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

                  \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d}} - a}{d} \]
                10. lower-*.f6477.9

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

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

              if -3.0000000000000001e-71 < d < 1.74999999999999993e-81

              1. Initial program 68.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. lower-*.f6488.7

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

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3 \cdot 10^{-71}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 1.75 \cdot 10^{-81}:\\ \;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \end{array} \]
            5. Add Preprocessing

            Alternative 7: 62.0% accurate, 1.5× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -2.7 \cdot 10^{-71}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{-81}:\\ \;\;\;\;\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 -2.7e-71) t_0 (if (<= d 1.1e-81) (/ b c) t_0))))
            double code(double a, double b, double c, double d) {
            	double t_0 = -a / d;
            	double tmp;
            	if (d <= -2.7e-71) {
            		tmp = t_0;
            	} else if (d <= 1.1e-81) {
            		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 <= (-2.7d-71)) then
                    tmp = t_0
                else if (d <= 1.1d-81) 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 <= -2.7e-71) {
            		tmp = t_0;
            	} else if (d <= 1.1e-81) {
            		tmp = b / c;
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            def code(a, b, c, d):
            	t_0 = -a / d
            	tmp = 0
            	if d <= -2.7e-71:
            		tmp = t_0
            	elif d <= 1.1e-81:
            		tmp = b / c
            	else:
            		tmp = t_0
            	return tmp
            
            function code(a, b, c, d)
            	t_0 = Float64(Float64(-a) / d)
            	tmp = 0.0
            	if (d <= -2.7e-71)
            		tmp = t_0;
            	elseif (d <= 1.1e-81)
            		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 <= -2.7e-71)
            		tmp = t_0;
            	elseif (d <= 1.1e-81)
            		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, -2.7e-71], t$95$0, If[LessEqual[d, 1.1e-81], N[(b / c), $MachinePrecision], t$95$0]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \frac{-a}{d}\\
            \mathbf{if}\;d \leq -2.7 \cdot 10^{-71}:\\
            \;\;\;\;t\_0\\
            
            \mathbf{elif}\;d \leq 1.1 \cdot 10^{-81}:\\
            \;\;\;\;\frac{b}{c}\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if d < -2.7000000000000001e-71 or 1.1e-81 < d

              1. Initial program 57.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}} \]
              4. Step-by-step derivation
                1. associate-*r/N/A

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

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

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

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

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

              if -2.7000000000000001e-71 < d < 1.1e-81

              1. Initial program 68.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}{c}} \]
              4. Step-by-step derivation
                1. lower-/.f6468.9

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

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

            Alternative 8: 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 61.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-/.f6438.8

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

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

            Developer Target 1: 99.3% 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 2024270 
            (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))))