Complex division, imag part

Percentage Accurate: 62.0% → 97.6%
Time: 15.4s
Alternatives: 13
Speedup: 1.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 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: 97.6% accurate, 0.0× speedup?

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

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

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. div-sub59.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-neg59.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-identity59.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-sqrt59.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-frac59.1%

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

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

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

      \[\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*67.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-sqrt67.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. pow267.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-def67.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) \]
  4. Applied egg-rr67.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)} \]
  5. Step-by-step derivation
    1. fma-neg67.5%

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

      \[\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*81.2%

      \[\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/77.9%

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

      \[\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}}} \]
  6. Simplified77.9%

    \[\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}}} \]
  7. Step-by-step derivation
    1. *-un-lft-identity77.9%

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

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

      \[\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. Applied egg-rr85.6%

    \[\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)} \]
  9. Step-by-step derivation
    1. associate-*l/85.7%

      \[\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-identity85.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}{\frac{a}{\mathsf{hypot}\left(c, d\right)}}}{\mathsf{hypot}\left(c, d\right)} \]
  10. Simplified85.7%

    \[\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)}} \]
  11. Step-by-step derivation
    1. associate-*r/98.3%

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

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

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

Alternative 2: 92.2% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_2 := \frac{t\_0}{c \cdot c + d \cdot d}\\ t_3 := \frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;t\_2 \leq -5 \cdot 10^{+245}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot t\_3}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+236}:\\ \;\;\;\;t\_1 \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \frac{t\_3}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a)))
        (t_1 (/ 1.0 (hypot c d)))
        (t_2 (/ t_0 (+ (* c c) (* d d))))
        (t_3 (/ a (hypot c d))))
   (if (<= t_2 -5e+245)
     (- (/ b c) (/ (* d t_3) (hypot c d)))
     (if (<= t_2 2e+236)
       (* t_1 (/ t_0 (hypot c d)))
       (- (* t_1 (/ c (/ (hypot c d) b))) (* d (/ t_3 (hypot c d))))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = 1.0 / hypot(c, d);
	double t_2 = t_0 / ((c * c) + (d * d));
	double t_3 = a / hypot(c, d);
	double tmp;
	if (t_2 <= -5e+245) {
		tmp = (b / c) - ((d * t_3) / hypot(c, d));
	} else if (t_2 <= 2e+236) {
		tmp = t_1 * (t_0 / hypot(c, d));
	} else {
		tmp = (t_1 * (c / (hypot(c, d) / b))) - (d * (t_3 / hypot(c, d)));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = 1.0 / Math.hypot(c, d);
	double t_2 = t_0 / ((c * c) + (d * d));
	double t_3 = a / Math.hypot(c, d);
	double tmp;
	if (t_2 <= -5e+245) {
		tmp = (b / c) - ((d * t_3) / Math.hypot(c, d));
	} else if (t_2 <= 2e+236) {
		tmp = t_1 * (t_0 / Math.hypot(c, d));
	} else {
		tmp = (t_1 * (c / (Math.hypot(c, d) / b))) - (d * (t_3 / Math.hypot(c, d)));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	t_1 = 1.0 / math.hypot(c, d)
	t_2 = t_0 / ((c * c) + (d * d))
	t_3 = a / math.hypot(c, d)
	tmp = 0
	if t_2 <= -5e+245:
		tmp = (b / c) - ((d * t_3) / math.hypot(c, d))
	elif t_2 <= 2e+236:
		tmp = t_1 * (t_0 / math.hypot(c, d))
	else:
		tmp = (t_1 * (c / (math.hypot(c, d) / b))) - (d * (t_3 / math.hypot(c, d)))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	t_1 = Float64(1.0 / hypot(c, d))
	t_2 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)))
	t_3 = Float64(a / hypot(c, d))
	tmp = 0.0
	if (t_2 <= -5e+245)
		tmp = Float64(Float64(b / c) - Float64(Float64(d * t_3) / hypot(c, d)));
	elseif (t_2 <= 2e+236)
		tmp = Float64(t_1 * Float64(t_0 / hypot(c, d)));
	else
		tmp = Float64(Float64(t_1 * Float64(c / Float64(hypot(c, d) / b))) - Float64(d * Float64(t_3 / hypot(c, d))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	t_1 = 1.0 / hypot(c, d);
	t_2 = t_0 / ((c * c) + (d * d));
	t_3 = a / hypot(c, d);
	tmp = 0.0;
	if (t_2 <= -5e+245)
		tmp = (b / c) - ((d * t_3) / hypot(c, d));
	elseif (t_2 <= 2e+236)
		tmp = t_1 * (t_0 / hypot(c, d));
	else
		tmp = (t_1 * (c / (hypot(c, d) / b))) - (d * (t_3 / hypot(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]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+245], N[(N[(b / c), $MachinePrecision] - N[(N[(d * t$95$3), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+236], N[(t$95$1 * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[(t$95$3 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+236}:\\
\;\;\;\;t\_1 \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\

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


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

    1. Initial program 45.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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) \]
    4. Applied egg-rr50.2%

      \[\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)} \]
    5. Step-by-step derivation
      1. fma-neg50.2%

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

        \[\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*81.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/77.0%

        \[\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. *-commutative77.0%

        \[\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}}} \]
    6. Simplified77.0%

      \[\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}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity77.0%

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

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

        \[\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. Applied egg-rr81.9%

      \[\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)} \]
    9. Step-by-step derivation
      1. associate-*l/81.9%

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

        \[\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)} \]
    10. Simplified81.9%

      \[\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)}} \]
    11. Step-by-step derivation
      1. associate-*r/95.4%

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

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

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

    if -5.00000000000000034e245 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.00000000000000011e236

    1. Initial program 84.8%

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

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

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

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

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

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

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

    if 2.00000000000000011e236 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 10.5%

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

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

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

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

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

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

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

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

        \[\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) \]
    4. 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)} \]
    5. Step-by-step derivation
      1. fma-neg18.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. *-commutative18.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*60.6%

        \[\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/60.6%

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

        \[\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}}} \]
    6. Simplified60.6%

      \[\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}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity60.6%

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

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

        \[\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. Applied egg-rr81.3%

      \[\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)} \]
    9. Step-by-step derivation
      1. associate-*l/81.4%

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

        \[\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)} \]
    10. Simplified81.4%

      \[\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 3 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 -5 \cdot 10^{+245}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 2 \cdot 10^{+236}:\\ \;\;\;\;\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} \]
  5. Add Preprocessing

Alternative 3: 87.2% accurate, 0.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}\\
t_1 := t\_0 - \frac{a}{d}\\
\mathbf{if}\;d \leq -1.42 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.42e-26 or 1.8e89 < d

    1. Initial program 46.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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*69.1%

        \[\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/65.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. *-commutative65.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}}} \]
    6. Simplified65.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}}} \]
    7. Taylor expanded in d around inf 89.3%

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

    if -1.42e-26 < d < 1.1e-155

    1. Initial program 73.6%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub69.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-neg69.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-identity69.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-sqrt69.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-frac69.8%

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

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

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

        \[\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) \]
    4. 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)} \]
    5. Step-by-step derivation
      1. fma-neg78.5%

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

        \[\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*88.6%

        \[\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/83.3%

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

        \[\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}}} \]
    6. Simplified83.3%

      \[\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}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity83.3%

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

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

        \[\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. Applied egg-rr86.6%

      \[\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)} \]
    9. Step-by-step derivation
      1. associate-*l/86.5%

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

        \[\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)} \]
    10. Simplified86.5%

      \[\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)}} \]
    11. Step-by-step derivation
      1. associate-*r/98.0%

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

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

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

    if 1.1e-155 < d < 1.8e89

    1. Initial program 65.4%

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

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

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

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

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

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

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

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

        \[\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*71.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-sqrt71.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. pow271.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-def71.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) \]
    4. Applied egg-rr71.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)} \]
    5. Step-by-step derivation
      1. fma-neg71.3%

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

        \[\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*92.5%

        \[\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/92.5%

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

        \[\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}}} \]
    6. Simplified92.5%

      \[\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}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification92.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.42 \cdot 10^{-26}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{a}{d}\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{-155}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{+89}:\\ \;\;\;\;\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}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{a}{d}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 89.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot b - d \cdot a\\ t_1 := \frac{t\_0}{c \cdot c + d \cdot d}\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{+245} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+236}\right):\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
   (if (or (<= t_1 -5e+245) (not (<= t_1 2e+236)))
     (- (/ b c) (/ (* d (/ a (hypot c d))) (hypot c d)))
     (* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d))))))
double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = t_0 / ((c * c) + (d * d));
	double tmp;
	if ((t_1 <= -5e+245) || !(t_1 <= 2e+236)) {
		tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d));
	} else {
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (c * b) - (d * a);
	double t_1 = t_0 / ((c * c) + (d * d));
	double tmp;
	if ((t_1 <= -5e+245) || !(t_1 <= 2e+236)) {
		tmp = (b / c) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
	} else {
		tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = (c * b) - (d * a)
	t_1 = t_0 / ((c * c) + (d * d))
	tmp = 0
	if (t_1 <= -5e+245) or not (t_1 <= 2e+236):
		tmp = (b / c) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d))
	else:
		tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d))
	return tmp
function code(a, b, c, d)
	t_0 = Float64(Float64(c * b) - Float64(d * a))
	t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if ((t_1 <= -5e+245) || !(t_1 <= 2e+236))
		tmp = Float64(Float64(b / c) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d)));
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d)));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	t_0 = (c * b) - (d * a);
	t_1 = t_0 / ((c * c) + (d * d));
	tmp = 0.0;
	if ((t_1 <= -5e+245) || ~((t_1 <= 2e+236)))
		tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d));
	else
		tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(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]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+245], N[Not[LessEqual[t$95$1, 2e+236]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{t\_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+245} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+236}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_0}{\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))) < -5.00000000000000034e245 or 2.00000000000000011e236 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 18.4%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. div-sub14.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-neg14.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-identity14.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-sqrt14.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-frac14.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-def14.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-def14.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-def18.2%

        \[\leadsto \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b \cdot c}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}, -\frac{a \cdot d}{c \cdot c + d \cdot d}\right) \]
      9. associate-/l*25.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-sqrt25.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. pow225.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-def25.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) \]
    4. Applied egg-rr25.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)} \]
    5. Step-by-step derivation
      1. fma-neg25.3%

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

        \[\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*65.3%

        \[\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/64.2%

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

        \[\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}}} \]
    6. Simplified64.2%

      \[\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}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity64.2%

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

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

        \[\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. Applied egg-rr81.5%

      \[\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)} \]
    9. Step-by-step derivation
      1. associate-*l/81.5%

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

        \[\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)} \]
    10. Simplified81.5%

      \[\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)}} \]
    11. Step-by-step derivation
      1. associate-*r/98.8%

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

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

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

    if -5.00000000000000034e245 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.00000000000000011e236

    1. Initial program 84.8%

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

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

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

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

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

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

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

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

Alternative 5: 78.5% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -1.55 \cdot 10^{-154}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 5.6 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 48.8%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/75.6%

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

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

    if -7.20000000000000018 < c < -1.54999999999999991e-154 or 1.69999999999999988e-125 < c < 5.59999999999999969e80

    1. Initial program 84.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999991e-154 < c < 1.69999999999999988e-125

    1. Initial program 64.6%

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

      \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity62.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{\frac{d}{b}}}{d} - \frac{\color{blue}{\frac{d}{1} \cdot \frac{a}{d}}}{d} \]
      8. /-rgt-identity87.6%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{d} \cdot b}{d} - \frac{\color{blue}{\left(\frac{1}{d} \cdot d\right) \cdot a}}{d} \]
      6. lft-mult-inverse90.5%

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

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

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

    if 5.59999999999999969e80 < c

    1. Initial program 32.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.2:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{a}{{c}^{2}}\\ \mathbf{elif}\;c \leq -1.55 \cdot 10^{-154}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2} \cdot \left(c \cdot b - d \cdot a\right)\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{-125}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 5.6 \cdot 10^{+80}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2} \cdot \left(c \cdot b - d \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 82.1% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{b}{c} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -1.3 \cdot 10^{-31}:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.29999999999999998e-31 or 2.20000000000000014e78 < c

    1. Initial program 44.9%

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

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

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

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

        \[\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-frac44.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-def44.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-def44.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-def52.8%

        \[\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*53.9%

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

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

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

        \[\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) \]
    4. Applied egg-rr53.9%

      \[\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)} \]
    5. Step-by-step derivation
      1. fma-neg54.0%

        \[\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. *-commutative54.0%

        \[\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*83.5%

        \[\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/84.3%

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

        \[\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}}} \]
    6. Simplified84.3%

      \[\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}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity84.3%

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

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

        \[\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. Applied egg-rr91.6%

      \[\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)} \]
    9. Step-by-step derivation
      1. associate-*l/91.6%

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

        \[\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)} \]
    10. Simplified91.6%

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

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

    if -1.29999999999999998e-31 < c < 8.50000000000000025e-121

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{\frac{d}{b}}}{d} - \frac{\color{blue}{\frac{d}{1} \cdot \frac{a}{d}}}{d} \]
      8. /-rgt-identity83.0%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{d} \cdot b}{d} - \frac{\color{blue}{\left(\frac{1}{d} \cdot d\right) \cdot a}}{d} \]
      6. lft-mult-inverse85.1%

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

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

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

    if 8.50000000000000025e-121 < c < 2.20000000000000014e78

    1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.3 \cdot 10^{-31}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq 8.5 \cdot 10^{-121}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{+78}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2} \cdot \left(c \cdot b - d \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.4% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -3.9 \cdot 10^{-29}:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -3.8999999999999998e-29 or 2.05e77 < c

    1. Initial program 44.9%

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

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

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

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

        \[\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-frac44.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-def44.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-def44.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-def52.8%

        \[\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*53.9%

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

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

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

        \[\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) \]
    4. Applied egg-rr53.9%

      \[\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)} \]
    5. Step-by-step derivation
      1. fma-neg54.0%

        \[\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. *-commutative54.0%

        \[\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*83.5%

        \[\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/84.3%

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

        \[\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}}} \]
    6. Simplified84.3%

      \[\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}}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity84.3%

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

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

        \[\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. Applied egg-rr91.6%

      \[\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)} \]
    9. Step-by-step derivation
      1. associate-*l/91.6%

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

        \[\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)} \]
    10. Simplified91.6%

      \[\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)}} \]
    11. Step-by-step derivation
      1. associate-*r/99.1%

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

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

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

    if -3.8999999999999998e-29 < c < 4.80000000000000014e-126

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{\frac{d}{b}}}{d} - \frac{\color{blue}{\frac{d}{1} \cdot \frac{a}{d}}}{d} \]
      8. /-rgt-identity83.0%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{d} \cdot b}{d} - \frac{\color{blue}{\left(\frac{1}{d} \cdot d\right) \cdot a}}{d} \]
      6. lft-mult-inverse85.1%

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

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

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

    if 4.80000000000000014e-126 < c < 2.05e77

    1. Initial program 81.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.9 \cdot 10^{-29}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{-126}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.05 \cdot 10^{+77}:\\ \;\;\;\;{\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2} \cdot \left(c \cdot b - d \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 78.2% 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}\;c \leq -8.4 \cdot 10^{-10}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{a}{{c}^{2}}\\ \mathbf{elif}\;c \leq -1.38 \cdot 10^{-154}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;c \leq 9.2 \cdot 10^{-126}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+80}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
   (if (<= c -8.4e-10)
     (- (/ b c) (* d (/ a (pow c 2.0))))
     (if (<= c -1.38e-154)
       t_0
       (if (<= c 9.2e-126)
         (- (/ (* b (/ c d)) d) (/ a d))
         (if (<= c 6e+80) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
	double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -8.4e-10) {
		tmp = (b / c) - (d * (a / pow(c, 2.0)));
	} else if (c <= -1.38e-154) {
		tmp = t_0;
	} else if (c <= 9.2e-126) {
		tmp = ((b * (c / d)) / d) - (a / d);
	} else if (c <= 6e+80) {
		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) - (d * a)) / ((c * c) + (d * d))
    if (c <= (-8.4d-10)) then
        tmp = (b / c) - (d * (a / (c ** 2.0d0)))
    else if (c <= (-1.38d-154)) then
        tmp = t_0
    else if (c <= 9.2d-126) then
        tmp = ((b * (c / d)) / d) - (a / d)
    else if (c <= 6d+80) 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) - (d * a)) / ((c * c) + (d * d));
	double tmp;
	if (c <= -8.4e-10) {
		tmp = (b / c) - (d * (a / Math.pow(c, 2.0)));
	} else if (c <= -1.38e-154) {
		tmp = t_0;
	} else if (c <= 9.2e-126) {
		tmp = ((b * (c / d)) / d) - (a / d);
	} else if (c <= 6e+80) {
		tmp = t_0;
	} else {
		tmp = b / c;
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -8.4e-10:
		tmp = (b / c) - (d * (a / math.pow(c, 2.0)))
	elif c <= -1.38e-154:
		tmp = t_0
	elif c <= 9.2e-126:
		tmp = ((b * (c / d)) / d) - (a / d)
	elif c <= 6e+80:
		tmp = t_0
	else:
		tmp = b / c
	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 (c <= -8.4e-10)
		tmp = Float64(Float64(b / c) - Float64(d * Float64(a / (c ^ 2.0))));
	elseif (c <= -1.38e-154)
		tmp = t_0;
	elseif (c <= 9.2e-126)
		tmp = Float64(Float64(Float64(b * Float64(c / d)) / d) - Float64(a / d));
	elseif (c <= 6e+80)
		tmp = t_0;
	else
		tmp = Float64(b / c);
	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 (c <= -8.4e-10)
		tmp = (b / c) - (d * (a / (c ^ 2.0)));
	elseif (c <= -1.38e-154)
		tmp = t_0;
	elseif (c <= 9.2e-126)
		tmp = ((b * (c / d)) / d) - (a / d);
	elseif (c <= 6e+80)
		tmp = t_0;
	else
		tmp = b / c;
	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[c, -8.4e-10], N[(N[(b / c), $MachinePrecision] - N[(d * N[(a / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.38e-154], t$95$0, If[LessEqual[c, 9.2e-126], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6e+80], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -1.38 \cdot 10^{-154}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 6 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -8.3999999999999999e-10

    1. Initial program 49.6%

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

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

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

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

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

        \[\leadsto \frac{b}{c} - \color{blue}{\frac{a}{\frac{{c}^{2}}{d}}} \]
      5. associate-/r/76.0%

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

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

    if -8.3999999999999999e-10 < c < -1.37999999999999995e-154 or 9.20000000000000043e-126 < c < 5.99999999999999974e80

    1. Initial program 84.4%

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

    if -1.37999999999999995e-154 < c < 9.20000000000000043e-126

    1. Initial program 64.6%

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

      \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity62.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{\frac{d}{b}}}{d} - \frac{\color{blue}{\frac{d}{1} \cdot \frac{a}{d}}}{d} \]
      8. /-rgt-identity87.6%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{d} \cdot b}{d} - \frac{\color{blue}{\left(\frac{1}{d} \cdot d\right) \cdot a}}{d} \]
      6. lft-mult-inverse90.5%

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

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

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

    if 5.99999999999999974e80 < c

    1. Initial program 32.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -8.4 \cdot 10^{-10}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{a}{{c}^{2}}\\ \mathbf{elif}\;c \leq -1.38 \cdot 10^{-154}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 9.2 \cdot 10^{-126}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+80}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 79.0% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;c \leq -1.15 \cdot 10^{-156}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;c \leq 2.9 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.15000000000000004e103 or 2.89999999999999992e79 < c

    1. Initial program 32.6%

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

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

    if -1.15000000000000004e103 < c < -1.15e-156 or 6.49999999999999988e-124 < c < 2.89999999999999992e79

    1. Initial program 82.7%

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

    if -1.15e-156 < c < 6.49999999999999988e-124

    1. Initial program 64.6%

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

      \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{{d}^{2}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity62.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{\frac{d}{b}}}{d} - \frac{\color{blue}{\frac{d}{1} \cdot \frac{a}{d}}}{d} \]
      8. /-rgt-identity87.6%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{d} \cdot b}{d} - \frac{\color{blue}{\left(\frac{1}{d} \cdot d\right) \cdot a}}{d} \]
      6. lft-mult-inverse90.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.15 \cdot 10^{+103}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -1.15 \cdot 10^{-156}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 6.5 \cdot 10^{-124}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.9 \cdot 10^{+79}:\\ \;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 71.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -5 \cdot 10^{-26} \lor \neg \left(c \leq 4.2 \cdot 10^{+80}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.00000000000000019e-26 or 4.20000000000000003e80 < c

    1. Initial program 44.0%

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

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

    if -5.00000000000000019e-26 < c < 4.20000000000000003e80

    1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{\frac{d}{b}}}{d} - \frac{\color{blue}{\frac{d}{1} \cdot \frac{a}{d}}}{d} \]
      8. /-rgt-identity77.1%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{c}{d} \cdot b}{d} - \frac{\color{blue}{\left(\frac{1}{d} \cdot d\right) \cdot a}}{d} \]
      6. lft-mult-inverse78.6%

        \[\leadsto \frac{\frac{c}{d} \cdot b}{d} - \frac{\color{blue}{1} \cdot a}{d} \]
      7. *-lft-identity78.6%

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

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

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

Alternative 11: 71.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.4 \cdot 10^{-11} \lor \neg \left(c \leq 2.4 \cdot 10^{+79}\right):\\
\;\;\;\;\frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.4e-11 or 2.39999999999999986e79 < c

    1. Initial program 42.5%

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

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

    if -1.4e-11 < c < 2.39999999999999986e79

    1. Initial program 75.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{b}{\frac{{d}^{2}}{c}}} - \frac{a}{d} \]
      5. associate-/r/71.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 63.1% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.05 \cdot 10^{-35} \lor \neg \left(d \leq 1.4 \cdot 10^{+70}\right):\\
\;\;\;\;\frac{-a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.05000000000000013e-35 or 1.39999999999999995e70 < d

    1. Initial program 49.7%

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

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

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

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

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

    if -2.05000000000000013e-35 < d < 1.39999999999999995e70

    1. Initial program 69.4%

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

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

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

Alternative 13: 43.1% 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 60.4%

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

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

    \[\leadsto \frac{b}{c} \]
  5. Add Preprocessing

Developer target: 99.4% 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 2024031 
(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))))