Complex division, imag part

Percentage Accurate: 61.3% → 92.1%
Time: 11.2s
Alternatives: 12
Speedup: 1.1×

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.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: 92.1% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, t\_0, a \cdot \frac{d}{-{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ t_2 := \frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{if}\;d \leq -2.2 \cdot 10^{+125}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;d \leq -1.8 \cdot 10^{-184}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;d \leq 4 \cdot 10^{-134}:\\ \;\;\;\;t\_0 \cdot \frac{c - \frac{a}{\frac{b}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq 3.95 \cdot 10^{+145}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ b (hypot c d)))
        (t_1 (fma (/ c (hypot c d)) t_0 (* a (/ d (- (pow (hypot c d) 2.0))))))
        (t_2 (/ (- (* c (/ b d)) a) d)))
   (if (<= d -2.2e+125)
     t_2
     (if (<= d -1.8e-184)
       t_1
       (if (<= d 4e-134)
         (* t_0 (/ (- c (/ a (/ b d))) (hypot c d)))
         (if (<= d 3.95e+145) t_1 t_2))))))
double code(double a, double b, double c, double d) {
	double t_0 = b / hypot(c, d);
	double t_1 = fma((c / hypot(c, d)), t_0, (a * (d / -pow(hypot(c, d), 2.0))));
	double t_2 = ((c * (b / d)) - a) / d;
	double tmp;
	if (d <= -2.2e+125) {
		tmp = t_2;
	} else if (d <= -1.8e-184) {
		tmp = t_1;
	} else if (d <= 4e-134) {
		tmp = t_0 * ((c - (a / (b / d))) / hypot(c, d));
	} else if (d <= 3.95e+145) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(b / hypot(c, d))
	t_1 = fma(Float64(c / hypot(c, d)), t_0, Float64(a * Float64(d / Float64(-(hypot(c, d) ^ 2.0)))))
	t_2 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d)
	tmp = 0.0
	if (d <= -2.2e+125)
		tmp = t_2;
	elseif (d <= -1.8e-184)
		tmp = t_1;
	elseif (d <= 4e-134)
		tmp = Float64(t_0 * Float64(Float64(c - Float64(a / Float64(b / d))) / hypot(c, d)));
	elseif (d <= 3.95e+145)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$0 + N[(a * N[(d / (-N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -2.2e+125], t$95$2, If[LessEqual[d, -1.8e-184], t$95$1, If[LessEqual[d, 4e-134], N[(t$95$0 * N[(N[(c - N[(a / N[(b / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.95e+145], t$95$1, t$95$2]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.8 \cdot 10^{-184}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;d \leq 3.95 \cdot 10^{+145}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -2.19999999999999991e125 or 3.9499999999999999e145 < d

    1. Initial program 38.5%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg77.6%

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(-\frac{a}{d}\right)} \]
      3. unsub-neg77.6%

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow277.6%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} - a}{d} \]
      8. associate-/l*91.8%

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

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

    if -2.19999999999999991e125 < d < -1.8000000000000001e-184 or 4.00000000000000016e-134 < d < 3.9499999999999999e145

    1. Initial program 71.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub71.1%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-commutative71.1%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. fma-define71.2%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. add-sqr-sqrt71.2%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. times-frac72.1%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      6. fma-neg72.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      7. fma-define72.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. hypot-define72.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      9. fma-define72.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      10. hypot-define91.4%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      11. associate-/l*95.0%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      12. fma-define95.0%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt95.0%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\right) \]
      14. pow295.0%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}\right)}^{2}}}\right) \]
    4. Applied egg-rr95.0%

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

    if -1.8000000000000001e-184 < d < 4.00000000000000016e-134

    1. Initial program 74.7%

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

      \[\leadsto \frac{\color{blue}{b \cdot \left(c + -1 \cdot \frac{a \cdot d}{b}\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. mul-1-neg74.7%

        \[\leadsto \frac{b \cdot \left(c + \color{blue}{\left(-\frac{a \cdot d}{b}\right)}\right)}{c \cdot c + d \cdot d} \]
      2. unsub-neg74.7%

        \[\leadsto \frac{b \cdot \color{blue}{\left(c - \frac{a \cdot d}{b}\right)}}{c \cdot c + d \cdot d} \]
      3. associate-/l*72.7%

        \[\leadsto \frac{b \cdot \left(c - \color{blue}{a \cdot \frac{d}{b}}\right)}{c \cdot c + d \cdot d} \]
    5. Simplified72.7%

      \[\leadsto \frac{\color{blue}{b \cdot \left(c - a \cdot \frac{d}{b}\right)}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. *-commutative72.7%

        \[\leadsto \frac{\color{blue}{\left(c - a \cdot \frac{d}{b}\right) \cdot b}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt72.7%

        \[\leadsto \frac{\left(c - a \cdot \frac{d}{b}\right) \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. hypot-undefine72.7%

        \[\leadsto \frac{\left(c - a \cdot \frac{d}{b}\right) \cdot b}{\color{blue}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{c \cdot c + d \cdot d}} \]
      4. hypot-undefine72.7%

        \[\leadsto \frac{\left(c - a \cdot \frac{d}{b}\right) \cdot b}{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      5. times-frac92.7%

        \[\leadsto \color{blue}{\frac{c - a \cdot \frac{d}{b}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}} \]
      6. clear-num92.7%

        \[\leadsto \frac{c - a \cdot \color{blue}{\frac{1}{\frac{b}{d}}}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)} \]
      7. un-div-inv92.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.2 \cdot 10^{+125}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.8 \cdot 10^{-184}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{d}{-{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \mathbf{elif}\;d \leq 4 \cdot 10^{-134}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c - \frac{a}{\frac{b}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq 3.95 \cdot 10^{+145}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{d}{-{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 87.2% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\ t_1 := {c}^{2} + {d}^{2}\\ \mathbf{if}\;d \leq -8 \cdot 10^{+121}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -1.42 \cdot 10^{+100}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq -8 \cdot 10^{+49}:\\ \;\;\;\;a \cdot \left(\frac{c \cdot b}{a \cdot t\_1} - \frac{d}{t\_1}\right)\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{+119}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c - \frac{a}{\frac{b}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c (/ b d)) a) d)) (t_1 (+ (pow c 2.0) (pow d 2.0))))
   (if (<= d -8e+121)
     t_0
     (if (<= d -1.42e+100)
       (/ (- b (* a (/ d c))) c)
       (if (<= d -8e+49)
         (* a (- (/ (* c b) (* a t_1)) (/ d t_1)))
         (if (<= d 1.8e+119)
           (* (/ b (hypot c d)) (/ (- c (/ a (/ b d))) (hypot c d)))
           t_0))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * (b / d)) - a) / d;
	double t_1 = pow(c, 2.0) + pow(d, 2.0);
	double tmp;
	if (d <= -8e+121) {
		tmp = t_0;
	} else if (d <= -1.42e+100) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= -8e+49) {
		tmp = a * (((c * b) / (a * t_1)) - (d / t_1));
	} else if (d <= 1.8e+119) {
		tmp = (b / hypot(c, d)) * ((c - (a / (b / d))) / hypot(c, d));
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * (b / d)) - a) / d;
	double t_1 = Math.pow(c, 2.0) + Math.pow(d, 2.0);
	double tmp;
	if (d <= -8e+121) {
		tmp = t_0;
	} else if (d <= -1.42e+100) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= -8e+49) {
		tmp = a * (((c * b) / (a * t_1)) - (d / t_1));
	} else if (d <= 1.8e+119) {
		tmp = (b / Math.hypot(c, d)) * ((c - (a / (b / d))) / Math.hypot(c, d));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * (b / d)) - a) / d
	t_1 = math.pow(c, 2.0) + math.pow(d, 2.0)
	tmp = 0
	if d <= -8e+121:
		tmp = t_0
	elif d <= -1.42e+100:
		tmp = (b - (a * (d / c))) / c
	elif d <= -8e+49:
		tmp = a * (((c * b) / (a * t_1)) - (d / t_1))
	elif d <= 1.8e+119:
		tmp = (b / math.hypot(c, d)) * ((c - (a / (b / d))) / math.hypot(c, d))
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d)
	t_1 = Float64((c ^ 2.0) + (d ^ 2.0))
	tmp = 0.0
	if (d <= -8e+121)
		tmp = t_0;
	elseif (d <= -1.42e+100)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (d <= -8e+49)
		tmp = Float64(a * Float64(Float64(Float64(c * b) / Float64(a * t_1)) - Float64(d / t_1)));
	elseif (d <= 1.8e+119)
		tmp = Float64(Float64(b / hypot(c, d)) * Float64(Float64(c - Float64(a / Float64(b / d))) / hypot(c, d)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * (b / d)) - a) / d;
	t_1 = (c ^ 2.0) + (d ^ 2.0);
	tmp = 0.0;
	if (d <= -8e+121)
		tmp = t_0;
	elseif (d <= -1.42e+100)
		tmp = (b - (a * (d / c))) / c;
	elseif (d <= -8e+49)
		tmp = a * (((c * b) / (a * t_1)) - (d / t_1));
	elseif (d <= 1.8e+119)
		tmp = (b / hypot(c, d)) * ((c - (a / (b / d))) / hypot(c, d));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[c, 2.0], $MachinePrecision] + N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8e+121], t$95$0, If[LessEqual[d, -1.42e+100], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, -8e+49], N[(a * N[(N[(N[(c * b), $MachinePrecision] / N[(a * t$95$1), $MachinePrecision]), $MachinePrecision] - N[(d / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.8e+119], N[(N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(c - N[(a / N[(b / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;d \leq -8 \cdot 10^{+49}:\\
\;\;\;\;a \cdot \left(\frac{c \cdot b}{a \cdot t\_1} - \frac{d}{t\_1}\right)\\

\mathbf{elif}\;d \leq 1.8 \cdot 10^{+119}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c - \frac{a}{\frac{b}{d}}}{\mathsf{hypot}\left(c, d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -8.0000000000000003e121 or 1.80000000000000001e119 < d

    1. Initial program 41.3%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg78.0%

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(-\frac{a}{d}\right)} \]
      3. unsub-neg78.0%

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow278.0%

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-sub83.7%

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} - a}{d} \]
      8. associate-/l*91.6%

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

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

    if -8.0000000000000003e121 < d < -1.41999999999999999e100

    1. Initial program 41.8%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. remove-double-neg89.0%

        \[\leadsto \frac{\color{blue}{\left(-\left(-b\right)\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      2. mul-1-neg89.0%

        \[\leadsto \frac{\left(-\color{blue}{-1 \cdot b}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      3. neg-mul-189.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. distribute-lft-in89.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      5. mul-1-neg89.0%

        \[\leadsto \frac{\color{blue}{-\left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      6. distribute-neg-in89.0%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right) + \left(-\frac{a \cdot d}{c}\right)}}{c} \]
      7. mul-1-neg89.0%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      8. remove-double-neg89.0%

        \[\leadsto \frac{\color{blue}{b} + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      9. unsub-neg89.0%

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      10. associate-/l*89.3%

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

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

    if -1.41999999999999999e100 < d < -7.99999999999999957e49

    1. Initial program 77.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub77.9%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-commutative77.9%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. fma-define77.9%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. add-sqr-sqrt77.9%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. times-frac77.9%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      6. fma-neg77.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      7. fma-define77.9%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. hypot-define77.9%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      9. fma-define77.9%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      10. hypot-define77.9%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      11. associate-/l*88.3%

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

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt88.3%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\right) \]
      14. pow288.3%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{{\left(\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}\right)}^{2}}}\right) \]
    4. Applied egg-rr88.3%

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

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

    if -7.99999999999999957e49 < d < 1.80000000000000001e119

    1. Initial program 72.1%

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

      \[\leadsto \frac{\color{blue}{b \cdot \left(c + -1 \cdot \frac{a \cdot d}{b}\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. mul-1-neg70.3%

        \[\leadsto \frac{b \cdot \left(c + \color{blue}{\left(-\frac{a \cdot d}{b}\right)}\right)}{c \cdot c + d \cdot d} \]
      2. unsub-neg70.3%

        \[\leadsto \frac{b \cdot \color{blue}{\left(c - \frac{a \cdot d}{b}\right)}}{c \cdot c + d \cdot d} \]
      3. associate-/l*68.5%

        \[\leadsto \frac{b \cdot \left(c - \color{blue}{a \cdot \frac{d}{b}}\right)}{c \cdot c + d \cdot d} \]
    5. Simplified68.5%

      \[\leadsto \frac{\color{blue}{b \cdot \left(c - a \cdot \frac{d}{b}\right)}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. *-commutative68.5%

        \[\leadsto \frac{\color{blue}{\left(c - a \cdot \frac{d}{b}\right) \cdot b}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt68.5%

        \[\leadsto \frac{\left(c - a \cdot \frac{d}{b}\right) \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. hypot-undefine68.5%

        \[\leadsto \frac{\left(c - a \cdot \frac{d}{b}\right) \cdot b}{\color{blue}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{c \cdot c + d \cdot d}} \]
      4. hypot-undefine68.5%

        \[\leadsto \frac{\left(c - a \cdot \frac{d}{b}\right) \cdot b}{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      5. times-frac89.8%

        \[\leadsto \color{blue}{\frac{c - a \cdot \frac{d}{b}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}} \]
      6. clear-num89.8%

        \[\leadsto \frac{c - a \cdot \color{blue}{\frac{1}{\frac{b}{d}}}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)} \]
      7. un-div-inv90.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -8 \cdot 10^{+121}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.42 \cdot 10^{+100}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq -8 \cdot 10^{+49}:\\ \;\;\;\;a \cdot \left(\frac{c \cdot b}{a \cdot \left({c}^{2} + {d}^{2}\right)} - \frac{d}{{c}^{2} + {d}^{2}}\right)\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{+119}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c - \frac{a}{\frac{b}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 86.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{if}\;d \leq -7.8 \cdot 10^{+121}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{+97}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq -1.25 \cdot 10^{+54}:\\ \;\;\;\;a \cdot \frac{d}{-{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}\\ \mathbf{elif}\;d \leq 4.6 \cdot 10^{+120}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c - \frac{a}{\frac{b}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \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 -7.8e+121)
     t_0
     (if (<= d -5.2e+97)
       (/ (- b (* a (/ d c))) c)
       (if (<= d -1.25e+54)
         (* a (/ d (- (pow (hypot d c) 2.0))))
         (if (<= d 4.6e+120)
           (* (/ b (hypot c d)) (/ (- c (/ a (/ b d))) (hypot c d)))
           t_0))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * (b / d)) - a) / d;
	double tmp;
	if (d <= -7.8e+121) {
		tmp = t_0;
	} else if (d <= -5.2e+97) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= -1.25e+54) {
		tmp = a * (d / -pow(hypot(d, c), 2.0));
	} else if (d <= 4.6e+120) {
		tmp = (b / hypot(c, d)) * ((c - (a / (b / d))) / hypot(c, d));
	} else {
		tmp = t_0;
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * (b / d)) - a) / d;
	double tmp;
	if (d <= -7.8e+121) {
		tmp = t_0;
	} else if (d <= -5.2e+97) {
		tmp = (b - (a * (d / c))) / c;
	} else if (d <= -1.25e+54) {
		tmp = a * (d / -Math.pow(Math.hypot(d, c), 2.0));
	} else if (d <= 4.6e+120) {
		tmp = (b / Math.hypot(c, d)) * ((c - (a / (b / d))) / Math.hypot(c, d));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * (b / d)) - a) / d
	tmp = 0
	if d <= -7.8e+121:
		tmp = t_0
	elif d <= -5.2e+97:
		tmp = (b - (a * (d / c))) / c
	elif d <= -1.25e+54:
		tmp = a * (d / -math.pow(math.hypot(d, c), 2.0))
	elif d <= 4.6e+120:
		tmp = (b / math.hypot(c, d)) * ((c - (a / (b / d))) / math.hypot(c, d))
	else:
		tmp = t_0
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d)
	tmp = 0.0
	if (d <= -7.8e+121)
		tmp = t_0;
	elseif (d <= -5.2e+97)
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	elseif (d <= -1.25e+54)
		tmp = Float64(a * Float64(d / Float64(-(hypot(d, c) ^ 2.0))));
	elseif (d <= 4.6e+120)
		tmp = Float64(Float64(b / hypot(c, d)) * Float64(Float64(c - Float64(a / Float64(b / d))) / hypot(c, d)));
	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 <= -7.8e+121)
		tmp = t_0;
	elseif (d <= -5.2e+97)
		tmp = (b - (a * (d / c))) / c;
	elseif (d <= -1.25e+54)
		tmp = a * (d / -(hypot(d, c) ^ 2.0));
	elseif (d <= 4.6e+120)
		tmp = (b / hypot(c, d)) * ((c - (a / (b / d))) / hypot(c, d));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -7.8e+121], t$95$0, If[LessEqual[d, -5.2e+97], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, -1.25e+54], N[(a * N[(d / (-N[Power[N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.6e+120], N[(N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(c - N[(a / N[(b / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;d \leq -1.25 \cdot 10^{+54}:\\
\;\;\;\;a \cdot \frac{d}{-{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}\\

\mathbf{elif}\;d \leq 4.6 \cdot 10^{+120}:\\
\;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c - \frac{a}{\frac{b}{d}}}{\mathsf{hypot}\left(c, d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -7.79999999999999967e121 or 4.59999999999999985e120 < d

    1. Initial program 41.3%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg78.0%

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(-\frac{a}{d}\right)} \]
      3. unsub-neg78.0%

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow278.0%

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-sub83.7%

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

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} - a}{d} \]
      8. associate-/l*91.6%

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

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

    if -7.79999999999999967e121 < d < -5.2e97

    1. Initial program 41.8%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. remove-double-neg89.0%

        \[\leadsto \frac{\color{blue}{\left(-\left(-b\right)\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      2. mul-1-neg89.0%

        \[\leadsto \frac{\left(-\color{blue}{-1 \cdot b}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      3. neg-mul-189.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. distribute-lft-in89.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      5. mul-1-neg89.0%

        \[\leadsto \frac{\color{blue}{-\left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      6. distribute-neg-in89.0%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right) + \left(-\frac{a \cdot d}{c}\right)}}{c} \]
      7. mul-1-neg89.0%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      8. remove-double-neg89.0%

        \[\leadsto \frac{\color{blue}{b} + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      9. unsub-neg89.0%

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      10. associate-/l*89.3%

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

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

    if -5.2e97 < d < -1.25000000000000001e54

    1. Initial program 77.7%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{c}^{2} + {d}^{2}}} \]
    4. Step-by-step derivation
      1. associate-/l*85.5%

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

        \[\leadsto \color{blue}{\left(-1 \cdot a\right) \cdot \frac{d}{{c}^{2} + {d}^{2}}} \]
      3. rem-square-sqrt85.5%

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

        \[\leadsto \left(-1 \cdot a\right) \cdot \frac{d}{\sqrt{\color{blue}{c \cdot c} + {d}^{2}} \cdot \sqrt{{c}^{2} + {d}^{2}}} \]
      5. unpow285.5%

        \[\leadsto \left(-1 \cdot a\right) \cdot \frac{d}{\sqrt{c \cdot c + \color{blue}{d \cdot d}} \cdot \sqrt{{c}^{2} + {d}^{2}}} \]
      6. hypot-undefine85.5%

        \[\leadsto \left(-1 \cdot a\right) \cdot \frac{d}{\color{blue}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{{c}^{2} + {d}^{2}}} \]
      7. unpow285.5%

        \[\leadsto \left(-1 \cdot a\right) \cdot \frac{d}{\mathsf{hypot}\left(c, d\right) \cdot \sqrt{\color{blue}{c \cdot c} + {d}^{2}}} \]
      8. unpow285.5%

        \[\leadsto \left(-1 \cdot a\right) \cdot \frac{d}{\mathsf{hypot}\left(c, d\right) \cdot \sqrt{c \cdot c + \color{blue}{d \cdot d}}} \]
      9. hypot-undefine85.5%

        \[\leadsto \left(-1 \cdot a\right) \cdot \frac{d}{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      10. unpow285.5%

        \[\leadsto \left(-1 \cdot a\right) \cdot \frac{d}{\color{blue}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}} \]
      11. *-commutative85.5%

        \[\leadsto \color{blue}{\left(a \cdot -1\right)} \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}} \]
      12. associate-*l*85.5%

        \[\leadsto \color{blue}{a \cdot \left(-1 \cdot \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
      13. neg-mul-185.5%

        \[\leadsto a \cdot \color{blue}{\left(-\frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
      14. distribute-neg-frac285.5%

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

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

    if -1.25000000000000001e54 < d < 4.59999999999999985e120

    1. Initial program 72.1%

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

      \[\leadsto \frac{\color{blue}{b \cdot \left(c + -1 \cdot \frac{a \cdot d}{b}\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. mul-1-neg70.3%

        \[\leadsto \frac{b \cdot \left(c + \color{blue}{\left(-\frac{a \cdot d}{b}\right)}\right)}{c \cdot c + d \cdot d} \]
      2. unsub-neg70.3%

        \[\leadsto \frac{b \cdot \color{blue}{\left(c - \frac{a \cdot d}{b}\right)}}{c \cdot c + d \cdot d} \]
      3. associate-/l*68.5%

        \[\leadsto \frac{b \cdot \left(c - \color{blue}{a \cdot \frac{d}{b}}\right)}{c \cdot c + d \cdot d} \]
    5. Simplified68.5%

      \[\leadsto \frac{\color{blue}{b \cdot \left(c - a \cdot \frac{d}{b}\right)}}{c \cdot c + d \cdot d} \]
    6. Step-by-step derivation
      1. *-commutative68.5%

        \[\leadsto \frac{\color{blue}{\left(c - a \cdot \frac{d}{b}\right) \cdot b}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt68.5%

        \[\leadsto \frac{\left(c - a \cdot \frac{d}{b}\right) \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. hypot-undefine68.5%

        \[\leadsto \frac{\left(c - a \cdot \frac{d}{b}\right) \cdot b}{\color{blue}{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{c \cdot c + d \cdot d}} \]
      4. hypot-undefine68.5%

        \[\leadsto \frac{\left(c - a \cdot \frac{d}{b}\right) \cdot b}{\mathsf{hypot}\left(c, d\right) \cdot \color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
      5. times-frac89.8%

        \[\leadsto \color{blue}{\frac{c - a \cdot \frac{d}{b}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}} \]
      6. clear-num89.8%

        \[\leadsto \frac{c - a \cdot \color{blue}{\frac{1}{\frac{b}{d}}}}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)} \]
      7. un-div-inv90.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.8 \cdot 10^{+121}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -5.2 \cdot 10^{+97}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq -1.25 \cdot 10^{+54}:\\ \;\;\;\;a \cdot \frac{d}{-{\left(\mathsf{hypot}\left(d, c\right)\right)}^{2}}\\ \mathbf{elif}\;d \leq 4.6 \cdot 10^{+120}:\\ \;\;\;\;\frac{b}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c - \frac{a}{\frac{b}{d}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 82.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{if}\;c \leq -1.2 \cdot 10^{+66}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq -2.15 \cdot 10^{-147}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 1.62 \cdot 10^{-55}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+131}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \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 -1.2e+66)
     t_0
     (if (<= c -2.15e-147)
       (/ (fma b c (* a (- d))) (fma d d (* c c)))
       (if (<= c 1.62e-55)
         (/ (- (/ (* c b) d) a) d)
         (if (<= c 6e+131) (/ (- (* c b) (* d a)) (fma c c (* d 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 <= -1.2e+66) {
		tmp = t_0;
	} else if (c <= -2.15e-147) {
		tmp = fma(b, c, (a * -d)) / fma(d, d, (c * c));
	} else if (c <= 1.62e-55) {
		tmp = (((c * b) / d) - a) / d;
	} else if (c <= 6e+131) {
		tmp = ((c * b) - (d * a)) / fma(c, c, (d * 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 <= -1.2e+66)
		tmp = t_0;
	elseif (c <= -2.15e-147)
		tmp = Float64(fma(b, c, Float64(a * Float64(-d))) / fma(d, d, Float64(c * c)));
	elseif (c <= 1.62e-55)
		tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d);
	elseif (c <= 6e+131)
		tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(c, c, Float64(d * d)));
	else
		tmp = t_0;
	end
	return 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, -1.2e+66], t$95$0, If[LessEqual[c, -2.15e-147], N[(N[(b * c + N[(a * (-d)), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.62e-55], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6e+131], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.2000000000000001e66 or 6.0000000000000003e131 < c

    1. Initial program 30.6%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. remove-double-neg78.3%

        \[\leadsto \frac{\color{blue}{\left(-\left(-b\right)\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      2. mul-1-neg78.3%

        \[\leadsto \frac{\left(-\color{blue}{-1 \cdot b}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      3. neg-mul-178.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. distribute-lft-in78.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      5. mul-1-neg78.3%

        \[\leadsto \frac{\color{blue}{-\left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      6. distribute-neg-in78.3%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right) + \left(-\frac{a \cdot d}{c}\right)}}{c} \]
      7. mul-1-neg78.3%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      8. remove-double-neg78.3%

        \[\leadsto \frac{\color{blue}{b} + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      9. unsub-neg78.3%

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      10. associate-/l*83.4%

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

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

    if -1.2000000000000001e66 < c < -2.1500000000000001e-147

    1. Initial program 85.1%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fma-neg85.1%

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, c, -a \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. distribute-rgt-neg-out85.1%

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

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

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

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

    if -2.1500000000000001e-147 < c < 1.62000000000000006e-55

    1. Initial program 66.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub62.2%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-commutative62.2%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. fma-define62.2%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. add-sqr-sqrt62.2%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. times-frac60.8%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      6. fma-neg60.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      7. fma-define60.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. hypot-define60.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      9. fma-define60.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      10. hypot-define62.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      11. associate-/l*68.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      12. fma-define68.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt68.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\right) \]
      14. pow268.6%

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

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

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

    if 1.62000000000000006e-55 < c < 6.0000000000000003e131

    1. Initial program 80.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fma-define80.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.2 \cdot 10^{+66}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -2.15 \cdot 10^{-147}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 1.62 \cdot 10^{-55}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+131}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 82.7% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{if}\;c \leq -1.4 \cdot 10^{+66}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;c \leq -1.02 \cdot 10^{-144}:\\
\;\;\;\;\frac{t\_0}{c \cdot c + d \cdot d}\\

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

\mathbf{elif}\;c \leq 5.5 \cdot 10^{+131}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.4e66 or 5.49999999999999971e131 < c

    1. Initial program 30.6%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. remove-double-neg78.3%

        \[\leadsto \frac{\color{blue}{\left(-\left(-b\right)\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      2. mul-1-neg78.3%

        \[\leadsto \frac{\left(-\color{blue}{-1 \cdot b}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      3. neg-mul-178.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. distribute-lft-in78.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      5. mul-1-neg78.3%

        \[\leadsto \frac{\color{blue}{-\left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      6. distribute-neg-in78.3%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right) + \left(-\frac{a \cdot d}{c}\right)}}{c} \]
      7. mul-1-neg78.3%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      8. remove-double-neg78.3%

        \[\leadsto \frac{\color{blue}{b} + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      9. unsub-neg78.3%

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      10. associate-/l*83.4%

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

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

    if -1.4e66 < c < -1.01999999999999997e-144

    1. Initial program 85.1%

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

    if -1.01999999999999997e-144 < c < 1.69999999999999986e-55

    1. Initial program 66.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub62.2%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-commutative62.2%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. fma-define62.2%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. add-sqr-sqrt62.2%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. times-frac60.8%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      6. fma-neg60.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      7. fma-define60.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. hypot-define60.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      9. fma-define60.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      10. hypot-define62.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      11. associate-/l*68.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      12. fma-define68.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt68.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\right) \]
      14. pow268.6%

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

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

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

    if 1.69999999999999986e-55 < c < 5.49999999999999971e131

    1. Initial program 80.9%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. fma-define80.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.4 \cdot 10^{+66}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -1.02 \cdot 10^{-144}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{-55}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+131}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 82.7% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{if}\;c \leq -1.2 \cdot 10^{+66}:\\
\;\;\;\;t\_1\\

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

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

\mathbf{elif}\;c \leq 4 \cdot 10^{+131}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.2000000000000001e66 or 3.9999999999999996e131 < c

    1. Initial program 30.6%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. remove-double-neg78.3%

        \[\leadsto \frac{\color{blue}{\left(-\left(-b\right)\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      2. mul-1-neg78.3%

        \[\leadsto \frac{\left(-\color{blue}{-1 \cdot b}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      3. neg-mul-178.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. distribute-lft-in78.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      5. mul-1-neg78.3%

        \[\leadsto \frac{\color{blue}{-\left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      6. distribute-neg-in78.3%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right) + \left(-\frac{a \cdot d}{c}\right)}}{c} \]
      7. mul-1-neg78.3%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      8. remove-double-neg78.3%

        \[\leadsto \frac{\color{blue}{b} + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      9. unsub-neg78.3%

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      10. associate-/l*83.4%

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

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

    if -1.2000000000000001e66 < c < -2.3500000000000001e-145 or 7.2000000000000001e-55 < c < 3.9999999999999996e131

    1. Initial program 83.2%

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

    if -2.3500000000000001e-145 < c < 7.2000000000000001e-55

    1. Initial program 66.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub62.2%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. *-commutative62.2%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. fma-define62.2%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      4. add-sqr-sqrt62.2%

        \[\leadsto \frac{c \cdot b}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. times-frac60.8%

        \[\leadsto \color{blue}{\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      6. fma-neg60.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      7. fma-define60.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      8. hypot-define60.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, \frac{b}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      9. fma-define60.8%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      10. hypot-define62.1%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      11. associate-/l*68.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -\color{blue}{a \cdot \frac{d}{c \cdot c + d \cdot d}}\right) \]
      12. fma-define68.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\right) \]
      13. add-sqr-sqrt68.6%

        \[\leadsto \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, -a \cdot \frac{d}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\right) \]
      14. pow268.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.2 \cdot 10^{+66}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -2.35 \cdot 10^{-145}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-55}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 4 \cdot 10^{+131}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 77.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -7.8 \cdot 10^{+121} \lor \neg \left(d \leq -7 \cdot 10^{+99}\right) \land \left(d \leq -4.5 \cdot 10^{-55} \lor \neg \left(d \leq 2.9 \cdot 10^{+55}\right)\right):\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= d -7.8e+121)
         (and (not (<= d -7e+99)) (or (<= d -4.5e-55) (not (<= d 2.9e+55)))))
   (/ (- (* c (/ b d)) a) d)
   (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -7.8e+121) || (!(d <= -7e+99) && ((d <= -4.5e-55) || !(d <= 2.9e+55)))) {
		tmp = ((c * (b / d)) - a) / d;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	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 <= (-7.8d+121)) .or. (.not. (d <= (-7d+99))) .and. (d <= (-4.5d-55)) .or. (.not. (d <= 2.9d+55))) then
        tmp = ((c * (b / d)) - a) / d
    else
        tmp = (b - (a * (d / c))) / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -7.8e+121) || (!(d <= -7e+99) && ((d <= -4.5e-55) || !(d <= 2.9e+55)))) {
		tmp = ((c * (b / d)) - a) / d;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -7.8e+121) or (not (d <= -7e+99) and ((d <= -4.5e-55) or not (d <= 2.9e+55))):
		tmp = ((c * (b / d)) - a) / d
	else:
		tmp = (b - (a * (d / c))) / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -7.8e+121) || (!(d <= -7e+99) && ((d <= -4.5e-55) || !(d <= 2.9e+55))))
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	else
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((d <= -7.8e+121) || (~((d <= -7e+99)) && ((d <= -4.5e-55) || ~((d <= 2.9e+55)))))
		tmp = ((c * (b / d)) - a) / d;
	else
		tmp = (b - (a * (d / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.8e+121], And[N[Not[LessEqual[d, -7e+99]], $MachinePrecision], Or[LessEqual[d, -4.5e-55], N[Not[LessEqual[d, 2.9e+55]], $MachinePrecision]]]], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.8 \cdot 10^{+121} \lor \neg \left(d \leq -7 \cdot 10^{+99}\right) \land \left(d \leq -4.5 \cdot 10^{-55} \lor \neg \left(d \leq 2.9 \cdot 10^{+55}\right)\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\

\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7.79999999999999967e121 or -6.9999999999999995e99 < d < -4.4999999999999997e-55 or 2.8999999999999999e55 < d

    1. Initial program 51.5%

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

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} + -1 \cdot \frac{a}{d}} \]
      2. mul-1-neg71.3%

        \[\leadsto \frac{b \cdot c}{{d}^{2}} + \color{blue}{\left(-\frac{a}{d}\right)} \]
      3. unsub-neg71.3%

        \[\leadsto \color{blue}{\frac{b \cdot c}{{d}^{2}} - \frac{a}{d}} \]
      4. unpow271.3%

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

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d}}{d}} - \frac{a}{d} \]
      6. div-sub74.8%

        \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{d} - a}{d}} \]
      7. *-commutative74.8%

        \[\leadsto \frac{\frac{\color{blue}{c \cdot b}}{d} - a}{d} \]
      8. associate-/l*79.7%

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

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

    if -7.79999999999999967e121 < d < -6.9999999999999995e99 or -4.4999999999999997e-55 < d < 2.8999999999999999e55

    1. Initial program 73.2%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. remove-double-neg86.4%

        \[\leadsto \frac{\color{blue}{\left(-\left(-b\right)\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      2. mul-1-neg86.4%

        \[\leadsto \frac{\left(-\color{blue}{-1 \cdot b}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      3. neg-mul-186.4%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. distribute-lft-in86.4%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      5. mul-1-neg86.4%

        \[\leadsto \frac{\color{blue}{-\left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      6. distribute-neg-in86.4%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right) + \left(-\frac{a \cdot d}{c}\right)}}{c} \]
      7. mul-1-neg86.4%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      8. remove-double-neg86.4%

        \[\leadsto \frac{\color{blue}{b} + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      9. unsub-neg86.4%

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      10. associate-/l*86.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.8 \cdot 10^{+121} \lor \neg \left(d \leq -7 \cdot 10^{+99}\right) \land \left(d \leq -4.5 \cdot 10^{-55} \lor \neg \left(d \leq 2.9 \cdot 10^{+55}\right)\right):\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 76.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -7.8 \cdot 10^{+121} \lor \neg \left(d \leq -3.5 \cdot 10^{+99}\right) \land \left(d \leq -4.5 \cdot 10^{-55} \lor \neg \left(d \leq 3.7 \cdot 10^{+55}\right)\right):\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= d -7.8e+121)
         (and (not (<= d -3.5e+99)) (or (<= d -4.5e-55) (not (<= d 3.7e+55)))))
   (/ (- (* b (/ c d)) a) d)
   (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -7.8e+121) || (!(d <= -3.5e+99) && ((d <= -4.5e-55) || !(d <= 3.7e+55)))) {
		tmp = ((b * (c / d)) - a) / d;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	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 <= (-7.8d+121)) .or. (.not. (d <= (-3.5d+99))) .and. (d <= (-4.5d-55)) .or. (.not. (d <= 3.7d+55))) then
        tmp = ((b * (c / d)) - a) / d
    else
        tmp = (b - (a * (d / c))) / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -7.8e+121) || (!(d <= -3.5e+99) && ((d <= -4.5e-55) || !(d <= 3.7e+55)))) {
		tmp = ((b * (c / d)) - a) / d;
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -7.8e+121) or (not (d <= -3.5e+99) and ((d <= -4.5e-55) or not (d <= 3.7e+55))):
		tmp = ((b * (c / d)) - a) / d
	else:
		tmp = (b - (a * (d / c))) / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -7.8e+121) || (!(d <= -3.5e+99) && ((d <= -4.5e-55) || !(d <= 3.7e+55))))
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d);
	else
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((d <= -7.8e+121) || (~((d <= -3.5e+99)) && ((d <= -4.5e-55) || ~((d <= 3.7e+55)))))
		tmp = ((b * (c / d)) - a) / d;
	else
		tmp = (b - (a * (d / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.8e+121], And[N[Not[LessEqual[d, -3.5e+99]], $MachinePrecision], Or[LessEqual[d, -4.5e-55], N[Not[LessEqual[d, 3.7e+55]], $MachinePrecision]]]], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.8 \cdot 10^{+121} \lor \neg \left(d \leq -3.5 \cdot 10^{+99}\right) \land \left(d \leq -4.5 \cdot 10^{-55} \lor \neg \left(d \leq 3.7 \cdot 10^{+55}\right)\right):\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\

\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7.79999999999999967e121 or -3.4999999999999998e99 < d < -4.4999999999999997e-55 or 3.7000000000000002e55 < d

    1. Initial program 51.5%

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

      \[\leadsto \frac{\color{blue}{b \cdot \left(c + -1 \cdot \frac{a \cdot d}{b}\right)}}{c \cdot c + d \cdot d} \]
    4. Step-by-step derivation
      1. mul-1-neg44.1%

        \[\leadsto \frac{b \cdot \left(c + \color{blue}{\left(-\frac{a \cdot d}{b}\right)}\right)}{c \cdot c + d \cdot d} \]
      2. unsub-neg44.1%

        \[\leadsto \frac{b \cdot \color{blue}{\left(c - \frac{a \cdot d}{b}\right)}}{c \cdot c + d \cdot d} \]
      3. associate-/l*37.6%

        \[\leadsto \frac{b \cdot \left(c - \color{blue}{a \cdot \frac{d}{b}}\right)}{c \cdot c + d \cdot d} \]
    5. Simplified37.6%

      \[\leadsto \frac{\color{blue}{b \cdot \left(c - a \cdot \frac{d}{b}\right)}}{c \cdot c + d \cdot d} \]
    6. Taylor expanded in d around inf 74.8%

      \[\leadsto \color{blue}{\frac{-1 \cdot a + \frac{b \cdot c}{d}}{d}} \]
    7. Step-by-step derivation
      1. +-commutative74.8%

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} + -1 \cdot a}}{d} \]
      2. neg-mul-174.8%

        \[\leadsto \frac{\frac{b \cdot c}{d} + \color{blue}{\left(-a\right)}}{d} \]
      3. sub-neg74.8%

        \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{d} - a}}{d} \]
      4. associate-/l*78.3%

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

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

    if -7.79999999999999967e121 < d < -3.4999999999999998e99 or -4.4999999999999997e-55 < d < 3.7000000000000002e55

    1. Initial program 73.2%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. remove-double-neg86.4%

        \[\leadsto \frac{\color{blue}{\left(-\left(-b\right)\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      2. mul-1-neg86.4%

        \[\leadsto \frac{\left(-\color{blue}{-1 \cdot b}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      3. neg-mul-186.4%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. distribute-lft-in86.4%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      5. mul-1-neg86.4%

        \[\leadsto \frac{\color{blue}{-\left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      6. distribute-neg-in86.4%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right) + \left(-\frac{a \cdot d}{c}\right)}}{c} \]
      7. mul-1-neg86.4%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      8. remove-double-neg86.4%

        \[\leadsto \frac{\color{blue}{b} + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      9. unsub-neg86.4%

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      10. associate-/l*86.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.8 \cdot 10^{+121} \lor \neg \left(d \leq -3.5 \cdot 10^{+99}\right) \land \left(d \leq -4.5 \cdot 10^{-55} \lor \neg \left(d \leq 3.7 \cdot 10^{+55}\right)\right):\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 71.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -6 \cdot 10^{+122} \lor \neg \left(d \leq -1.2 \cdot 10^{+100} \lor \neg \left(d \leq -1.08 \cdot 10^{+45}\right) \land d \leq 5.8 \cdot 10^{+118}\right):\\ \;\;\;\;-\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= d -6e+122)
         (not
          (or (<= d -1.2e+100) (and (not (<= d -1.08e+45)) (<= d 5.8e+118)))))
   (- (/ a d))
   (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -6e+122) || !((d <= -1.2e+100) || (!(d <= -1.08e+45) && (d <= 5.8e+118)))) {
		tmp = -(a / d);
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	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 <= (-6d+122)) .or. (.not. (d <= (-1.2d+100)) .or. (.not. (d <= (-1.08d+45))) .and. (d <= 5.8d+118))) then
        tmp = -(a / d)
    else
        tmp = (b - (a * (d / c))) / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -6e+122) || !((d <= -1.2e+100) || (!(d <= -1.08e+45) && (d <= 5.8e+118)))) {
		tmp = -(a / d);
	} else {
		tmp = (b - (a * (d / c))) / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -6e+122) or not ((d <= -1.2e+100) or (not (d <= -1.08e+45) and (d <= 5.8e+118))):
		tmp = -(a / d)
	else:
		tmp = (b - (a * (d / c))) / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -6e+122) || !((d <= -1.2e+100) || (!(d <= -1.08e+45) && (d <= 5.8e+118))))
		tmp = Float64(-Float64(a / d));
	else
		tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((d <= -6e+122) || ~(((d <= -1.2e+100) || (~((d <= -1.08e+45)) && (d <= 5.8e+118)))))
		tmp = -(a / d);
	else
		tmp = (b - (a * (d / c))) / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -6e+122], N[Not[Or[LessEqual[d, -1.2e+100], And[N[Not[LessEqual[d, -1.08e+45]], $MachinePrecision], LessEqual[d, 5.8e+118]]]], $MachinePrecision]], (-N[(a / d), $MachinePrecision]), N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -6 \cdot 10^{+122} \lor \neg \left(d \leq -1.2 \cdot 10^{+100} \lor \neg \left(d \leq -1.08 \cdot 10^{+45}\right) \land d \leq 5.8 \cdot 10^{+118}\right):\\
\;\;\;\;-\frac{a}{d}\\

\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -5.99999999999999972e122 or -1.20000000000000006e100 < d < -1.08e45 or 5.80000000000000032e118 < d

    1. Initial program 45.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. associate-*r/77.9%

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-177.9%

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

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

    if -5.99999999999999972e122 < d < -1.20000000000000006e100 or -1.08e45 < d < 5.80000000000000032e118

    1. Initial program 70.8%

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

      \[\leadsto \color{blue}{\frac{b + -1 \cdot \frac{a \cdot d}{c}}{c}} \]
    4. Step-by-step derivation
      1. remove-double-neg75.0%

        \[\leadsto \frac{\color{blue}{\left(-\left(-b\right)\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      2. mul-1-neg75.0%

        \[\leadsto \frac{\left(-\color{blue}{-1 \cdot b}\right) + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      3. neg-mul-175.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b\right)} + -1 \cdot \frac{a \cdot d}{c}}{c} \]
      4. distribute-lft-in75.0%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      5. mul-1-neg75.0%

        \[\leadsto \frac{\color{blue}{-\left(-1 \cdot b + \frac{a \cdot d}{c}\right)}}{c} \]
      6. distribute-neg-in75.0%

        \[\leadsto \frac{\color{blue}{\left(--1 \cdot b\right) + \left(-\frac{a \cdot d}{c}\right)}}{c} \]
      7. mul-1-neg75.0%

        \[\leadsto \frac{\left(-\color{blue}{\left(-b\right)}\right) + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      8. remove-double-neg75.0%

        \[\leadsto \frac{\color{blue}{b} + \left(-\frac{a \cdot d}{c}\right)}{c} \]
      9. unsub-neg75.0%

        \[\leadsto \frac{\color{blue}{b - \frac{a \cdot d}{c}}}{c} \]
      10. associate-/l*76.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -6 \cdot 10^{+122} \lor \neg \left(d \leq -1.2 \cdot 10^{+100} \lor \neg \left(d \leq -1.08 \cdot 10^{+45}\right) \land d \leq 5.8 \cdot 10^{+118}\right):\\ \;\;\;\;-\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 63.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1 \cdot 10^{+50} \lor \neg \left(c \leq 3.6 \cdot 10^{-54}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;-\frac{a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= c -1e+50) (not (<= c 3.6e-54))) (/ b c) (- (/ a d))))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((c <= -1e+50) || !(c <= 3.6e-54)) {
		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 ((c <= (-1d+50)) .or. (.not. (c <= 3.6d-54))) 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 ((c <= -1e+50) || !(c <= 3.6e-54)) {
		tmp = b / c;
	} else {
		tmp = -(a / d);
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (c <= -1e+50) or not (c <= 3.6e-54):
		tmp = b / c
	else:
		tmp = -(a / d)
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((c <= -1e+50) || !(c <= 3.6e-54))
		tmp = Float64(b / c);
	else
		tmp = Float64(-Float64(a / d));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((c <= -1e+50) || ~((c <= 3.6e-54)))
		tmp = b / c;
	else
		tmp = -(a / d);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1e+50], N[Not[LessEqual[c, 3.6e-54]], $MachinePrecision]], N[(b / c), $MachinePrecision], (-N[(a / d), $MachinePrecision])]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1 \cdot 10^{+50} \lor \neg \left(c \leq 3.6 \cdot 10^{-54}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.0000000000000001e50 or 3.59999999999999976e-54 < c

    1. Initial program 48.9%

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

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

    if -1.0000000000000001e50 < c < 3.59999999999999976e-54

    1. Initial program 73.1%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d}} \]
    4. Step-by-step derivation
      1. associate-*r/67.0%

        \[\leadsto \color{blue}{\frac{-1 \cdot a}{d}} \]
      2. neg-mul-167.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1 \cdot 10^{+50} \lor \neg \left(c \leq 3.6 \cdot 10^{-54}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;-\frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 46.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -1.75 \cdot 10^{+125} \lor \neg \left(d \leq 8.1 \cdot 10^{+121}\right):\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= d -1.75e+125) (not (<= d 8.1e+121))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -1.75e+125) || !(d <= 8.1e+121)) {
		tmp = a / d;
	} else {
		tmp = b / c;
	}
	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 <= (-1.75d+125)) .or. (.not. (d <= 8.1d+121))) then
        tmp = a / d
    else
        tmp = b / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -1.75e+125) || !(d <= 8.1e+121)) {
		tmp = a / d;
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -1.75e+125) or not (d <= 8.1e+121):
		tmp = a / d
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -1.75e+125) || !(d <= 8.1e+121))
		tmp = Float64(a / d);
	else
		tmp = Float64(b / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((d <= -1.75e+125) || ~((d <= 8.1e+121)))
		tmp = a / d;
	else
		tmp = b / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.75e+125], N[Not[LessEqual[d, 8.1e+121]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.75 \cdot 10^{+125} \lor \neg \left(d \leq 8.1 \cdot 10^{+121}\right):\\
\;\;\;\;\frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.75000000000000006e125 or 8.09999999999999969e121 < d

    1. Initial program 41.3%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. fma-define41.3%

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, c, -a \cdot d\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
      3. distribute-rgt-neg-out41.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
      5. add-sqr-sqrt41.3%

        \[\leadsto \frac{1 \cdot \mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} \]
      6. times-frac41.3%

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

        \[\leadsto \frac{1}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      8. hypot-define41.3%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      9. add-sqr-sqrt22.1%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \color{blue}{\sqrt{a \cdot \left(-d\right)} \cdot \sqrt{a \cdot \left(-d\right)}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      10. sqrt-unprod31.0%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \color{blue}{\sqrt{\left(a \cdot \left(-d\right)\right) \cdot \left(a \cdot \left(-d\right)\right)}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      11. distribute-rgt-neg-out31.0%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \sqrt{\color{blue}{\left(-a \cdot d\right)} \cdot \left(a \cdot \left(-d\right)\right)}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      12. distribute-rgt-neg-out31.0%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \sqrt{\left(-a \cdot d\right) \cdot \color{blue}{\left(-a \cdot d\right)}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      13. sqr-neg31.0%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \sqrt{\color{blue}{\left(a \cdot d\right) \cdot \left(a \cdot d\right)}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      14. sqrt-unprod15.9%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \color{blue}{\sqrt{a \cdot d} \cdot \sqrt{a \cdot d}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      15. add-sqr-sqrt35.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \color{blue}{a \cdot d}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      16. fma-define35.7%

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot d\right)}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
      17. hypot-define42.3%

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

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

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

    if -1.75000000000000006e125 < d < 8.09999999999999969e121

    1. Initial program 71.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.75 \cdot 10^{+125} \lor \neg \left(d \leq 8.1 \cdot 10^{+121}\right):\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 10.8% accurate, 5.0× 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 61.4%

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. fma-define61.4%

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(b, c, -a \cdot d\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
    3. distribute-rgt-neg-out61.4%

      \[\leadsto \frac{\mathsf{fma}\left(b, c, \color{blue}{a \cdot \left(-d\right)}\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
    4. *-un-lft-identity61.4%

      \[\leadsto \frac{\color{blue}{1 \cdot \mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}}{\mathsf{fma}\left(c, c, d \cdot d\right)} \]
    5. add-sqr-sqrt61.4%

      \[\leadsto \frac{1 \cdot \mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} \]
    6. times-frac61.4%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}} \]
    7. fma-define61.4%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    8. hypot-define61.4%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot \left(-d\right)\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    9. add-sqr-sqrt36.7%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \color{blue}{\sqrt{a \cdot \left(-d\right)} \cdot \sqrt{a \cdot \left(-d\right)}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    10. sqrt-unprod45.1%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \color{blue}{\sqrt{\left(a \cdot \left(-d\right)\right) \cdot \left(a \cdot \left(-d\right)\right)}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    11. distribute-rgt-neg-out45.1%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \sqrt{\color{blue}{\left(-a \cdot d\right)} \cdot \left(a \cdot \left(-d\right)\right)}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    12. distribute-rgt-neg-out45.1%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \sqrt{\left(-a \cdot d\right) \cdot \color{blue}{\left(-a \cdot d\right)}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    13. sqr-neg45.1%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \sqrt{\color{blue}{\left(a \cdot d\right) \cdot \left(a \cdot d\right)}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    14. sqrt-unprod19.9%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \color{blue}{\sqrt{a \cdot d} \cdot \sqrt{a \cdot d}}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    15. add-sqr-sqrt37.8%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, \color{blue}{a \cdot d}\right)}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
    16. fma-define37.8%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, a \cdot d\right)}{\sqrt{\color{blue}{c \cdot c + d \cdot d}}} \]
    17. hypot-define44.4%

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

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

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  6. Add Preprocessing

Developer target: 99.2% accurate, 0.1× 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 2024111 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :alt
  (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))))