Complex division, imag part

Percentage Accurate: 62.0% → 87.8%
Time: 13.3s
Alternatives: 12
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 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: 62.0% 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: 87.8% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := b \cdot c - a \cdot d\\ \mathbf{if}\;\frac{t_1}{c \cdot c + d \cdot d} \leq \infty:\\ \;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t_0, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{-a}{d}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (- (* b c) (* a d))))
   (if (<= (/ t_1 (+ (* c c) (* d d))) INFINITY)
     (* t_0 (/ t_1 (hypot c d)))
     (fma t_0 (/ b (/ (hypot c d) c)) (/ (- a) d)))))
double code(double a, double b, double c, double d) {
	double t_0 = 1.0 / hypot(c, d);
	double t_1 = (b * c) - (a * d);
	double tmp;
	if ((t_1 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
		tmp = t_0 * (t_1 / hypot(c, d));
	} else {
		tmp = fma(t_0, (b / (hypot(c, d) / c)), (-a / d));
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(1.0 / hypot(c, d))
	t_1 = Float64(Float64(b * c) - Float64(a * d))
	tmp = 0.0
	if (Float64(t_1 / Float64(Float64(c * c) + Float64(d * d))) <= Inf)
		tmp = Float64(t_0 * Float64(t_1 / hypot(c, d)));
	else
		tmp = fma(t_0, Float64(b / Float64(hypot(c, d) / c)), Float64(Float64(-a) / d));
	end
	return 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[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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


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

    1. Initial program 77.1%

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

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

        \[\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-frac77.2%

        \[\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-def77.2%

        \[\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-def94.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-rr94.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 +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 0.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub0.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. sub-neg0.0%

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right)} \]
      3. *-un-lft-identity0.0%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c\right)}}{c \cdot c + d \cdot d} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      4. add-sqr-sqrt0.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}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      5. times-frac0.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}}} + \left(-\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      6. fma-def0.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)} \]
      7. hypot-def0.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) \]
      8. hypot-def1.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) \]
      9. add-sqr-sqrt1.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 \cdot d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\right) \]
      10. pow21.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 \cdot d}{\color{blue}{{\left(\sqrt{c \cdot c + d \cdot d}\right)}^{2}}}\right) \]
      11. hypot-def1.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 \cdot d}{{\color{blue}{\left(\mathsf{hypot}\left(c, d\right)\right)}}^{2}}\right) \]
    3. Applied egg-rr1.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 \cdot d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} \]
    4. Step-by-step derivation
      1. associate-/l*49.6%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \color{blue}{-1 \cdot \frac{a}{d}}\right) \]
    7. Step-by-step derivation
      1. associate-*r/74.2%

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

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

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

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

Alternative 2: 85.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot c - a \cdot d\\ \mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq \infty:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* b c) (* a d))))
   (if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
     (* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
     (- (* b (/ 1.0 c)) (* (/ d c) (/ a c))))))
double code(double a, double b, double c, double d) {
	double t_0 = (b * c) - (a * d);
	double tmp;
	if ((t_0 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	} else {
		tmp = (b * (1.0 / c)) - ((d / c) * (a / c));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (b * c) - (a * d);
	double tmp;
	if ((t_0 / ((c * c) + (d * d))) <= Double.POSITIVE_INFINITY) {
		tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
	} else {
		tmp = (b * (1.0 / c)) - ((d / c) * (a / c));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b * c) - (a * d)
	tmp = 0
	if (t_0 / ((c * c) + (d * d))) <= math.inf:
		tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d))
	else:
		tmp = (b * (1.0 / c)) - ((d / c) * (a / c))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b * c) - Float64(a * d))
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= Inf)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d)));
	else
		tmp = Float64(Float64(b * Float64(1.0 / c)) - Float64(Float64(d / c) * Float64(a / c)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b * c) - (a * d);
	tmp = 0.0;
	if ((t_0 / ((c * c) + (d * d))) <= Inf)
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	else
		tmp = (b * (1.0 / c)) - ((d / c) * (a / c));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], 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[(b * N[(1.0 / c), $MachinePrecision]), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 77.1%

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

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

        \[\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-frac77.2%

        \[\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-def77.2%

        \[\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-def94.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-rr94.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 +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 0.0%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{d \cdot a}}{{c}^{2}} \]
      5. associate-/l*44.3%

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

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

        \[\leadsto \color{blue}{b \cdot \frac{1}{c}} - \frac{d}{\frac{{c}^{2}}{a}} \]
      2. fma-neg44.1%

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

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

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{1}{c} - d \cdot \frac{a}{{c}^{2}}} \]
      3. associate-*r/41.3%

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

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

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

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

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

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

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

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

Alternative 3: 79.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot c - a \cdot d\\ t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_2 := a \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -2.6 \cdot 10^{+41}:\\ \;\;\;\;t_1 \cdot \left(t_2 - b\right)\\ \mathbf{elif}\;c \leq -1.25 \cdot 10^{-135}:\\ \;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7.4 \cdot 10^{-247}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{+86}:\\ \;\;\;\;t_0 \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(b - t_2\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* b c) (* a d)))
        (t_1 (/ 1.0 (hypot c d)))
        (t_2 (* a (/ d c))))
   (if (<= c -2.6e+41)
     (* t_1 (- t_2 b))
     (if (<= c -1.25e-135)
       (/ t_0 (+ (* c c) (* d d)))
       (if (<= c 7.4e-247)
         (- (/ b (/ (pow d 2.0) c)) (/ a d))
         (if (<= c 3.1e+86)
           (* t_0 (/ 1.0 (pow (hypot c d) 2.0)))
           (* t_1 (- b t_2))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (b * c) - (a * d);
	double t_1 = 1.0 / hypot(c, d);
	double t_2 = a * (d / c);
	double tmp;
	if (c <= -2.6e+41) {
		tmp = t_1 * (t_2 - b);
	} else if (c <= -1.25e-135) {
		tmp = t_0 / ((c * c) + (d * d));
	} else if (c <= 7.4e-247) {
		tmp = (b / (pow(d, 2.0) / c)) - (a / d);
	} else if (c <= 3.1e+86) {
		tmp = t_0 * (1.0 / pow(hypot(c, d), 2.0));
	} else {
		tmp = t_1 * (b - t_2);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (b * c) - (a * d);
	double t_1 = 1.0 / Math.hypot(c, d);
	double t_2 = a * (d / c);
	double tmp;
	if (c <= -2.6e+41) {
		tmp = t_1 * (t_2 - b);
	} else if (c <= -1.25e-135) {
		tmp = t_0 / ((c * c) + (d * d));
	} else if (c <= 7.4e-247) {
		tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
	} else if (c <= 3.1e+86) {
		tmp = t_0 * (1.0 / Math.pow(Math.hypot(c, d), 2.0));
	} else {
		tmp = t_1 * (b - t_2);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (b * c) - (a * d)
	t_1 = 1.0 / math.hypot(c, d)
	t_2 = a * (d / c)
	tmp = 0
	if c <= -2.6e+41:
		tmp = t_1 * (t_2 - b)
	elif c <= -1.25e-135:
		tmp = t_0 / ((c * c) + (d * d))
	elif c <= 7.4e-247:
		tmp = (b / (math.pow(d, 2.0) / c)) - (a / d)
	elif c <= 3.1e+86:
		tmp = t_0 * (1.0 / math.pow(math.hypot(c, d), 2.0))
	else:
		tmp = t_1 * (b - t_2)
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(b * c) - Float64(a * d))
	t_1 = Float64(1.0 / hypot(c, d))
	t_2 = Float64(a * Float64(d / c))
	tmp = 0.0
	if (c <= -2.6e+41)
		tmp = Float64(t_1 * Float64(t_2 - b));
	elseif (c <= -1.25e-135)
		tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 7.4e-247)
		tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d));
	elseif (c <= 3.1e+86)
		tmp = Float64(t_0 * Float64(1.0 / (hypot(c, d) ^ 2.0)));
	else
		tmp = Float64(t_1 * Float64(b - t_2));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b * c) - (a * d);
	t_1 = 1.0 / hypot(c, d);
	t_2 = a * (d / c);
	tmp = 0.0;
	if (c <= -2.6e+41)
		tmp = t_1 * (t_2 - b);
	elseif (c <= -1.25e-135)
		tmp = t_0 / ((c * c) + (d * d));
	elseif (c <= 7.4e-247)
		tmp = (b / ((d ^ 2.0) / c)) - (a / d);
	elseif (c <= 3.1e+86)
		tmp = t_0 * (1.0 / (hypot(c, d) ^ 2.0));
	else
		tmp = t_1 * (b - t_2);
	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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.6e+41], N[(t$95$1 * N[(t$95$2 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.25e-135], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7.4e-247], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.1e+86], N[(t$95$0 * N[(1.0 / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(b - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.25 \cdot 10^{-135}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\

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

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

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b - t_2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if c < -2.6000000000000001e41

    1. Initial program 42.7%

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

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

        \[\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-frac42.7%

        \[\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-def42.7%

        \[\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-def67.4%

        \[\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-rr67.4%

      \[\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)}} \]
    4. Taylor expanded in c around -inf 80.7%

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

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

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

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

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

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

    if -2.6000000000000001e41 < c < -1.25000000000000005e-135

    1. Initial program 90.4%

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

    if -1.25000000000000005e-135 < c < 7.40000000000000021e-247

    1. Initial program 67.3%

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

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

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

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

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

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

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

    if 7.40000000000000021e-247 < c < 3.1000000000000002e86

    1. Initial program 82.1%

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

        \[\leadsto \color{blue}{\frac{1}{\frac{c \cdot c + d \cdot d}{b \cdot c - a \cdot d}}} \]
      2. associate-/r/82.2%

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

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

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

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

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

    if 3.1000000000000002e86 < c

    1. Initial program 35.4%

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

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

        \[\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-frac35.5%

        \[\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-def35.5%

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

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

      \[\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)}} \]
    4. Taylor expanded in c around inf 78.2%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(b + -1 \cdot \frac{a \cdot d}{c}\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg78.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.6 \cdot 10^{+41}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a \cdot \frac{d}{c} - b\right)\\ \mathbf{elif}\;c \leq -1.25 \cdot 10^{-135}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7.4 \cdot 10^{-247}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{+86}:\\ \;\;\;\;\left(b \cdot c - a \cdot d\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - a \cdot \frac{d}{c}\right)\\ \end{array} \]

Alternative 4: 79.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot c - a \cdot d\\ t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_2 := a \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -1.6 \cdot 10^{+41}:\\ \;\;\;\;t_1 \cdot \left(t_2 - b\right)\\ \mathbf{elif}\;c \leq -7.8 \cdot 10^{-138}:\\ \;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.8 \cdot 10^{-252}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 6.5 \cdot 10^{+86}:\\ \;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(b - t_2\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* b c) (* a d)))
        (t_1 (/ 1.0 (hypot c d)))
        (t_2 (* a (/ d c))))
   (if (<= c -1.6e+41)
     (* t_1 (- t_2 b))
     (if (<= c -7.8e-138)
       (/ t_0 (+ (* c c) (* d d)))
       (if (<= c 1.8e-252)
         (- (/ b (/ (pow d 2.0) c)) (/ a d))
         (if (<= c 6.5e+86) (/ t_0 (fma c c (* d d))) (* t_1 (- b t_2))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (b * c) - (a * d);
	double t_1 = 1.0 / hypot(c, d);
	double t_2 = a * (d / c);
	double tmp;
	if (c <= -1.6e+41) {
		tmp = t_1 * (t_2 - b);
	} else if (c <= -7.8e-138) {
		tmp = t_0 / ((c * c) + (d * d));
	} else if (c <= 1.8e-252) {
		tmp = (b / (pow(d, 2.0) / c)) - (a / d);
	} else if (c <= 6.5e+86) {
		tmp = t_0 / fma(c, c, (d * d));
	} else {
		tmp = t_1 * (b - t_2);
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(b * c) - Float64(a * d))
	t_1 = Float64(1.0 / hypot(c, d))
	t_2 = Float64(a * Float64(d / c))
	tmp = 0.0
	if (c <= -1.6e+41)
		tmp = Float64(t_1 * Float64(t_2 - b));
	elseif (c <= -7.8e-138)
		tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 1.8e-252)
		tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d));
	elseif (c <= 6.5e+86)
		tmp = Float64(t_0 / fma(c, c, Float64(d * d)));
	else
		tmp = Float64(t_1 * Float64(b - t_2));
	end
	return 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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.6e+41], N[(t$95$1 * N[(t$95$2 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -7.8e-138], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.8e-252], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.5e+86], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(b - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -7.8 \cdot 10^{-138}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\

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

\mathbf{elif}\;c \leq 6.5 \cdot 10^{+86}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b - t_2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if c < -1.60000000000000005e41

    1. Initial program 42.7%

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

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

        \[\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-frac42.7%

        \[\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-def42.7%

        \[\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-def67.4%

        \[\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-rr67.4%

      \[\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)}} \]
    4. Taylor expanded in c around -inf 80.7%

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

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

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

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

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

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

    if -1.60000000000000005e41 < c < -7.7999999999999999e-138

    1. Initial program 90.4%

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

    if -7.7999999999999999e-138 < c < 1.80000000000000011e-252

    1. Initial program 67.3%

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

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

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

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

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

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

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

    if 1.80000000000000011e-252 < c < 6.49999999999999996e86

    1. Initial program 82.1%

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

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

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

    if 6.49999999999999996e86 < c

    1. Initial program 35.4%

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

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

        \[\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-frac35.5%

        \[\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-def35.5%

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

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

      \[\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)}} \]
    4. Taylor expanded in c around inf 78.2%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(b + -1 \cdot \frac{a \cdot d}{c}\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg78.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.6 \cdot 10^{+41}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a \cdot \frac{d}{c} - b\right)\\ \mathbf{elif}\;c \leq -7.8 \cdot 10^{-138}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.8 \cdot 10^{-252}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 6.5 \cdot 10^{+86}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - a \cdot \frac{d}{c}\right)\\ \end{array} \]

Alternative 5: 80.2% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -5 \cdot 10^{-139}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 5.4 \cdot 10^{+86}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -7.5000000000000006e125

    1. Initial program 31.2%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{d \cdot a}}{{c}^{2}} \]
      5. associate-/l*71.9%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}} \]
    5. Step-by-step derivation
      1. div-inv71.7%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{1}{c}, -\frac{d}{\frac{{c}^{2}}{a}}\right)} \]
      3. div-inv71.7%

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

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{1}{c} - d \cdot \frac{a}{{c}^{2}}} \]
      3. associate-*r/73.5%

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

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

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

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

        \[\leadsto b \cdot \frac{1}{c} - \frac{d \cdot a}{\color{blue}{c \cdot c}} \]
      3. times-frac84.9%

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

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

    if -7.5000000000000006e125 < c < -5.00000000000000034e-139 or 7.5e-247 < c < 5.40000000000000036e86

    1. Initial program 83.4%

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

    if -5.00000000000000034e-139 < c < 7.5e-247

    1. Initial program 67.3%

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

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

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

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

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

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

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

    if 5.40000000000000036e86 < c

    1. Initial program 35.4%

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

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

        \[\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-frac35.5%

        \[\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-def35.5%

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

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

      \[\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)}} \]
    4. Taylor expanded in c around inf 78.2%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(b + -1 \cdot \frac{a \cdot d}{c}\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg78.2%

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

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

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

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

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

Alternative 6: 80.0% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -1.2 \cdot 10^{-135}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 7 \cdot 10^{+86}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b - t_2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -2.9999999999999998e41

    1. Initial program 42.7%

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

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

        \[\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-frac42.7%

        \[\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-def42.7%

        \[\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-def67.4%

        \[\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-rr67.4%

      \[\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)}} \]
    4. Taylor expanded in c around -inf 80.7%

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

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

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

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

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

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

    if -2.9999999999999998e41 < c < -1.1999999999999999e-135 or 7.5e-247 < c < 7.00000000000000038e86

    1. Initial program 84.7%

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

    if -1.1999999999999999e-135 < c < 7.5e-247

    1. Initial program 67.3%

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

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

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

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

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

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

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

    if 7.00000000000000038e86 < c

    1. Initial program 35.4%

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

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

        \[\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-frac35.5%

        \[\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-def35.5%

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

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

      \[\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)}} \]
    4. Taylor expanded in c around inf 78.2%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(b + -1 \cdot \frac{a \cdot d}{c}\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg78.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3 \cdot 10^{+41}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a \cdot \frac{d}{c} - b\right)\\ \mathbf{elif}\;c \leq -1.2 \cdot 10^{-135}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7.5 \cdot 10^{-247}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{+86}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - a \cdot \frac{d}{c}\right)\\ \end{array} \]

Alternative 7: 80.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ t_1 := b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{if}\;c \leq -7 \cdot 10^{+125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-137}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-248}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{+86}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
        (t_1 (- (* b (/ 1.0 c)) (* (/ d c) (/ a c)))))
   (if (<= c -7e+125)
     t_1
     (if (<= c -1.9e-137)
       t_0
       (if (<= c 3.1e-248)
         (- (/ b (/ (pow d 2.0) c)) (/ a d))
         (if (<= c 4.8e+86) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
	double t_1 = (b * (1.0 / c)) - ((d / c) * (a / c));
	double tmp;
	if (c <= -7e+125) {
		tmp = t_1;
	} else if (c <= -1.9e-137) {
		tmp = t_0;
	} else if (c <= 3.1e-248) {
		tmp = (b / (pow(d, 2.0) / c)) - (a / d);
	} else if (c <= 4.8e+86) {
		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 = ((b * c) - (a * d)) / ((c * c) + (d * d))
    t_1 = (b * (1.0d0 / c)) - ((d / c) * (a / c))
    if (c <= (-7d+125)) then
        tmp = t_1
    else if (c <= (-1.9d-137)) then
        tmp = t_0
    else if (c <= 3.1d-248) then
        tmp = (b / ((d ** 2.0d0) / c)) - (a / d)
    else if (c <= 4.8d+86) 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 = ((b * c) - (a * d)) / ((c * c) + (d * d));
	double t_1 = (b * (1.0 / c)) - ((d / c) * (a / c));
	double tmp;
	if (c <= -7e+125) {
		tmp = t_1;
	} else if (c <= -1.9e-137) {
		tmp = t_0;
	} else if (c <= 3.1e-248) {
		tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
	} else if (c <= 4.8e+86) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d))
	t_1 = (b * (1.0 / c)) - ((d / c) * (a / c))
	tmp = 0
	if c <= -7e+125:
		tmp = t_1
	elif c <= -1.9e-137:
		tmp = t_0
	elif c <= 3.1e-248:
		tmp = (b / (math.pow(d, 2.0) / c)) - (a / d)
	elif c <= 4.8e+86:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(Float64(b * Float64(1.0 / c)) - Float64(Float64(d / c) * Float64(a / c)))
	tmp = 0.0
	if (c <= -7e+125)
		tmp = t_1;
	elseif (c <= -1.9e-137)
		tmp = t_0;
	elseif (c <= 3.1e-248)
		tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d));
	elseif (c <= 4.8e+86)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
	t_1 = (b * (1.0 / c)) - ((d / c) * (a / c));
	tmp = 0.0;
	if (c <= -7e+125)
		tmp = t_1;
	elseif (c <= -1.9e-137)
		tmp = t_0;
	elseif (c <= 3.1e-248)
		tmp = (b / ((d ^ 2.0) / c)) - (a / d);
	elseif (c <= 4.8e+86)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * N[(1.0 / c), $MachinePrecision]), $MachinePrecision] - N[(N[(d / c), $MachinePrecision] * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -7e+125], t$95$1, If[LessEqual[c, -1.9e-137], t$95$0, If[LessEqual[c, 3.1e-248], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.8e+86], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.9 \cdot 10^{-137}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 4.8 \cdot 10^{+86}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -7.00000000000000023e125 or 4.8000000000000001e86 < c

    1. Initial program 33.6%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{d \cdot a}}{{c}^{2}} \]
      5. associate-/l*73.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{1}{c} - d \cdot \frac{a}{{c}^{2}}} \]
      3. associate-*r/73.9%

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

        \[\leadsto b \cdot \frac{1}{c} - \frac{\color{blue}{a \cdot d}}{{c}^{2}} \]
    8. Simplified73.9%

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

        \[\leadsto b \cdot \frac{1}{c} - \frac{\color{blue}{d \cdot a}}{{c}^{2}} \]
      2. unpow273.9%

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

        \[\leadsto b \cdot \frac{1}{c} - \color{blue}{\frac{d}{c} \cdot \frac{a}{c}} \]
    10. Applied egg-rr84.3%

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

    if -7.00000000000000023e125 < c < -1.89999999999999999e-137 or 3.1000000000000002e-248 < c < 4.8000000000000001e86

    1. Initial program 83.4%

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

    if -1.89999999999999999e-137 < c < 3.1000000000000002e-248

    1. Initial program 67.3%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7 \cdot 10^{+125}:\\ \;\;\;\;b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-137}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-248}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{+86}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]

Alternative 8: 78.1% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;c \leq -3 \cdot 10^{-139}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 7 \cdot 10^{+86}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.3000000000000001e127 or 7.00000000000000038e86 < c

    1. Initial program 33.6%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{d \cdot a}}{{c}^{2}} \]
      5. associate-/l*73.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{1}{c} - d \cdot \frac{a}{{c}^{2}}} \]
      3. associate-*r/73.9%

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

        \[\leadsto b \cdot \frac{1}{c} - \frac{\color{blue}{a \cdot d}}{{c}^{2}} \]
    8. Simplified73.9%

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

        \[\leadsto b \cdot \frac{1}{c} - \frac{\color{blue}{d \cdot a}}{{c}^{2}} \]
      2. unpow273.9%

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

        \[\leadsto b \cdot \frac{1}{c} - \color{blue}{\frac{d}{c} \cdot \frac{a}{c}} \]
    10. Applied egg-rr84.3%

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

    if -1.3000000000000001e127 < c < -2.9999999999999999e-139 or -7.4000000000000006e-304 < c < 7.00000000000000038e86

    1. Initial program 83.9%

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

    if -2.9999999999999999e-139 < c < -7.4000000000000006e-304

    1. Initial program 60.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.3 \cdot 10^{+127}:\\ \;\;\;\;b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{elif}\;c \leq -3 \cdot 10^{-139}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq -7.4 \cdot 10^{-304}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{+86}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]

Alternative 9: 69.6% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;c \leq -1.45 \cdot 10^{-136}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.9 \cdot 10^{+86}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.2e37 or 1.89999999999999989e86 < c

    1. Initial program 39.2%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \frac{\color{blue}{d \cdot a}}{{c}^{2}} \]
      5. associate-/l*73.9%

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{d}{\frac{{c}^{2}}{a}}} \]
    5. Step-by-step derivation
      1. div-inv73.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, \frac{1}{c}, -\frac{d}{\frac{{c}^{2}}{a}}\right)} \]
      3. div-inv73.7%

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

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

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

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

        \[\leadsto \color{blue}{b \cdot \frac{1}{c} - d \cdot \frac{a}{{c}^{2}}} \]
      3. associate-*r/74.0%

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

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

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

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

        \[\leadsto b \cdot \frac{1}{c} - \frac{d \cdot a}{\color{blue}{c \cdot c}} \]
      3. times-frac82.9%

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

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

    if -1.2e37 < c < -1.44999999999999997e-136 or 6.2999999999999997e-55 < c < 1.89999999999999989e86

    1. Initial program 87.7%

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

      \[\leadsto \frac{\color{blue}{b \cdot c}}{c \cdot c + d \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative64.9%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} \]
    4. Simplified64.9%

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

    if -1.44999999999999997e-136 < c < 6.2999999999999997e-55

    1. Initial program 72.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.2 \cdot 10^{+37}:\\ \;\;\;\;b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{elif}\;c \leq -1.45 \cdot 10^{-136}:\\ \;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 6.3 \cdot 10^{-55}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 1.9 \cdot 10^{+86}:\\ \;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;b \cdot \frac{1}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \end{array} \]

Alternative 10: 64.9% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;c \leq -1.26 \cdot 10^{-135}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 5.4 \cdot 10^{+86}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.9999999999999998e41 or 5.40000000000000036e86 < c

    1. Initial program 39.2%

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

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

    if -2.9999999999999998e41 < c < -1.2600000000000001e-135 or 1.49999999999999995e-56 < c < 5.40000000000000036e86

    1. Initial program 87.7%

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

      \[\leadsto \frac{\color{blue}{b \cdot c}}{c \cdot c + d \cdot d} \]
    3. Step-by-step derivation
      1. *-commutative64.9%

        \[\leadsto \frac{\color{blue}{c \cdot b}}{c \cdot c + d \cdot d} \]
    4. Simplified64.9%

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

    if -1.2600000000000001e-135 < c < 1.49999999999999995e-56

    1. Initial program 72.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3 \cdot 10^{+41}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -1.26 \cdot 10^{-135}:\\ \;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.5 \cdot 10^{-56}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{+86}:\\ \;\;\;\;\frac{b \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 11: 63.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.5 \cdot 10^{-17} \lor \neg \left(c \leq 1.22 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.49999999999999978e-17 or 1.2199999999999999e-9 < c

    1. Initial program 49.1%

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

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

    if -4.49999999999999978e-17 < c < 1.2199999999999999e-9

    1. Initial program 78.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.5 \cdot 10^{-17} \lor \neg \left(c \leq 1.22 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]

Alternative 12: 42.4% accurate, 5.0× speedup?

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

\\
\frac{b}{c}
\end{array}
Derivation
  1. Initial program 62.1%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Final simplification46.2%

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

Developer target: 99.3% 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 2023314 
(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))))