Complex division, imag part

Percentage Accurate: 62.0% → 98.5%
Time: 13.5s
Alternatives: 14
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 14 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: 98.5% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot \left(-d\right)}{\mathsf{hypot}\left(c, d\right)}\right) \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (fma
  (/ 1.0 (hypot c d))
  (/ b (/ (hypot c d) c))
  (/ (* (/ a (hypot c d)) (- d)) (hypot c d))))
double code(double a, double b, double c, double d) {
	return fma((1.0 / hypot(c, d)), (b / (hypot(c, d) / c)), (((a / hypot(c, d)) * -d) / hypot(c, d)));
}
function code(a, b, c, d)
	return fma(Float64(1.0 / hypot(c, d)), Float64(b / Float64(hypot(c, d) / c)), Float64(Float64(Float64(a / hypot(c, d)) * Float64(-d)) / hypot(c, d)))
end
code[a_, b_, c_, d_] := N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * (-d)), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot \left(-d\right)}{\mathsf{hypot}\left(c, d\right)}\right)
\end{array}
Derivation
  1. Initial program 69.1%

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Step-by-step derivation
    1. div-sub67.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-neg67.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-identity67.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-sqrt67.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-frac66.9%

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

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

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

      \[\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. associate-/l*74.8%

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

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

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

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

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

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
    2. distribute-neg-frac85.1%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
  5. Simplified85.1%

    \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
  6. Step-by-step derivation
    1. unpow285.1%

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

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

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

    \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{-a}{\color{blue}{\frac{\mathsf{hypot}\left(c, d\right)}{1} \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}}\right) \]
  8. Step-by-step derivation
    1. /-rgt-identity98.3%

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

      \[\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}{-1 \cdot a}}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{d}}\right) \]
    3. times-frac98.9%

      \[\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}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}}\right) \]
  9. Applied egg-rr98.9%

    \[\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}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}}\right) \]
  10. Step-by-step derivation
    1. associate-*l/99.0%

      \[\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 \frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}}{\mathsf{hypot}\left(c, d\right)}}\right) \]
    2. mul-1-neg99.0%

      \[\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}{-\frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}}}{\mathsf{hypot}\left(c, d\right)}\right) \]
    3. associate-/r/98.3%

      \[\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}{\frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot d}}{\mathsf{hypot}\left(c, d\right)}\right) \]
  11. Simplified98.3%

    \[\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{-\frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot d}{\mathsf{hypot}\left(c, d\right)}}\right) \]
  12. Final simplification98.3%

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

Alternative 2: 90.7% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := c \cdot b - d \cdot a\\
\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}:\\
\;\;\;\;t_0 \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, 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 84.2%

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

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

        \[\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-frac84.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-def84.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-def95.9%

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

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

        \[\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. associate-/l*3.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ \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}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))))
   (if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
     (* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
     (- (/ b c) (/ a (* c (/ c d)))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	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 / c) - (a / (c * (c / d)));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	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 / c) - (a / (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	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 / c) - (a / (c * (c / d)))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	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 / c) - Float64(a / Float64(c * Float64(c / d))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	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 / c) - (a / (c * (c / d)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $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 / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\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}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\


\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 84.2%

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

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

        \[\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-frac84.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-def84.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-def95.9%

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

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

        \[\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. associate-/l*3.1%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac55.8%

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified55.8%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around inf 44.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 81.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-a}{d}\\ t_1 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -7.5 \cdot 10^{+76}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-1}{d}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, t_0\right)\\ \mathbf{elif}\;d \leq -1.2 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-171}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{+143}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\frac{d}{c}}, t_0\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- a) d)) (t_1 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -7.5e+76)
     (fma (/ -1.0 d) (/ b (/ (hypot c d) c)) t_0)
     (if (<= d -1.2e-88)
       t_1
       (if (<= d 3.8e-171)
         (- (/ b c) (/ a (* c (/ c d))))
         (if (<= d 6.2e+143)
           t_1
           (fma (/ 1.0 (hypot c d)) (/ b (/ d c)) t_0)))))))
double code(double a, double b, double c, double d) {
	double t_0 = -a / d;
	double t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -7.5e+76) {
		tmp = fma((-1.0 / d), (b / (hypot(c, d) / c)), t_0);
	} else if (d <= -1.2e-88) {
		tmp = t_1;
	} else if (d <= 3.8e-171) {
		tmp = (b / c) - (a / (c * (c / d)));
	} else if (d <= 6.2e+143) {
		tmp = t_1;
	} else {
		tmp = fma((1.0 / hypot(c, d)), (b / (d / c)), t_0);
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(-a) / d)
	t_1 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -7.5e+76)
		tmp = fma(Float64(-1.0 / d), Float64(b / Float64(hypot(c, d) / c)), t_0);
	elseif (d <= -1.2e-88)
		tmp = t_1;
	elseif (d <= 3.8e-171)
		tmp = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d))));
	elseif (d <= 6.2e+143)
		tmp = t_1;
	else
		tmp = fma(Float64(1.0 / hypot(c, d)), Float64(b / Float64(d / c)), t_0);
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.5e+76], N[(N[(-1.0 / d), $MachinePrecision] * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[d, -1.2e-88], t$95$1, If[LessEqual[d, 3.8e-171], N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.2e+143], t$95$1, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -1.2 \cdot 10^{-88}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;d \leq 6.2 \cdot 10^{+143}:\\
\;\;\;\;t_1\\

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


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

    1. Initial program 46.5%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. sub-neg46.5%

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

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

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

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

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

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

        \[\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. associate-/l*61.3%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac78.3%

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified78.3%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around 0 87.9%

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

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

    if -7.4999999999999995e76 < d < -1.2e-88 or 3.80000000000000021e-171 < d < 6.1999999999999998e143

    1. Initial program 89.2%

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

    if -1.2e-88 < d < 3.80000000000000021e-171

    1. Initial program 67.8%

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

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

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

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

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

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

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

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

        \[\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. associate-/l*70.0%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac82.3%

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified82.3%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around inf 80.0%

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

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

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

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

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

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

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

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

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

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

    if 6.1999999999999998e143 < d

    1. Initial program 30.6%

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

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

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

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

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

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

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

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

        \[\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. associate-/l*39.0%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac55.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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified55.2%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around 0 87.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{+76}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-1}{d}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{-a}{d}\right)\\ \mathbf{elif}\;d \leq -1.2 \cdot 10^{-88}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-171}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{+143}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\frac{d}{c}}, \frac{-a}{d}\right)\\ \end{array} \]

Alternative 5: 79.4% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -3.6 \cdot 10^{-155}:\\
\;\;\;\;t_0 \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\

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

\mathbf{elif}\;c \leq 9.5 \cdot 10^{+111}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.19999999999999992e113 or 9.50000000000000019e111 < c

    1. Initial program 35.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub35.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-neg35.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-identity35.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-sqrt35.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-frac35.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-def35.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-def35.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-def51.0%

        \[\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. associate-/l*51.4%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac90.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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified90.2%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around inf 78.6%

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

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

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

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

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

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

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

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

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

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

    if -1.19999999999999992e113 < c < -3.59999999999999989e-155

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)} - 1\right)} \cdot \left(b \cdot c - a \cdot d\right) \]
      3. pow-flip38.7%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{\left(-2\right)}}\right)} - 1\right) \cdot \left(b \cdot c - a \cdot d\right) \]
      4. metadata-eval38.7%

        \[\leadsto \left(e^{\mathsf{log1p}\left({\left(\mathsf{hypot}\left(c, d\right)\right)}^{\color{blue}{-2}}\right)} - 1\right) \cdot \left(b \cdot c - a \cdot d\right) \]
    5. Applied egg-rr38.7%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\right)} - 1\right)} \cdot \left(b \cdot c - a \cdot d\right) \]
    6. Step-by-step derivation
      1. expm1-def88.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\right)\right)} \cdot \left(b \cdot c - a \cdot d\right) \]
      2. expm1-log1p90.8%

        \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}} \cdot \left(b \cdot c - a \cdot d\right) \]
    7. Simplified90.8%

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

    if -3.59999999999999989e-155 < c < 1.75e-149

    1. Initial program 70.2%

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

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

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

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

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

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

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

    if 1.75e-149 < c < 9.50000000000000019e111

    1. Initial program 91.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.2 \cdot 10^{+113}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;c \leq -3.6 \cdot 10^{-155}:\\ \;\;\;\;\left(c \cdot b - d \cdot a\right) \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{-149}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{+111}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \end{array} \]

Alternative 6: 80.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -3 \cdot 10^{+76}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-1}{d}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{-a}{d}\right)\\ \mathbf{elif}\;d \leq -4.2 \cdot 10^{-88}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-172}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+143}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= d -3e+76)
     (fma (/ -1.0 d) (/ b (/ (hypot c d) c)) (/ (- a) d))
     (if (<= d -4.2e-88)
       t_0
       (if (<= d 5.5e-172)
         (- (/ b c) (/ a (* c (/ c d))))
         (if (<= d 3.3e+143) t_0 (- (/ b (/ (pow d 2.0) c)) (/ a d))))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (d <= -3e+76) {
		tmp = fma((-1.0 / d), (b / (hypot(c, d) / c)), (-a / d));
	} else if (d <= -4.2e-88) {
		tmp = t_0;
	} else if (d <= 5.5e-172) {
		tmp = (b / c) - (a / (c * (c / d)));
	} else if (d <= 3.3e+143) {
		tmp = t_0;
	} else {
		tmp = (b / (pow(d, 2.0) / c)) - (a / d);
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (d <= -3e+76)
		tmp = fma(Float64(-1.0 / d), Float64(b / Float64(hypot(c, d) / c)), Float64(Float64(-a) / d));
	elseif (d <= -4.2e-88)
		tmp = t_0;
	elseif (d <= 5.5e-172)
		tmp = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d))));
	elseif (d <= 3.3e+143)
		tmp = t_0;
	else
		tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d));
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3e+76], N[(N[(-1.0 / d), $MachinePrecision] * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.2e-88], t$95$0, If[LessEqual[d, 5.5e-172], N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.3e+143], t$95$0, N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -4.2 \cdot 10^{-88}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 3.3 \cdot 10^{+143}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 46.5%

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

        \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}} \]
      2. sub-neg46.5%

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

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

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

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

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

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

        \[\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. associate-/l*61.3%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac78.3%

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified78.3%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around 0 87.9%

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

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

    if -2.9999999999999998e76 < d < -4.1999999999999999e-88 or 5.5000000000000004e-172 < d < 3.3e143

    1. Initial program 89.2%

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

    if -4.1999999999999999e-88 < d < 5.5000000000000004e-172

    1. Initial program 67.8%

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

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

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

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

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

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

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

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

        \[\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. associate-/l*70.0%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac82.3%

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified82.3%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around inf 80.0%

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

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

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

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

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

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

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

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

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

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

    if 3.3e143 < d

    1. Initial program 30.6%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3 \cdot 10^{+76}:\\ \;\;\;\;\mathsf{fma}\left(\frac{-1}{d}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{-a}{d}\right)\\ \mathbf{elif}\;d \leq -4.2 \cdot 10^{-88}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-172}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+143}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \end{array} \]

Alternative 7: 79.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ t_1 := \frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ t_2 := c \cdot c + d \cdot d\\ \mathbf{if}\;c \leq -9.5 \cdot 10^{+111}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -5.8 \cdot 10^{-156}:\\ \;\;\;\;\frac{t_0 + 2 \cdot \mathsf{fma}\left(a, -d, d \cdot a\right)}{t_2}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-149}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 1.08 \cdot 10^{+111}:\\ \;\;\;\;\frac{t_0}{t_2}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a)))
        (t_1 (- (/ b c) (/ a (* c (/ c d)))))
        (t_2 (+ (* c c) (* d d))))
   (if (<= c -9.5e+111)
     t_1
     (if (<= c -5.8e-156)
       (/ (+ t_0 (* 2.0 (fma a (- d) (* d a)))) t_2)
       (if (<= c 1.35e-149)
         (- (/ b (/ (pow d 2.0) c)) (/ a d))
         (if (<= c 1.08e+111) (/ t_0 t_2) t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = (b / c) - (a / (c * (c / d)));
	double t_2 = (c * c) + (d * d);
	double tmp;
	if (c <= -9.5e+111) {
		tmp = t_1;
	} else if (c <= -5.8e-156) {
		tmp = (t_0 + (2.0 * fma(a, -d, (d * a)))) / t_2;
	} else if (c <= 1.35e-149) {
		tmp = (b / (pow(d, 2.0) / c)) - (a / d);
	} else if (c <= 1.08e+111) {
		tmp = t_0 / t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	t_1 = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d))))
	t_2 = Float64(Float64(c * c) + Float64(d * d))
	tmp = 0.0
	if (c <= -9.5e+111)
		tmp = t_1;
	elseif (c <= -5.8e-156)
		tmp = Float64(Float64(t_0 + Float64(2.0 * fma(a, Float64(-d), Float64(d * a)))) / t_2);
	elseif (c <= 1.35e-149)
		tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d));
	elseif (c <= 1.08e+111)
		tmp = Float64(t_0 / t_2);
	else
		tmp = t_1;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9.5e+111], t$95$1, If[LessEqual[c, -5.8e-156], N[(N[(t$95$0 + N[(2.0 * N[(a * (-d) + N[(d * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[c, 1.35e-149], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.08e+111], N[(t$95$0 / t$95$2), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -5.8 \cdot 10^{-156}:\\
\;\;\;\;\frac{t_0 + 2 \cdot \mathsf{fma}\left(a, -d, d \cdot a\right)}{t_2}\\

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

\mathbf{elif}\;c \leq 1.08 \cdot 10^{+111}:\\
\;\;\;\;\frac{t_0}{t_2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -9.50000000000000019e111 or 1.08000000000000004e111 < c

    1. Initial program 35.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub35.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-neg35.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-identity35.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-sqrt35.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-frac35.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-def35.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-def35.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-def51.0%

        \[\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. associate-/l*51.4%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac90.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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified90.2%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around inf 78.6%

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

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

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

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

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

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

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

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

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

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

    if -9.50000000000000019e111 < c < -5.80000000000000041e-156

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\color{blue}{\left(\left(-d\right) \cdot a + a \cdot d\right)} + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}{c \cdot c + d \cdot d} \]
      10. distribute-lft-neg-in89.4%

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

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

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

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\color{blue}{\mathsf{fma}\left(a, -d, a \cdot d\right)} + \mathsf{fma}\left(-d, a, d \cdot a\right)\right)}{c \cdot c + d \cdot d} \]
      14. *-commutative89.5%

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

        \[\leadsto \frac{\left(b \cdot c - a \cdot d\right) + \left(\mathsf{fma}\left(a, -d, a \cdot d\right) + \color{blue}{\left(\left(-d\right) \cdot a + a \cdot d\right)}\right)}{c \cdot c + d \cdot d} \]
      16. distribute-lft-neg-in89.4%

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

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

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

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

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

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

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

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

    if -5.80000000000000041e-156 < c < 1.35000000000000007e-149

    1. Initial program 70.2%

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

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

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

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

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

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

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

    if 1.35000000000000007e-149 < c < 1.08000000000000004e111

    1. Initial program 91.7%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9.5 \cdot 10^{+111}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;c \leq -5.8 \cdot 10^{-156}:\\ \;\;\;\;\frac{\left(c \cdot b - d \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -d, d \cdot a\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-149}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 1.08 \cdot 10^{+111}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \end{array} \]

Alternative 8: 79.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \mathbf{if}\;c \leq -8 \cdot 10^{+111}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.6 \cdot 10^{-156}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{-149}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 1.25 \cdot 10^{+116}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
        (t_1 (- (/ b c) (/ a (* c (/ c d))))))
   (if (<= c -8e+111)
     t_1
     (if (<= c -3.6e-156)
       t_0
       (if (<= c 1.55e-149)
         (- (/ b (/ (pow d 2.0) c)) (/ a d))
         (if (<= c 1.25e+116) t_0 t_1))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = (b / c) - (a / (c * (c / d)));
	double tmp;
	if (c <= -8e+111) {
		tmp = t_1;
	} else if (c <= -3.6e-156) {
		tmp = t_0;
	} else if (c <= 1.55e-149) {
		tmp = (b / (pow(d, 2.0) / c)) - (a / d);
	} else if (c <= 1.25e+116) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
    t_1 = (b / c) - (a / (c * (c / d)))
    if (c <= (-8d+111)) then
        tmp = t_1
    else if (c <= (-3.6d-156)) then
        tmp = t_0
    else if (c <= 1.55d-149) then
        tmp = (b / ((d ** 2.0d0) / c)) - (a / d)
    else if (c <= 1.25d+116) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double t_1 = (b / c) - (a / (c * (c / d)));
	double tmp;
	if (c <= -8e+111) {
		tmp = t_1;
	} else if (c <= -3.6e-156) {
		tmp = t_0;
	} else if (c <= 1.55e-149) {
		tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
	} else if (c <= 1.25e+116) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	t_1 = (b / c) - (a / (c * (c / d)))
	tmp = 0
	if c <= -8e+111:
		tmp = t_1
	elif c <= -3.6e-156:
		tmp = t_0
	elif c <= 1.55e-149:
		tmp = (b / (math.pow(d, 2.0) / c)) - (a / d)
	elif c <= 1.25e+116:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d)))
	t_1 = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d))))
	tmp = 0.0
	if (c <= -8e+111)
		tmp = t_1;
	elseif (c <= -3.6e-156)
		tmp = t_0;
	elseif (c <= 1.55e-149)
		tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d));
	elseif (c <= 1.25e+116)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	t_1 = (b / c) - (a / (c * (c / d)));
	tmp = 0.0;
	if (c <= -8e+111)
		tmp = t_1;
	elseif (c <= -3.6e-156)
		tmp = t_0;
	elseif (c <= 1.55e-149)
		tmp = (b / ((d ^ 2.0) / c)) - (a / d);
	elseif (c <= 1.25e+116)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8e+111], t$95$1, If[LessEqual[c, -3.6e-156], t$95$0, If[LessEqual[c, 1.55e-149], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.25e+116], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -3.6 \cdot 10^{-156}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.25 \cdot 10^{+116}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -7.99999999999999965e111 or 1.25000000000000006e116 < c

    1. Initial program 35.0%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Step-by-step derivation
      1. div-sub35.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-neg35.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-identity35.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-sqrt35.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-frac35.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-def35.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-def35.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-def51.0%

        \[\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. associate-/l*51.4%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac90.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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified90.2%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around inf 78.6%

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

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

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

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

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

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

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

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

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

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

    if -7.99999999999999965e111 < c < -3.59999999999999999e-156 or 1.54999999999999994e-149 < c < 1.25000000000000006e116

    1. Initial program 90.5%

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

    if -3.59999999999999999e-156 < c < 1.54999999999999994e-149

    1. Initial program 70.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8 \cdot 10^{+111}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;c \leq -3.6 \cdot 10^{-156}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{-149}:\\ \;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 1.25 \cdot 10^{+116}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \end{array} \]

Alternative 9: 71.5% accurate, 0.5× speedup?

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

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

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


\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))) < 1.00000000000000007e244

    1. Initial program 86.2%

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

    if 1.00000000000000007e244 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 17.7%

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

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

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

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

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

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

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

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

        \[\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. associate-/l*18.1%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac60.4%

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified60.4%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around inf 48.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 65.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{c \cdot b}{t_0}\\ t_2 := \frac{-a}{d}\\ \mathbf{if}\;c \leq -2.8 \cdot 10^{+82}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -4.8 \cdot 10^{+33}:\\ \;\;\;\;\frac{d \cdot \left(-a\right)}{t_0}\\ \mathbf{elif}\;c \leq -5.6 \cdot 10^{+17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -4.6 \cdot 10^{-30}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -4.2 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{-98}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{+108}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (+ (* c c) (* d d))) (t_1 (/ (* c b) t_0)) (t_2 (/ (- a) d)))
   (if (<= c -2.8e+82)
     (/ b c)
     (if (<= c -4.8e+33)
       (/ (* d (- a)) t_0)
       (if (<= c -5.6e+17)
         t_1
         (if (<= c -4.6e-30)
           t_2
           (if (<= c -4.2e-132)
             t_1
             (if (<= c 1.45e-98) t_2 (if (<= c 2.8e+108) t_1 (/ b c))))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * c) + (d * d);
	double t_1 = (c * b) / t_0;
	double t_2 = -a / d;
	double tmp;
	if (c <= -2.8e+82) {
		tmp = b / c;
	} else if (c <= -4.8e+33) {
		tmp = (d * -a) / t_0;
	} else if (c <= -5.6e+17) {
		tmp = t_1;
	} else if (c <= -4.6e-30) {
		tmp = t_2;
	} else if (c <= -4.2e-132) {
		tmp = t_1;
	} else if (c <= 1.45e-98) {
		tmp = t_2;
	} else if (c <= 2.8e+108) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = (c * c) + (d * d)
    t_1 = (c * b) / t_0
    t_2 = -a / d
    if (c <= (-2.8d+82)) then
        tmp = b / c
    else if (c <= (-4.8d+33)) then
        tmp = (d * -a) / t_0
    else if (c <= (-5.6d+17)) then
        tmp = t_1
    else if (c <= (-4.6d-30)) then
        tmp = t_2
    else if (c <= (-4.2d-132)) then
        tmp = t_1
    else if (c <= 1.45d-98) then
        tmp = t_2
    else if (c <= 2.8d+108) then
        tmp = t_1
    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 = (c * c) + (d * d);
	double t_1 = (c * b) / t_0;
	double t_2 = -a / d;
	double tmp;
	if (c <= -2.8e+82) {
		tmp = b / c;
	} else if (c <= -4.8e+33) {
		tmp = (d * -a) / t_0;
	} else if (c <= -5.6e+17) {
		tmp = t_1;
	} else if (c <= -4.6e-30) {
		tmp = t_2;
	} else if (c <= -4.2e-132) {
		tmp = t_1;
	} else if (c <= 1.45e-98) {
		tmp = t_2;
	} else if (c <= 2.8e+108) {
		tmp = t_1;
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * c) + (d * d)
	t_1 = (c * b) / t_0
	t_2 = -a / d
	tmp = 0
	if c <= -2.8e+82:
		tmp = b / c
	elif c <= -4.8e+33:
		tmp = (d * -a) / t_0
	elif c <= -5.6e+17:
		tmp = t_1
	elif c <= -4.6e-30:
		tmp = t_2
	elif c <= -4.2e-132:
		tmp = t_1
	elif c <= 1.45e-98:
		tmp = t_2
	elif c <= 2.8e+108:
		tmp = t_1
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * c) + Float64(d * d))
	t_1 = Float64(Float64(c * b) / t_0)
	t_2 = Float64(Float64(-a) / d)
	tmp = 0.0
	if (c <= -2.8e+82)
		tmp = Float64(b / c);
	elseif (c <= -4.8e+33)
		tmp = Float64(Float64(d * Float64(-a)) / t_0);
	elseif (c <= -5.6e+17)
		tmp = t_1;
	elseif (c <= -4.6e-30)
		tmp = t_2;
	elseif (c <= -4.2e-132)
		tmp = t_1;
	elseif (c <= 1.45e-98)
		tmp = t_2;
	elseif (c <= 2.8e+108)
		tmp = t_1;
	else
		tmp = Float64(b / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * c) + (d * d);
	t_1 = (c * b) / t_0;
	t_2 = -a / d;
	tmp = 0.0;
	if (c <= -2.8e+82)
		tmp = b / c;
	elseif (c <= -4.8e+33)
		tmp = (d * -a) / t_0;
	elseif (c <= -5.6e+17)
		tmp = t_1;
	elseif (c <= -4.6e-30)
		tmp = t_2;
	elseif (c <= -4.2e-132)
		tmp = t_1;
	elseif (c <= 1.45e-98)
		tmp = t_2;
	elseif (c <= 2.8e+108)
		tmp = t_1;
	else
		tmp = b / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[c, -2.8e+82], N[(b / c), $MachinePrecision], If[LessEqual[c, -4.8e+33], N[(N[(d * (-a)), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[c, -5.6e+17], t$95$1, If[LessEqual[c, -4.6e-30], t$95$2, If[LessEqual[c, -4.2e-132], t$95$1, If[LessEqual[c, 1.45e-98], t$95$2, If[LessEqual[c, 2.8e+108], t$95$1, N[(b / c), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -4.8 \cdot 10^{+33}:\\
\;\;\;\;\frac{d \cdot \left(-a\right)}{t_0}\\

\mathbf{elif}\;c \leq -5.6 \cdot 10^{+17}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \leq -4.6 \cdot 10^{-30}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;c \leq -4.2 \cdot 10^{-132}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \leq 1.45 \cdot 10^{-98}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;c \leq 2.8 \cdot 10^{+108}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -2.8e82 or 2.7999999999999998e108 < c

    1. Initial program 42.3%

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

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

    if -2.8e82 < c < -4.8e33

    1. Initial program 99.4%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(a \cdot d\right)}}{c \cdot c + d \cdot d} \]
    3. Step-by-step derivation
      1. associate-*r*89.9%

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

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

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

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

    if -4.8e33 < c < -5.6e17 or -4.59999999999999968e-30 < c < -4.2000000000000002e-132 or 1.45e-98 < c < 2.7999999999999998e108

    1. Initial program 86.6%

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

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

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

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

    if -5.6e17 < c < -4.59999999999999968e-30 or -4.2000000000000002e-132 < c < 1.45e-98

    1. Initial program 75.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.8 \cdot 10^{+82}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -4.8 \cdot 10^{+33}:\\ \;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq -5.6 \cdot 10^{+17}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq -4.6 \cdot 10^{-30}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq -4.2 \cdot 10^{-132}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{-98}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{+108}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 11: 66.0% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;c \leq -1.02 \cdot 10^{-131}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 5.2 \cdot 10^{+107}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -8.49999999999999983e111 or 5.2000000000000002e107 < c

    1. Initial program 35.0%

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

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

    if -8.49999999999999983e111 < c < -1.02000000000000001e-131 or 1.3999999999999999e-98 < c < 5.2000000000000002e107

    1. Initial program 89.6%

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

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

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

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

    if -1.02000000000000001e-131 < c < 1.3999999999999999e-98

    1. Initial program 73.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.5 \cdot 10^{+111}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -1.02 \cdot 10^{-131}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{-98}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;c \leq 5.2 \cdot 10^{+107}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]

Alternative 12: 72.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -4.8 \cdot 10^{+89}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -2.55 \cdot 10^{-33}:\\
\;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.80000000000000009e89 or 6.0999999999999999e38 < d

    1. Initial program 53.1%

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

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

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

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

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

    if -4.80000000000000009e89 < d < -2.55000000000000004e-33

    1. Initial program 86.6%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(a \cdot d\right)}}{c \cdot c + d \cdot d} \]
    3. Step-by-step derivation
      1. associate-*r*64.3%

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

        \[\leadsto \frac{\color{blue}{\left(-a\right)} \cdot d}{c \cdot c + d \cdot d} \]
      3. *-commutative64.3%

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

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

    if -2.55000000000000004e-33 < d < 6.0999999999999999e38

    1. Initial program 75.0%

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

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

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

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

        \[\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-frac71.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-def71.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-def71.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-def77.0%

        \[\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. associate-/l*78.5%

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

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

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

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

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

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right) \]
      2. distribute-neg-frac89.7%

        \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}}\right) \]
    5. Simplified89.7%

      \[\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}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)} \]
    6. Taylor expanded in c around inf 71.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4.8 \cdot 10^{+89}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq -2.55 \cdot 10^{-33}:\\ \;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 6.1 \cdot 10^{+38}:\\ \;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]

Alternative 13: 64.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -3.4 \cdot 10^{-40} \lor \neg \left(d \leq 4000000\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= d -3.4e-40) (not (<= d 4000000.0))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -3.4e-40) || !(d <= 4000000.0)) {
		tmp = -a / d;
	} else {
		tmp = b / c;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if ((d <= (-3.4d-40)) .or. (.not. (d <= 4000000.0d0))) then
        tmp = -a / d
    else
        tmp = b / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if ((d <= -3.4e-40) || !(d <= 4000000.0)) {
		tmp = -a / d;
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if (d <= -3.4e-40) or not (d <= 4000000.0):
		tmp = -a / d
	else:
		tmp = b / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if ((d <= -3.4e-40) || !(d <= 4000000.0))
		tmp = Float64(Float64(-a) / d);
	else
		tmp = Float64(b / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((d <= -3.4e-40) || ~((d <= 4000000.0)))
		tmp = -a / d;
	else
		tmp = b / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.4e-40], N[Not[LessEqual[d, 4000000.0]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.4 \cdot 10^{-40} \lor \neg \left(d \leq 4000000\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.39999999999999984e-40 or 4e6 < d

    1. Initial program 62.7%

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

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

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

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

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

    if -3.39999999999999984e-40 < d < 4e6

    1. Initial program 75.1%

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

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

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

Alternative 14: 43.5% 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 69.1%

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

    \[\leadsto \color{blue}{\frac{b}{c}} \]
  3. Final simplification45.4%

    \[\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 2023339 
(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))))