Complex division, imag part

Percentage Accurate: 61.5% → 89.2%
Time: 8.9s
Alternatives: 10
Speedup: 1.8×

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 10 alternatives:

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

Initial Program: 61.5% accurate, 1.0× speedup?

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

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

Alternative 1: 89.2% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := t_0 \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}\\
t_2 := b \cdot c - a \cdot d\\
t_3 := \frac{t_2}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_3 \leq -1 \cdot 10^{+281}:\\
\;\;\;\;t_1 - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\

\mathbf{elif}\;t_3 \leq 2 \cdot 10^{+285}:\\
\;\;\;\;t_0 \cdot \frac{t_2}{\mathsf{hypot}\left(c, d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -1e281

    1. Initial program 54.6%

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c\right)}}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      3. add-sqr-sqrt44.0%

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg44.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    4. Step-by-step derivation
      1. fma-neg64.3%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}} \]
      3. associate-/r/94.4%

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

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

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

    if -1e281 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2e285

    1. Initial program 79.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. *-un-lft-identity79.0%

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

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac79.0%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def79.0%

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

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

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

    if 2e285 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 8.3%

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg6.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    4. Step-by-step derivation
      1. fma-neg22.6%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}} \]
      3. associate-/r/60.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq -1 \cdot 10^{+281}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{elif}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+285}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{a}{d}\\ \end{array} \]

Alternative 2: 85.0% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+285}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -1e281

    1. Initial program 54.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    7. Taylor expanded in b around 0 74.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}} \]
      9. associate-/r/74.5%

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{d \cdot \frac{a}{c}}{c}} \]
      12. div-sub80.0%

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

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      14. *-commutative80.0%

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

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    9. Simplified80.0%

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

    if -1e281 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2e285

    1. Initial program 79.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. *-un-lft-identity79.0%

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

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac79.0%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def79.0%

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

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

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

    if 2e285 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 8.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq -1 \cdot 10^{+281}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+285}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 3: 89.2% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
t_2 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+281}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+285}:\\
\;\;\;\;t_2 \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -1e281

    1. Initial program 54.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    7. Taylor expanded in b around 0 74.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}} \]
      9. associate-/r/74.5%

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{d \cdot \frac{a}{c}}{c}} \]
      12. div-sub80.0%

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

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      14. *-commutative80.0%

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

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    9. Simplified80.0%

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

    if -1e281 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2e285

    1. Initial program 79.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. *-un-lft-identity79.0%

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

        \[\leadsto \frac{1 \cdot \left(b \cdot c - a \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac79.0%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}} \]
      4. hypot-def79.0%

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

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

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

    if 2e285 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 8.3%

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d} \]
      5. fma-neg6.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\mathsf{hypot}\left(c, d\right)}, -\frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    4. Step-by-step derivation
      1. fma-neg22.6%

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

        \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} - \frac{a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}} \]
      3. associate-/r/60.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq -1 \cdot 10^{+281}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+285}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{a}{d}\\ \end{array} \]

Alternative 4: 80.3% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.35 \cdot 10^{+99}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\

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

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

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


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

    1. Initial program 40.4%

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

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

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

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

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

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

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

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

    if -4.3499999999999998e99 < d < -9.99999999999999927e-105

    1. Initial program 77.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]

    if -9.99999999999999927e-105 < d < 2.7000000000000002e22

    1. Initial program 70.7%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    6. Applied egg-rr83.9%

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    7. Taylor expanded in b around 0 84.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}} \]
      9. associate-/r/82.1%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{c} \cdot d} \]
      10. *-commutative82.1%

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{d \cdot \frac{a}{c}}{c}} \]
      12. div-sub84.9%

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

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      14. *-commutative89.1%

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

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    9. Simplified88.2%

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

    if 2.7000000000000002e22 < d

    1. Initial program 51.1%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-1, \frac{a}{d}, \color{blue}{{\left(\frac{\frac{d \cdot d}{b}}{c}\right)}^{-1}}\right) \]
      3. associate-/l*87.1%

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

      \[\leadsto \mathsf{fma}\left(-1, \frac{a}{d}, \color{blue}{{\left(\frac{\frac{d}{\frac{b}{d}}}{c}\right)}^{-1}}\right) \]
    7. Step-by-step derivation
      1. unpow-187.1%

        \[\leadsto \mathsf{fma}\left(-1, \frac{a}{d}, \color{blue}{\frac{1}{\frac{\frac{d}{\frac{b}{d}}}{c}}}\right) \]
      2. associate-/l/89.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.35 \cdot 10^{+99}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-104}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+22}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-1, \frac{a}{d}, \frac{1}{\frac{d}{c \cdot \frac{b}{d}}}\right)\\ \end{array} \]

Alternative 5: 80.2% accurate, 0.8× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 46.3%

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

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

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

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

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

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

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

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

    if -2e98 < d < -9.7999999999999999e-105

    1. Initial program 77.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]

    if -9.7999999999999999e-105 < d < 5.8e22

    1. Initial program 70.7%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    6. Applied egg-rr83.9%

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    7. Taylor expanded in b around 0 84.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}} \]
      9. associate-/r/82.1%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{c} \cdot d} \]
      10. *-commutative82.1%

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{d \cdot \frac{a}{c}}{c}} \]
      12. div-sub84.9%

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

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      14. *-commutative89.1%

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

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    9. Simplified88.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2 \cdot 10^{+98}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -9.8 \cdot 10^{-105}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 5.8 \cdot 10^{+22}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \end{array} \]

Alternative 6: 78.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.8 \cdot 10^{-13} \lor \neg \left(d \leq 9.5 \cdot 10^{+21}\right):\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -4.7999999999999997e-13 or 9.500000000000001e21 < d

    1. Initial program 50.8%

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

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

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

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

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

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

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

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

    if -4.7999999999999997e-13 < d < 9.500000000000001e21

    1. Initial program 72.7%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    6. Applied egg-rr80.9%

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    7. Taylor expanded in b around 0 81.5%

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

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

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

        \[\leadsto \frac{b}{c} + \left(-\color{blue}{\frac{a}{\frac{{c}^{2}}{d}}}\right) \]
      4. unpow280.8%

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}} \]
      9. associate-/r/79.4%

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c}}{c} \cdot d} \]
      10. *-commutative79.4%

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

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

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

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      14. *-commutative85.4%

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

        \[\leadsto \frac{b - \color{blue}{\frac{a}{\frac{c}{d}}}}{c} \]
    9. Simplified84.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.8 \cdot 10^{-13} \lor \neg \left(d \leq 9.5 \cdot 10^{+21}\right):\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \end{array} \]

Alternative 7: 72.0% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.8 \cdot 10^{+86} \lor \neg \left(d \leq 2 \cdot 10^{+22}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.79999999999999978e86 or 2e22 < d

    1. Initial program 47.3%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified72.9%

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

    if -3.79999999999999978e86 < d < 2e22

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{b}{c} - \color{blue}{\frac{\frac{a}{c} \cdot d}{c}} \]
    7. Taylor expanded in b around 0 75.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{c} - \frac{\frac{a}{c}}{\frac{c}{d}}} \]
      9. associate-/r/75.2%

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{d \cdot \frac{a}{c}}{c}} \]
      12. div-sub77.2%

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

        \[\leadsto \frac{b - \color{blue}{\frac{d \cdot a}{c}}}{c} \]
      14. *-commutative80.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.8 \cdot 10^{+86} \lor \neg \left(d \leq 2 \cdot 10^{+22}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \end{array} \]

Alternative 8: 64.0% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.15 \cdot 10^{-12} \lor \neg \left(d \leq 1.55 \cdot 10^{+22}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.14999999999999995e-12 or 1.5500000000000001e22 < d

    1. Initial program 50.8%

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

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

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

        \[\leadsto \frac{\color{blue}{-a}}{d} \]
    4. Simplified68.2%

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

    if -1.14999999999999995e-12 < d < 1.5500000000000001e22

    1. Initial program 72.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.15 \cdot 10^{-12} \lor \neg \left(d \leq 1.55 \cdot 10^{+22}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 9: 46.5% accurate, 2.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -1.15e146 or 1.4500000000000001e133 < d

    1. Initial program 37.7%

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

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

        \[\leadsto \frac{\color{blue}{-a \cdot d}}{c \cdot c + d \cdot d} \]
      2. distribute-rgt-neg-out36.5%

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

      \[\leadsto \frac{\color{blue}{a \cdot \left(-d\right)}}{c \cdot c + d \cdot d} \]
    5. Taylor expanded in c around 0 36.5%

      \[\leadsto \frac{a \cdot \left(-d\right)}{\color{blue}{{d}^{2}}} \]
    6. Step-by-step derivation
      1. unpow236.5%

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

      \[\leadsto \frac{a \cdot \left(-d\right)}{\color{blue}{d \cdot d}} \]
    8. Step-by-step derivation
      1. associate-/l*39.0%

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

        \[\leadsto \frac{a}{\color{blue}{\frac{-d \cdot d}{-\left(-d\right)}}} \]
      3. neg-sub039.0%

        \[\leadsto \frac{a}{\frac{\color{blue}{0 - d \cdot d}}{-\left(-d\right)}} \]
      4. metadata-eval39.0%

        \[\leadsto \frac{a}{\frac{\color{blue}{0 \cdot 0} - d \cdot d}{-\left(-d\right)}} \]
      5. add-sqr-sqrt18.9%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\color{blue}{\sqrt{-d} \cdot \sqrt{-d}}}} \]
      6. sqrt-unprod7.7%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\color{blue}{\sqrt{\left(-d\right) \cdot \left(-d\right)}}}} \]
      7. sqr-neg7.7%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\sqrt{\color{blue}{d \cdot d}}}} \]
      8. sqrt-prod17.1%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\color{blue}{\sqrt{d} \cdot \sqrt{d}}}} \]
      9. add-sqr-sqrt31.7%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\color{blue}{d}}} \]
      10. neg-sub031.7%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{\color{blue}{0 - d}}} \]
      11. sub-neg31.7%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{\color{blue}{0 + \left(-d\right)}}} \]
      12. add-sqr-sqrt14.6%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \color{blue}{\sqrt{-d} \cdot \sqrt{-d}}}} \]
      13. sqrt-unprod6.3%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \color{blue}{\sqrt{\left(-d\right) \cdot \left(-d\right)}}}} \]
      14. sqr-neg6.3%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \sqrt{\color{blue}{d \cdot d}}}} \]
      15. sqrt-prod20.0%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \color{blue}{\sqrt{d} \cdot \sqrt{d}}}} \]
      16. add-sqr-sqrt39.0%

        \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \color{blue}{d}}} \]
      17. flip--83.1%

        \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
      18. neg-sub083.1%

        \[\leadsto \frac{a}{\color{blue}{-d}} \]
      19. add-sqr-sqrt37.4%

        \[\leadsto \frac{a}{\color{blue}{\sqrt{-d} \cdot \sqrt{-d}}} \]
      20. sqrt-unprod36.0%

        \[\leadsto \frac{a}{\color{blue}{\sqrt{\left(-d\right) \cdot \left(-d\right)}}} \]
      21. sqr-neg36.0%

        \[\leadsto \frac{a}{\sqrt{\color{blue}{d \cdot d}}} \]
      22. sqrt-prod16.6%

        \[\leadsto \frac{a}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}} \]
      23. add-sqr-sqrt30.9%

        \[\leadsto \frac{a}{\color{blue}{d}} \]
      24. expm1-log1p-u30.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a}{d}\right)\right)} \]
    9. Applied egg-rr31.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{a}{d}\right)} - 1} \]
    10. Step-by-step derivation
      1. expm1-def30.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a}{d}\right)\right)} \]
      2. expm1-log1p30.9%

        \[\leadsto \color{blue}{\frac{a}{d}} \]
    11. Simplified30.9%

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

    if -1.15e146 < d < 1.4500000000000001e133

    1. Initial program 70.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.15 \cdot 10^{+146}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{elif}\;d \leq 1.45 \cdot 10^{+133}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{d}\\ \end{array} \]

Alternative 10: 11.0% 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 62.0%

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

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

      \[\leadsto \frac{\color{blue}{-a \cdot d}}{c \cdot c + d \cdot d} \]
    2. distribute-rgt-neg-out41.6%

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

    \[\leadsto \frac{\color{blue}{a \cdot \left(-d\right)}}{c \cdot c + d \cdot d} \]
  5. Taylor expanded in c around 0 27.9%

    \[\leadsto \frac{a \cdot \left(-d\right)}{\color{blue}{{d}^{2}}} \]
  6. Step-by-step derivation
    1. unpow227.9%

      \[\leadsto \frac{a \cdot \left(-d\right)}{\color{blue}{d \cdot d}} \]
  7. Simplified27.9%

    \[\leadsto \frac{a \cdot \left(-d\right)}{\color{blue}{d \cdot d}} \]
  8. Step-by-step derivation
    1. associate-/l*31.7%

      \[\leadsto \color{blue}{\frac{a}{\frac{d \cdot d}{-d}}} \]
    2. frac-2neg31.7%

      \[\leadsto \frac{a}{\color{blue}{\frac{-d \cdot d}{-\left(-d\right)}}} \]
    3. neg-sub029.8%

      \[\leadsto \frac{a}{\frac{\color{blue}{0 - d \cdot d}}{-\left(-d\right)}} \]
    4. metadata-eval29.8%

      \[\leadsto \frac{a}{\frac{\color{blue}{0 \cdot 0} - d \cdot d}{-\left(-d\right)}} \]
    5. add-sqr-sqrt15.3%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\color{blue}{\sqrt{-d} \cdot \sqrt{-d}}}} \]
    6. sqrt-unprod12.8%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\color{blue}{\sqrt{\left(-d\right) \cdot \left(-d\right)}}}} \]
    7. sqr-neg12.8%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\sqrt{\color{blue}{d \cdot d}}}} \]
    8. sqrt-prod7.2%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\color{blue}{\sqrt{d} \cdot \sqrt{d}}}} \]
    9. add-sqr-sqrt13.4%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{-\color{blue}{d}}} \]
    10. neg-sub013.4%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{\color{blue}{0 - d}}} \]
    11. sub-neg13.4%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{\color{blue}{0 + \left(-d\right)}}} \]
    12. add-sqr-sqrt6.2%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \color{blue}{\sqrt{-d} \cdot \sqrt{-d}}}} \]
    13. sqrt-unprod12.0%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \color{blue}{\sqrt{\left(-d\right) \cdot \left(-d\right)}}}} \]
    14. sqr-neg12.0%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \sqrt{\color{blue}{d \cdot d}}}} \]
    15. sqrt-prod14.4%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \color{blue}{\sqrt{d} \cdot \sqrt{d}}}} \]
    16. add-sqr-sqrt29.8%

      \[\leadsto \frac{a}{\frac{0 \cdot 0 - d \cdot d}{0 + \color{blue}{d}}} \]
    17. flip--43.0%

      \[\leadsto \frac{a}{\color{blue}{0 - d}} \]
    18. neg-sub043.0%

      \[\leadsto \frac{a}{\color{blue}{-d}} \]
    19. add-sqr-sqrt20.7%

      \[\leadsto \frac{a}{\color{blue}{\sqrt{-d} \cdot \sqrt{-d}}} \]
    20. sqrt-unprod21.5%

      \[\leadsto \frac{a}{\color{blue}{\sqrt{\left(-d\right) \cdot \left(-d\right)}}} \]
    21. sqr-neg21.5%

      \[\leadsto \frac{a}{\sqrt{\color{blue}{d \cdot d}}} \]
    22. sqrt-prod5.6%

      \[\leadsto \frac{a}{\color{blue}{\sqrt{d} \cdot \sqrt{d}}} \]
    23. add-sqr-sqrt11.0%

      \[\leadsto \frac{a}{\color{blue}{d}} \]
    24. expm1-log1p-u10.6%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a}{d}\right)\right)} \]
  9. Applied egg-rr14.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{a}{d}\right)} - 1} \]
  10. Step-by-step derivation
    1. expm1-def10.6%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{a}{d}\right)\right)} \]
    2. expm1-log1p11.0%

      \[\leadsto \color{blue}{\frac{a}{d}} \]
  11. Simplified11.0%

    \[\leadsto \color{blue}{\frac{a}{d}} \]
  12. Final simplification11.0%

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

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 2023224 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :herbie-target
  (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))))