Complex division, imag part

Percentage Accurate: 61.5% → 80.2%
Time: 10.0s
Alternatives: 12
Speedup: 1.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 61.5% 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.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(c, c, d \cdot d\right)\\ t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \mathbf{if}\;d \leq -1.2 \cdot 10^{+68}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq -1.8 \cdot 10^{-85}:\\ \;\;\;\;\mathsf{fma}\left(d, \frac{0 - a}{t\_0}, \frac{c \cdot b}{t\_0}\right)\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-14}:\\ \;\;\;\;\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 c c (* d d))) (t_1 (/ (fma c (/ b d) (- 0.0 a)) d)))
   (if (<= d -1.2e+68)
     t_1
     (if (<= d -1.8e-85)
       (fma d (/ (- 0.0 a) t_0) (/ (* c b) t_0))
       (if (<= d 1.4e-14) (/ (- b (/ (* d a) c)) c) t_1)))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(c, c, (d * d));
	double t_1 = fma(c, (b / d), (0.0 - a)) / d;
	double tmp;
	if (d <= -1.2e+68) {
		tmp = t_1;
	} else if (d <= -1.8e-85) {
		tmp = fma(d, ((0.0 - a) / t_0), ((c * b) / t_0));
	} else if (d <= 1.4e-14) {
		tmp = (b - ((d * a) / c)) / c;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(c, c, Float64(d * d))
	t_1 = Float64(fma(c, Float64(b / d), Float64(0.0 - a)) / d)
	tmp = 0.0
	if (d <= -1.2e+68)
		tmp = t_1;
	elseif (d <= -1.8e-85)
		tmp = fma(d, Float64(Float64(0.0 - a) / t_0), Float64(Float64(c * b) / t_0));
	elseif (d <= 1.4e-14)
		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[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * N[(b / d), $MachinePrecision] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.2e+68], t$95$1, If[LessEqual[d, -1.8e-85], N[(d * N[(N[(0.0 - a), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.4e-14], 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(c, c, d \cdot d\right)\\
t_1 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -1.2 \cdot 10^{+68}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 1.4 \cdot 10^{-14}:\\
\;\;\;\;\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 < -1.20000000000000004e68 or 1.4e-14 < d

    1. Initial program 54.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \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. /-lowering-/.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. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{0 - a}\right)}{d} \]
      16. --lowering--.f6485.5

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

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

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

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

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

    if -1.20000000000000004e68 < d < -1.7999999999999999e-85

    1. Initial program 78.6%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. 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}} \]
      2. 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)} \]
      3. +-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}} \]
      4. *-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} \]
      5. 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} \]
      6. distribute-rgt-neg-inN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(d, \mathsf{neg}\left(\frac{a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right), \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      16. *-lowering-*.f6478.6

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

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

    if -1.7999999999999999e-85 < d < 1.4e-14

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. /-lowering-/.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. *-lowering-*.f6487.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.2 \cdot 10^{+68}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \mathbf{elif}\;d \leq -1.8 \cdot 10^{-85}:\\ \;\;\;\;\mathsf{fma}\left(d, \frac{0 - a}{\mathsf{fma}\left(c, c, d \cdot d\right)}, \frac{c \cdot b}{\mathsf{fma}\left(c, c, d \cdot d\right)}\right)\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-14}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 65.6% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;c \leq -2.35 \cdot 10^{-128}:\\
\;\;\;\;\frac{c \cdot b}{t\_0}\\

\mathbf{elif}\;c \leq 2.7 \cdot 10^{-11}:\\
\;\;\;\;0 - \frac{a}{d}\\

\mathbf{elif}\;c \leq 1.85 \cdot 10^{+90}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{b}{t\_0}, 0\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.12000000000000003e104 or 1.85e90 < c

    1. Initial program 39.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}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6473.5

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

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

    if -1.12000000000000003e104 < c < -2.3500000000000002e-128

    1. Initial program 87.4%

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

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      3. *-lowering-*.f6487.4

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{{d}^{2} + {c}^{2}}} \]
      5. unpow2N/A

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d} + {c}^{2}} \]
      6. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \frac{c \cdot b}{\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)} \]
      8. *-lowering-*.f6466.6

        \[\leadsto \frac{c \cdot b}{\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)} \]
    7. Simplified66.6%

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

    if -2.3500000000000002e-128 < c < 2.70000000000000005e-11

    1. Initial program 72.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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6472.7

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

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

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

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

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

    if 2.70000000000000005e-11 < c < 1.85e90

    1. Initial program 75.6%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{c}^{2} + {d}^{2}} + 0} \]
      2. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{c \cdot b}}{{c}^{2} + {d}^{2}} + 0 \]
      3. associate-/l*N/A

        \[\leadsto \color{blue}{c \cdot \frac{b}{{c}^{2} + {d}^{2}}} + 0 \]
      4. accelerator-lowering-fma.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(c, \frac{b}{\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)}, 0\right) \]
      10. *-lowering-*.f6468.2

        \[\leadsto \mathsf{fma}\left(c, \frac{b}{\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)}, 0\right) \]
    5. Simplified68.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.12 \cdot 10^{+104}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -2.35 \cdot 10^{-128}:\\ \;\;\;\;\frac{c \cdot b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{-11}:\\ \;\;\;\;0 - \frac{a}{d}\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{+90}:\\ \;\;\;\;\mathsf{fma}\left(c, \frac{b}{\mathsf{fma}\left(d, d, c \cdot c\right)}, 0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 80.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \mathbf{if}\;d \leq -1.4 \cdot 10^{+68}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -5.7 \cdot 10^{-89}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 3.9 \cdot 10^{-16}:\\ \;\;\;\;\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) (- 0.0 a)) d)))
   (if (<= d -1.4e+68)
     t_0
     (if (<= d -5.7e-89)
       (/ (- (* c b) (* d a)) (fma d d (* c c)))
       (if (<= d 3.9e-16) (/ (- b (/ (* d a) c)) c) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(c, (b / d), (0.0 - a)) / d;
	double tmp;
	if (d <= -1.4e+68) {
		tmp = t_0;
	} else if (d <= -5.7e-89) {
		tmp = ((c * b) - (d * a)) / fma(d, d, (c * c));
	} else if (d <= 3.9e-16) {
		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(0.0 - a)) / d)
	tmp = 0.0
	if (d <= -1.4e+68)
		tmp = t_0;
	elseif (d <= -5.7e-89)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(d, d, Float64(c * c)));
	elseif (d <= 3.9e-16)
		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] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.4e+68], t$95$0, If[LessEqual[d, -5.7e-89], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.9e-16], 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}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -1.4 \cdot 10^{+68}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;d \leq 3.9 \cdot 10^{-16}:\\
\;\;\;\;\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.4e68 or 3.89999999999999977e-16 < d

    1. Initial program 54.6%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \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. /-lowering-/.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. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{0 - a}\right)}{d} \]
      16. --lowering--.f6485.5

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

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

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

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

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

    if -1.4e68 < d < -5.7000000000000002e-89

    1. Initial program 78.6%

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

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      3. *-lowering-*.f6478.6

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

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

    if -5.7000000000000002e-89 < d < 3.89999999999999977e-16

    1. Initial program 65.9%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. /-lowering-/.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. *-lowering-*.f6487.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.4 \cdot 10^{+68}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \mathbf{elif}\;d \leq -5.7 \cdot 10^{-89}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;d \leq 3.9 \cdot 10^{-16}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 71.2% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;d \leq 7.5 \cdot 10^{-29}:\\
\;\;\;\;\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 < -3.9999999999999996e165 or 7.50000000000000006e-29 < d

    1. Initial program 53.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}} \]
    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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6476.3

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

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

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      2. neg-lowering-neg.f6476.3

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr76.3%

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

    if -3.9999999999999996e165 < d < -1.60000000000000006e-9

    1. Initial program 69.1%

      \[\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. *-lowering-*.f6457.6

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

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

    if -1.60000000000000006e-9 < d < 7.50000000000000006e-29

    1. Initial program 67.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. /-lowering-/.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. --lowering--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. /-lowering-/.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. *-lowering-*.f6485.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4 \cdot 10^{+165}:\\ \;\;\;\;0 - \frac{a}{d}\\ \mathbf{elif}\;d \leq -1.6 \cdot 10^{-9}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{-29}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;0 - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 77.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\mathsf{fma}\left(c, \frac{b}{d}, 0 - a\right)}{d}\\ \mathbf{if}\;d \leq -1.7 \cdot 10^{-9}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 3.6 \cdot 10^{-18}:\\ \;\;\;\;\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) (- 0.0 a)) d)))
   (if (<= d -1.7e-9) t_0 (if (<= d 3.6e-18) (/ (- b (/ (* d a) c)) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(c, (b / d), (0.0 - a)) / d;
	double tmp;
	if (d <= -1.7e-9) {
		tmp = t_0;
	} else if (d <= 3.6e-18) {
		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(0.0 - a)) / d)
	tmp = 0.0
	if (d <= -1.7e-9)
		tmp = t_0;
	elseif (d <= 3.6e-18)
		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] + N[(0.0 - a), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.7e-9], t$95$0, If[LessEqual[d, 3.6e-18], 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}, 0 - a\right)}{d}\\
\mathbf{if}\;d \leq -1.7 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d \leq 3.6 \cdot 10^{-18}:\\
\;\;\;\;\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 < -1.6999999999999999e-9 or 3.6000000000000001e-18 < d

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(c, \frac{b}{d}, -1 \cdot a\right)}}{d} \]
      13. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{b}{d}, \color{blue}{0 - a}\right)}{d} \]
      16. --lowering--.f6481.2

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

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

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

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

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

    if -1.6999999999999999e-9 < d < 3.6000000000000001e-18

    1. Initial program 67.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 + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. /-lowering-/.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. *-lowering-*.f6485.0

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

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

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

Alternative 6: 78.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{if}\;c \leq -8.5 \cdot 10^{-61}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 1.95 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- b (* a (/ d c))) c)))
   (if (<= c -8.5e-61)
     t_0
     (if (<= c 1.95e-10) (/ (- (/ (* c b) d) a) d) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = (b - (a * (d / c))) / c;
	double tmp;
	if (c <= -8.5e-61) {
		tmp = t_0;
	} else if (c <= 1.95e-10) {
		tmp = (((c * b) / d) - a) / d;
	} 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 - (a * (d / c))) / c
    if (c <= (-8.5d-61)) then
        tmp = t_0
    else if (c <= 1.95d-10) then
        tmp = (((c * b) / d) - a) / d
    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 - (a * (d / c))) / c;
	double tmp;
	if (c <= -8.5e-61) {
		tmp = t_0;
	} else if (c <= 1.95e-10) {
		tmp = (((c * b) / d) - a) / d;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b - (a * (d / c))) / c
	tmp = 0
	if c <= -8.5e-61:
		tmp = t_0
	elif c <= 1.95e-10:
		tmp = (((c * b) / d) - a) / d
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b - Float64(a * Float64(d / c))) / c)
	tmp = 0.0
	if (c <= -8.5e-61)
		tmp = t_0;
	elseif (c <= 1.95e-10)
		tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b - (a * (d / c))) / c;
	tmp = 0.0;
	if (c <= -8.5e-61)
		tmp = t_0;
	elseif (c <= 1.95e-10)
		tmp = (((c * b) / d) - a) / d;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -8.5e-61], t$95$0, If[LessEqual[c, 1.95e-10], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -8.50000000000000016e-61 or 1.95e-10 < c

    1. Initial program 52.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. /-lowering-/.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. --lowering--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. /-lowering-/.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. *-lowering-*.f6472.5

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

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

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

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

        \[\leadsto \frac{b - \color{blue}{a \cdot \frac{d}{c}}}{c} \]
      4. /-lowering-/.f6473.4

        \[\leadsto \frac{b - a \cdot \color{blue}{\frac{d}{c}}}{c} \]
    7. Applied egg-rr73.4%

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

    if -8.50000000000000016e-61 < c < 1.95e-10

    1. Initial program 74.6%

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

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      3. *-lowering-*.f6474.6

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} - a}}{d} \]
      9. /-lowering-/.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. *-lowering-*.f6487.3

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} - a}{d} \]
    7. Simplified87.3%

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

Alternative 7: 70.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0 - \frac{a}{d}\\ \mathbf{if}\;d \leq -1.7 \cdot 10^{+68}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{-29}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- 0.0 (/ a d))))
   (if (<= d -1.7e+68) t_0 (if (<= d 7.5e-29) (/ (- b (* a (/ d c))) c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = 0.0 - (a / d);
	double tmp;
	if (d <= -1.7e+68) {
		tmp = t_0;
	} else if (d <= 7.5e-29) {
		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 = 0.0d0 - (a / d)
    if (d <= (-1.7d+68)) then
        tmp = t_0
    else if (d <= 7.5d-29) 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 = 0.0 - (a / d);
	double tmp;
	if (d <= -1.7e+68) {
		tmp = t_0;
	} else if (d <= 7.5e-29) {
		tmp = (b - (a * (d / c))) / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = 0.0 - (a / d)
	tmp = 0
	if d <= -1.7e+68:
		tmp = t_0
	elif d <= 7.5e-29:
		tmp = (b - (a * (d / c))) / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(0.0 - Float64(a / d))
	tmp = 0.0
	if (d <= -1.7e+68)
		tmp = t_0;
	elseif (d <= 7.5e-29)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = 0.0 - (a / d);
	tmp = 0.0;
	if (d <= -1.7e+68)
		tmp = t_0;
	elseif (d <= 7.5e-29)
		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[(0.0 - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.7e+68], t$95$0, If[LessEqual[d, 7.5e-29], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.70000000000000008e68 or 7.50000000000000006e-29 < d

    1. Initial program 55.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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6472.2

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

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

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

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr72.2%

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

    if -1.70000000000000008e68 < d < 7.50000000000000006e-29

    1. Initial program 68.1%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. /-lowering-/.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. --lowering--.f64N/A

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      5. /-lowering-/.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. *-lowering-*.f6479.6

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

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

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

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

        \[\leadsto \frac{b - \color{blue}{a \cdot \frac{d}{c}}}{c} \]
      4. /-lowering-/.f6479.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.7 \cdot 10^{+68}:\\ \;\;\;\;0 - \frac{a}{d}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{-29}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;0 - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 63.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0 - \frac{a}{d}\\ \mathbf{if}\;d \leq -4 \cdot 10^{+165}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -2.4 \cdot 10^{-10}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-31}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- 0.0 (/ a d))))
   (if (<= d -4e+165)
     t_0
     (if (<= d -2.4e-10)
       (/ (- (* c b) (* d a)) (* d d))
       (if (<= d 1.4e-31) (/ b c) t_0)))))
double code(double a, double b, double c, double d) {
	double t_0 = 0.0 - (a / d);
	double tmp;
	if (d <= -4e+165) {
		tmp = t_0;
	} else if (d <= -2.4e-10) {
		tmp = ((c * b) - (d * a)) / (d * d);
	} else if (d <= 1.4e-31) {
		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 = 0.0d0 - (a / d)
    if (d <= (-4d+165)) then
        tmp = t_0
    else if (d <= (-2.4d-10)) then
        tmp = ((c * b) - (d * a)) / (d * d)
    else if (d <= 1.4d-31) 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 = 0.0 - (a / d);
	double tmp;
	if (d <= -4e+165) {
		tmp = t_0;
	} else if (d <= -2.4e-10) {
		tmp = ((c * b) - (d * a)) / (d * d);
	} else if (d <= 1.4e-31) {
		tmp = b / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = 0.0 - (a / d)
	tmp = 0
	if d <= -4e+165:
		tmp = t_0
	elif d <= -2.4e-10:
		tmp = ((c * b) - (d * a)) / (d * d)
	elif d <= 1.4e-31:
		tmp = b / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(0.0 - Float64(a / d))
	tmp = 0.0
	if (d <= -4e+165)
		tmp = t_0;
	elseif (d <= -2.4e-10)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(d * d));
	elseif (d <= 1.4e-31)
		tmp = Float64(b / c);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = 0.0 - (a / d);
	tmp = 0.0;
	if (d <= -4e+165)
		tmp = t_0;
	elseif (d <= -2.4e-10)
		tmp = ((c * b) - (d * a)) / (d * d);
	elseif (d <= 1.4e-31)
		tmp = b / c;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(0.0 - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4e+165], t$95$0, If[LessEqual[d, -2.4e-10], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.4e-31], N[(b / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.9999999999999996e165 or 1.3999999999999999e-31 < d

    1. Initial program 54.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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6475.8

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
    5. Simplified75.8%

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

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      2. neg-lowering-neg.f6475.8

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr75.8%

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

    if -3.9999999999999996e165 < d < -2.4e-10

    1. Initial program 69.1%

      \[\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. *-lowering-*.f6457.6

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

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

    if -2.4e-10 < d < 1.3999999999999999e-31

    1. Initial program 66.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. /-lowering-/.f6470.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4 \cdot 10^{+165}:\\ \;\;\;\;0 - \frac{a}{d}\\ \mathbf{elif}\;d \leq -2.4 \cdot 10^{-10}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-31}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;0 - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 64.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.1 \cdot 10^{+103}:\\
\;\;\;\;\frac{b}{c}\\

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

\mathbf{elif}\;c \leq 4.8 \cdot 10^{-9}:\\
\;\;\;\;0 - \frac{a}{d}\\

\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.09999999999999996e103 or 4.8e-9 < c

    1. Initial program 45.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. /-lowering-/.f6469.0

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

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

    if -1.09999999999999996e103 < c < -3.40000000000000013e-129

    1. Initial program 87.4%

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

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

        \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}} \]
      3. *-lowering-*.f6487.4

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

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

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

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

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

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

        \[\leadsto \frac{c \cdot b}{\color{blue}{{d}^{2} + {c}^{2}}} \]
      5. unpow2N/A

        \[\leadsto \frac{c \cdot b}{\color{blue}{d \cdot d} + {c}^{2}} \]
      6. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \frac{c \cdot b}{\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)} \]
      8. *-lowering-*.f6466.6

        \[\leadsto \frac{c \cdot b}{\mathsf{fma}\left(d, d, \color{blue}{c \cdot c}\right)} \]
    7. Simplified66.6%

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

    if -3.40000000000000013e-129 < c < 4.8e-9

    1. Initial program 72.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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6472.7

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.1 \cdot 10^{+103}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -3.4 \cdot 10^{-129}:\\ \;\;\;\;\frac{c \cdot b}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{-9}:\\ \;\;\;\;0 - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 62.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0 - \frac{a}{d}\\ \mathbf{if}\;d \leq -1.7 \cdot 10^{+68}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-31}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- 0.0 (/ a d))))
   (if (<= d -1.7e+68) t_0 (if (<= d 1.4e-31) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
	double t_0 = 0.0 - (a / d);
	double tmp;
	if (d <= -1.7e+68) {
		tmp = t_0;
	} else if (d <= 1.4e-31) {
		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 = 0.0d0 - (a / d)
    if (d <= (-1.7d+68)) then
        tmp = t_0
    else if (d <= 1.4d-31) 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 = 0.0 - (a / d);
	double tmp;
	if (d <= -1.7e+68) {
		tmp = t_0;
	} else if (d <= 1.4e-31) {
		tmp = b / c;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = 0.0 - (a / d)
	tmp = 0
	if d <= -1.7e+68:
		tmp = t_0
	elif d <= 1.4e-31:
		tmp = b / c
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(0.0 - Float64(a / d))
	tmp = 0.0
	if (d <= -1.7e+68)
		tmp = t_0;
	elseif (d <= 1.4e-31)
		tmp = Float64(b / c);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = 0.0 - (a / d);
	tmp = 0.0;
	if (d <= -1.7e+68)
		tmp = t_0;
	elseif (d <= 1.4e-31)
		tmp = b / c;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(0.0 - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.7e+68], t$95$0, If[LessEqual[d, 1.4e-31], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.70000000000000008e68 or 1.3999999999999999e-31 < d

    1. Initial program 55.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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6471.9

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
    5. Simplified71.9%

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

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      2. neg-lowering-neg.f6471.9

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr71.9%

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

    if -1.70000000000000008e68 < d < 1.3999999999999999e-31

    1. Initial program 67.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. /-lowering-/.f6465.3

        \[\leadsto \color{blue}{\frac{b}{c}} \]
    5. Simplified65.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.7 \cdot 10^{+68}:\\ \;\;\;\;0 - \frac{a}{d}\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-31}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;0 - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 46.2% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.9 \cdot 10^{+177}:\\
\;\;\;\;\frac{a}{d}\\

\mathbf{elif}\;d \leq 3.2 \cdot 10^{+171}:\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -6.89999999999999971e177 or 3.20000000000000011e171 < d

    1. Initial program 40.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. 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. /-lowering-/.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. neg-sub0N/A

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      7. --lowering--.f6483.1

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

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

        \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
      2. neg-lowering-neg.f6483.1

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
    7. Applied egg-rr83.1%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{{a}^{3}}{{a}^{2}}}}{\mathsf{neg}\left(d\right)} \]
      4. pow2N/A

        \[\leadsto \frac{\frac{{a}^{3}}{\color{blue}{a \cdot a}}}{\mathsf{neg}\left(d\right)} \]
      5. +-rgt-identityN/A

        \[\leadsto \frac{\frac{{a}^{3}}{\color{blue}{a \cdot a + 0}}}{\mathsf{neg}\left(d\right)} \]
      6. mul0-lftN/A

        \[\leadsto \frac{\frac{{a}^{3}}{a \cdot a + \color{blue}{0 \cdot a}}}{\mathsf{neg}\left(d\right)} \]
      7. +-lft-identityN/A

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

        \[\leadsto \frac{\frac{{a}^{3}}{\color{blue}{0 \cdot 0} + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
      9. sqr-powN/A

        \[\leadsto \frac{\frac{\color{blue}{{a}^{\left(\frac{3}{2}\right)} \cdot {a}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
      10. unpow-prod-downN/A

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

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

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

        \[\leadsto \frac{\frac{{\left(\left(0 - a\right) \cdot \color{blue}{\left(0 - a\right)}\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
      14. unpow-prod-downN/A

        \[\leadsto \frac{\frac{\color{blue}{{\left(0 - a\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(0 - a\right)}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
      15. sqr-powN/A

        \[\leadsto \frac{\frac{\color{blue}{{\left(0 - a\right)}^{3}}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
      16. sub0-negN/A

        \[\leadsto \frac{\frac{{\color{blue}{\left(\mathsf{neg}\left(a\right)\right)}}^{3}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
      17. cube-negN/A

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{neg}\left({a}^{3}\right)}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
      18. sub0-negN/A

        \[\leadsto \frac{\frac{\color{blue}{0 - {a}^{3}}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
      19. metadata-evalN/A

        \[\leadsto \frac{\frac{\color{blue}{{0}^{3}} - {a}^{3}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
      20. flip3--N/A

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

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

        \[\leadsto \color{blue}{\frac{a}{d}} \]
      23. /-lowering-/.f6441.3

        \[\leadsto \color{blue}{\frac{a}{d}} \]
    9. Applied egg-rr41.3%

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

    if -6.89999999999999971e177 < d < 3.20000000000000011e171

    1. Initial program 68.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. /-lowering-/.f6451.0

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

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

Alternative 12: 10.7% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \frac{a}{d} \end{array} \]
(FPCore (a b c d) :precision binary64 (/ a d))
double code(double a, double b, double c, double d) {
	return a / 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 = a / d
end function
public static double code(double a, double b, double c, double d) {
	return a / d;
}
def code(a, b, c, d):
	return a / d
function code(a, b, c, d)
	return Float64(a / d)
end
function tmp = code(a, b, c, d)
	tmp = a / d;
end
code[a_, b_, c_, d_] := N[(a / d), $MachinePrecision]
\begin{array}{l}

\\
\frac{a}{d}
\end{array}
Derivation
  1. Initial program 62.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. /-lowering-/.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. neg-sub0N/A

      \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
    7. --lowering--.f6442.7

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

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

      \[\leadsto \frac{a}{\color{blue}{\mathsf{neg}\left(d\right)}} \]
    2. neg-lowering-neg.f6442.7

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{{a}^{3}}{{a}^{2}}}}{\mathsf{neg}\left(d\right)} \]
    4. pow2N/A

      \[\leadsto \frac{\frac{{a}^{3}}{\color{blue}{a \cdot a}}}{\mathsf{neg}\left(d\right)} \]
    5. +-rgt-identityN/A

      \[\leadsto \frac{\frac{{a}^{3}}{\color{blue}{a \cdot a + 0}}}{\mathsf{neg}\left(d\right)} \]
    6. mul0-lftN/A

      \[\leadsto \frac{\frac{{a}^{3}}{a \cdot a + \color{blue}{0 \cdot a}}}{\mathsf{neg}\left(d\right)} \]
    7. +-lft-identityN/A

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

      \[\leadsto \frac{\frac{{a}^{3}}{\color{blue}{0 \cdot 0} + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
    9. sqr-powN/A

      \[\leadsto \frac{\frac{\color{blue}{{a}^{\left(\frac{3}{2}\right)} \cdot {a}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
    10. unpow-prod-downN/A

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

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

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

      \[\leadsto \frac{\frac{{\left(\left(0 - a\right) \cdot \color{blue}{\left(0 - a\right)}\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
    14. unpow-prod-downN/A

      \[\leadsto \frac{\frac{\color{blue}{{\left(0 - a\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(0 - a\right)}^{\left(\frac{3}{2}\right)}}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
    15. sqr-powN/A

      \[\leadsto \frac{\frac{\color{blue}{{\left(0 - a\right)}^{3}}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
    16. sub0-negN/A

      \[\leadsto \frac{\frac{{\color{blue}{\left(\mathsf{neg}\left(a\right)\right)}}^{3}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
    17. cube-negN/A

      \[\leadsto \frac{\frac{\color{blue}{\mathsf{neg}\left({a}^{3}\right)}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
    18. sub0-negN/A

      \[\leadsto \frac{\frac{\color{blue}{0 - {a}^{3}}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
    19. metadata-evalN/A

      \[\leadsto \frac{\frac{\color{blue}{{0}^{3}} - {a}^{3}}{0 \cdot 0 + \left(a \cdot a + 0 \cdot a\right)}}{\mathsf{neg}\left(d\right)} \]
    20. flip3--N/A

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

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

      \[\leadsto \color{blue}{\frac{a}{d}} \]
    23. /-lowering-/.f6412.2

      \[\leadsto \color{blue}{\frac{a}{d}} \]
  9. Applied egg-rr12.2%

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  10. 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 2024195 
(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))))