Complex division, real part

Percentage Accurate: 61.8% → 84.7%
Time: 9.7s
Alternatives: 14
Speedup: 2.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 61.8% accurate, 1.0× speedup?

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

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

Alternative 1: 84.7% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\

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


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

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e251 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 0.0%

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

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

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{c \cdot c}} \]
    5. Step-by-step derivation
      1. clear-num50.0%

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

        \[\leadsto \frac{a}{c} + \color{blue}{{\left(\frac{c \cdot c}{b \cdot d}\right)}^{-1}} \]
    6. Applied egg-rr50.0%

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

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

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

        \[\leadsto \frac{a}{c} + \frac{1}{\color{blue}{\frac{c}{d} \cdot \frac{c}{b}}} \]
    8. Simplified66.3%

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

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

Alternative 2: 84.7% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\

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


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

    1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

    if 1e251 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 0.0%

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

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

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{c \cdot c}} \]
    5. Step-by-step derivation
      1. clear-num50.0%

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

        \[\leadsto \frac{a}{c} + \color{blue}{{\left(\frac{c \cdot c}{b \cdot d}\right)}^{-1}} \]
    6. Applied egg-rr50.0%

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

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

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

        \[\leadsto \frac{a}{c} + \frac{1}{\color{blue}{\frac{c}{d} \cdot \frac{c}{b}}} \]
    8. Simplified66.3%

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

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

Alternative 3: 81.0% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 5.8 \cdot 10^{+26}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 2.3 \cdot 10^{+91}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\

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


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

    1. Initial program 30.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b \cdot \color{blue}{\left(-\frac{d}{c}\right)} - a}{\mathsf{hypot}\left(c, d\right)} \]
      14. distribute-neg-frac94.8%

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

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

    if -3.4999999999999999e131 < c < -2e-167 or 3.2e-175 < c < 5.8e26

    1. Initial program 79.7%

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

    if -2e-167 < c < 3.2e-175

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{a}{\frac{{d}^{2}}{c}}} \]
      2. unpow286.2%

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

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

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

        \[\leadsto \frac{b}{d} + \frac{a}{\color{blue}{d} \cdot \frac{d}{c}} \]
    8. Simplified92.1%

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

    if 5.8e26 < c < 2.29999999999999991e91

    1. Initial program 33.4%

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

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

        \[\leadsto \frac{\color{blue}{d \cdot b}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt24.9%

        \[\leadsto \frac{d \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. hypot-udef24.9%

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

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

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

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

    if 2.29999999999999991e91 < c

    1. Initial program 37.6%

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

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

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{c \cdot c}} \]
    5. Taylor expanded in b around 0 66.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{c} + \frac{1}{\color{blue}{\frac{1}{\frac{d}{c}} \cdot \frac{c}{b}}} \]
      5. clear-num79.9%

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

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{\frac{1}{\frac{c}{d}}}{\frac{c}{b}}} \]
      7. clear-num80.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{\frac{d}{c}}}{\frac{c}{b}} \]
      8. div-inv80.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{d \cdot \frac{1}{c}}}{\frac{c}{b}} \]
      9. div-inv80.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.5 \cdot 10^{+131}:\\ \;\;\;\;\frac{b \cdot \left(-\frac{d}{c}\right) - a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-175}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+26}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.3 \cdot 10^{+91}:\\ \;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\ \end{array} \]

Alternative 4: 81.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -4.1 \cdot 10^{+131}:\\ \;\;\;\;\frac{b \cdot \left(-\frac{d}{c}\right) - a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 10^{-174}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;c \leq 1.8 \cdot 10^{+26}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\ \;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -4.1e+131)
   (/ (- (* b (- (/ d c))) a) (hypot c d))
   (if (<= c -2e-167)
     (/ (fma a c (* b d)) (fma c c (* d d)))
     (if (<= c 1e-174)
       (+ (/ b d) (/ a (* d (/ d c))))
       (if (<= c 1.8e+26)
         (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
         (if (<= c 1.35e+90)
           (* (/ d (hypot c d)) (/ b (hypot c d)))
           (+ (/ a c) (* (/ d c) (/ (/ 1.0 c) (/ 1.0 b))))))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -4.1e+131) {
		tmp = ((b * -(d / c)) - a) / hypot(c, d);
	} else if (c <= -2e-167) {
		tmp = fma(a, c, (b * d)) / fma(c, c, (d * d));
	} else if (c <= 1e-174) {
		tmp = (b / d) + (a / (d * (d / c)));
	} else if (c <= 1.8e+26) {
		tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
	} else if (c <= 1.35e+90) {
		tmp = (d / hypot(c, d)) * (b / hypot(c, d));
	} else {
		tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -4.1e+131)
		tmp = Float64(Float64(Float64(b * Float64(-Float64(d / c))) - a) / hypot(c, d));
	elseif (c <= -2e-167)
		tmp = Float64(fma(a, c, Float64(b * d)) / fma(c, c, Float64(d * d)));
	elseif (c <= 1e-174)
		tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c))));
	elseif (c <= 1.8e+26)
		tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= 1.35e+90)
		tmp = Float64(Float64(d / hypot(c, d)) * Float64(b / hypot(c, d)));
	else
		tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(Float64(1.0 / c) / Float64(1.0 / b))));
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.1e+131], N[(N[(N[(b * (-N[(d / c), $MachinePrecision])), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2e-167], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1e-174], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.8e+26], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.35e+90], N[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.1 \cdot 10^{+131}:\\
\;\;\;\;\frac{b \cdot \left(-\frac{d}{c}\right) - a}{\mathsf{hypot}\left(c, d\right)}\\

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

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

\mathbf{elif}\;c \leq 1.8 \cdot 10^{+26}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\

\mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if c < -4.10000000000000007e131

    1. Initial program 30.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b \cdot \color{blue}{\left(-\frac{d}{c}\right)} - a}{\mathsf{hypot}\left(c, d\right)} \]
      14. distribute-neg-frac94.8%

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

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

    if -4.10000000000000007e131 < c < -2e-167

    1. Initial program 81.5%

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

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

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

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

    if -2e-167 < c < 1e-174

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{a}{\frac{{d}^{2}}{c}}} \]
      2. unpow286.2%

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

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

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

        \[\leadsto \frac{b}{d} + \frac{a}{\color{blue}{d} \cdot \frac{d}{c}} \]
    8. Simplified92.1%

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

    if 1e-174 < c < 1.80000000000000012e26

    1. Initial program 76.7%

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

    if 1.80000000000000012e26 < c < 1.35e90

    1. Initial program 33.4%

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

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

        \[\leadsto \frac{\color{blue}{d \cdot b}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt24.9%

        \[\leadsto \frac{d \cdot b}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. hypot-udef24.9%

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

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

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

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

    if 1.35e90 < c

    1. Initial program 37.6%

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

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

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{c \cdot c}} \]
    5. Taylor expanded in b around 0 66.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{c} + \frac{1}{\color{blue}{\frac{1}{\frac{d}{c}} \cdot \frac{c}{b}}} \]
      5. clear-num79.9%

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

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{\frac{1}{\frac{c}{d}}}{\frac{c}{b}}} \]
      7. clear-num80.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{\frac{d}{c}}}{\frac{c}{b}} \]
      8. div-inv80.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{d \cdot \frac{1}{c}}}{\frac{c}{b}} \]
      9. div-inv80.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.1 \cdot 10^{+131}:\\ \;\;\;\;\frac{b \cdot \left(-\frac{d}{c}\right) - a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 10^{-174}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;c \leq 1.8 \cdot 10^{+26}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\ \;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\ \end{array} \]

Alternative 5: 80.5% accurate, 0.1× speedup?

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

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

\mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.8 \cdot 10^{+26}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 4.5 \cdot 10^{+92}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\

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


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

    1. Initial program 30.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b \cdot \color{blue}{\left(-\frac{d}{c}\right)} - a}{\mathsf{hypot}\left(c, d\right)} \]
      14. distribute-neg-frac94.8%

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

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

    if -3.8000000000000004e131 < c < -2e-167 or 1e-174 < c < 1.80000000000000012e26

    1. Initial program 79.7%

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

    if -2e-167 < c < 1e-174

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{a}{\frac{{d}^{2}}{c}}} \]
      2. unpow286.2%

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

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

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

        \[\leadsto \frac{b}{d} + \frac{a}{\color{blue}{d} \cdot \frac{d}{c}} \]
    8. Simplified92.1%

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

    if 1.80000000000000012e26 < c < 4.4999999999999999e92

    1. Initial program 33.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{c \cdot \frac{a}{d \cdot d}} \]
    6. Simplified77.0%

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

    if 4.4999999999999999e92 < c

    1. Initial program 37.6%

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

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

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{c \cdot c}} \]
    5. Taylor expanded in b around 0 66.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{c} + \frac{1}{\color{blue}{\frac{1}{\frac{d}{c}} \cdot \frac{c}{b}}} \]
      5. clear-num79.9%

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

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{\frac{1}{\frac{c}{d}}}{\frac{c}{b}}} \]
      7. clear-num80.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{\frac{d}{c}}}{\frac{c}{b}} \]
      8. div-inv80.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{d \cdot \frac{1}{c}}}{\frac{c}{b}} \]
      9. div-inv80.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.8 \cdot 10^{+131}:\\ \;\;\;\;\frac{b \cdot \left(-\frac{d}{c}\right) - a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 10^{-174}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;c \leq 1.8 \cdot 10^{+26}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{+92}:\\ \;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\ \end{array} \]

Alternative 6: 80.5% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 5.8 \cdot 10^{+26}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -3.4999999999999999e131 or 1.35e90 < c

    1. Initial program 34.4%

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

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

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{c \cdot c}} \]
    5. Taylor expanded in b around 0 75.3%

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

        \[\leadsto \frac{a}{c} + \frac{b \cdot d}{\color{blue}{c \cdot c}} \]
      2. times-frac87.0%

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

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{b \cdot \frac{d}{c}}{c}} \]
    7. Simplified87.0%

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

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

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

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

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

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

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{\frac{1}{\frac{c}{d}}}{\frac{c}{b}}} \]
      7. clear-num87.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{\frac{d}{c}}}{\frac{c}{b}} \]
      8. div-inv87.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{d \cdot \frac{1}{c}}}{\frac{c}{b}} \]
      9. div-inv87.0%

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

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

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

    if -3.4999999999999999e131 < c < -2e-167 or 1e-175 < c < 5.8e26

    1. Initial program 79.7%

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

    if -2e-167 < c < 1e-175

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{a}{\frac{{d}^{2}}{c}}} \]
      2. unpow286.2%

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

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

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

        \[\leadsto \frac{b}{d} + \frac{a}{\color{blue}{d} \cdot \frac{d}{c}} \]
    8. Simplified92.1%

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

    if 5.8e26 < c < 1.35e90

    1. Initial program 33.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{c \cdot \frac{a}{d \cdot d}} \]
    6. Simplified77.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.5 \cdot 10^{+131}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 10^{-175}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+26}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\ \;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\ \end{array} \]

Alternative 7: 75.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -6.5 \cdot 10^{+53}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{elif}\;c \leq 13000000000:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;c \leq 3 \cdot 10^{+24}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+91}:\\ \;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -6.5e+53)
   (+ (/ a c) (* (/ d c) (/ b c)))
   (if (<= c 13000000000.0)
     (+ (/ b d) (* (/ c d) (/ a d)))
     (if (<= c 3e+24)
       (+ (/ a c) (/ (* b d) (* c c)))
       (if (<= c 2.1e+91)
         (+ (/ b d) (* c (/ a (* d d))))
         (+ (/ a c) (* (/ d c) (/ (/ 1.0 c) (/ 1.0 b)))))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -6.5e+53) {
		tmp = (a / c) + ((d / c) * (b / c));
	} else if (c <= 13000000000.0) {
		tmp = (b / d) + ((c / d) * (a / d));
	} else if (c <= 3e+24) {
		tmp = (a / c) + ((b * d) / (c * c));
	} else if (c <= 2.1e+91) {
		tmp = (b / d) + (c * (a / (d * d)));
	} else {
		tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
	}
	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 <= (-6.5d+53)) then
        tmp = (a / c) + ((d / c) * (b / c))
    else if (c <= 13000000000.0d0) then
        tmp = (b / d) + ((c / d) * (a / d))
    else if (c <= 3d+24) then
        tmp = (a / c) + ((b * d) / (c * c))
    else if (c <= 2.1d+91) then
        tmp = (b / d) + (c * (a / (d * d)))
    else
        tmp = (a / c) + ((d / c) * ((1.0d0 / c) / (1.0d0 / b)))
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -6.5e+53) {
		tmp = (a / c) + ((d / c) * (b / c));
	} else if (c <= 13000000000.0) {
		tmp = (b / d) + ((c / d) * (a / d));
	} else if (c <= 3e+24) {
		tmp = (a / c) + ((b * d) / (c * c));
	} else if (c <= 2.1e+91) {
		tmp = (b / d) + (c * (a / (d * d)));
	} else {
		tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -6.5e+53:
		tmp = (a / c) + ((d / c) * (b / c))
	elif c <= 13000000000.0:
		tmp = (b / d) + ((c / d) * (a / d))
	elif c <= 3e+24:
		tmp = (a / c) + ((b * d) / (c * c))
	elif c <= 2.1e+91:
		tmp = (b / d) + (c * (a / (d * d)))
	else:
		tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -6.5e+53)
		tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c)));
	elseif (c <= 13000000000.0)
		tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d)));
	elseif (c <= 3e+24)
		tmp = Float64(Float64(a / c) + Float64(Float64(b * d) / Float64(c * c)));
	elseif (c <= 2.1e+91)
		tmp = Float64(Float64(b / d) + Float64(c * Float64(a / Float64(d * d))));
	else
		tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(Float64(1.0 / c) / Float64(1.0 / b))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (c <= -6.5e+53)
		tmp = (a / c) + ((d / c) * (b / c));
	elseif (c <= 13000000000.0)
		tmp = (b / d) + ((c / d) * (a / d));
	elseif (c <= 3e+24)
		tmp = (a / c) + ((b * d) / (c * c));
	elseif (c <= 2.1e+91)
		tmp = (b / d) + (c * (a / (d * d)));
	else
		tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -6.5e+53], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 13000000000.0], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3e+24], N[(N[(a / c), $MachinePrecision] + N[(N[(b * d), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e+91], N[(N[(b / d), $MachinePrecision] + N[(c * N[(a / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq 13000000000:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\

\mathbf{elif}\;c \leq 3 \cdot 10^{+24}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\

\mathbf{elif}\;c \leq 2.1 \cdot 10^{+91}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\

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


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

    1. Initial program 45.9%

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

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

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{d \cdot b}}{{c}^{2}} \]
      2. unpow282.8%

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

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

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

    if -6.50000000000000017e53 < c < 1.3e10

    1. Initial program 74.9%

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

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

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

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

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

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

    if 1.3e10 < c < 2.99999999999999995e24

    1. Initial program 81.8%

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

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

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

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

    if 2.99999999999999995e24 < c < 2.10000000000000008e91

    1. Initial program 33.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{c \cdot \frac{a}{d \cdot d}} \]
    6. Simplified77.0%

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

    if 2.10000000000000008e91 < c

    1. Initial program 37.6%

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

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

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{b \cdot d}{c \cdot c}} \]
    5. Taylor expanded in b around 0 66.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{c} + \frac{1}{\color{blue}{\frac{1}{\frac{d}{c}} \cdot \frac{c}{b}}} \]
      5. clear-num79.9%

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

        \[\leadsto \frac{a}{c} + \color{blue}{\frac{\frac{1}{\frac{c}{d}}}{\frac{c}{b}}} \]
      7. clear-num80.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{\frac{d}{c}}}{\frac{c}{b}} \]
      8. div-inv80.0%

        \[\leadsto \frac{a}{c} + \frac{\color{blue}{d \cdot \frac{1}{c}}}{\frac{c}{b}} \]
      9. div-inv80.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -6.5 \cdot 10^{+53}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{elif}\;c \leq 13000000000:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;c \leq 3 \cdot 10^{+24}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+91}:\\ \;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\ \end{array} \]

Alternative 8: 67.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.4 \cdot 10^{+52} \lor \neg \left(c \leq 500000000 \lor \neg \left(c \leq 6.2 \cdot 10^{+21}\right) \land c \leq 3.2 \cdot 10^{+92}\right):\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -4.4e52 or 5e8 < c < 6.2e21 or 3.20000000000000025e92 < c

    1. Initial program 44.0%

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

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

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

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

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

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

    if -4.4e52 < c < 5e8 or 6.2e21 < c < 3.20000000000000025e92

    1. Initial program 71.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.4 \cdot 10^{+52} \lor \neg \left(c \leq 500000000 \lor \neg \left(c \leq 6.2 \cdot 10^{+21}\right) \land c \leq 3.2 \cdot 10^{+92}\right):\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]

Alternative 9: 67.3% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;c \leq 18000000000:\\
\;\;\;\;\frac{b}{d}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -4.4e52 or 1.35e90 < c

    1. Initial program 42.3%

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

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

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

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

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

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

    if -4.4e52 < c < 1.8e10 or 5.8e26 < c < 1.35e90

    1. Initial program 71.4%

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

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

    if 1.8e10 < c < 5.8e26

    1. Initial program 81.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.4 \cdot 10^{+52}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{elif}\;c \leq 18000000000:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+26}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]

Alternative 10: 72.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;c \leq 550000000:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 2.1 \cdot 10^{+91}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -9.1999999999999999e52 or 2.10000000000000008e91 < c

    1. Initial program 42.3%

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

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

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

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

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

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

    if -9.1999999999999999e52 < c < 5.5e8 or 1.5e22 < c < 2.10000000000000008e91

    1. Initial program 71.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.5e8 < c < 1.5e22

    1. Initial program 81.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9.2 \cdot 10^{+52}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{elif}\;c \leq 550000000:\\ \;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\ \mathbf{elif}\;c \leq 1.5 \cdot 10^{+22}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+91}:\\ \;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]

Alternative 11: 75.7% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;c \leq 1020000:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\

\mathbf{elif}\;c \leq 2.3 \cdot 10^{+20}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\

\mathbf{elif}\;c \leq 1.4 \cdot 10^{+90}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if c < -1.09999999999999999e53 or 1.4e90 < c

    1. Initial program 42.3%

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

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

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

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

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

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

    if -1.09999999999999999e53 < c < 1.02e6

    1. Initial program 74.9%

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

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

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

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

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

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

    if 1.02e6 < c < 2.3e20

    1. Initial program 81.8%

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

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

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

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

    if 2.3e20 < c < 1.4e90

    1. Initial program 33.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{c \cdot \frac{a}{d \cdot d}} \]
    6. Simplified77.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.1 \cdot 10^{+53}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{elif}\;c \leq 1020000:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;c \leq 2.3 \cdot 10^{+20}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{+90}:\\ \;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]

Alternative 12: 63.0% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1.6 \cdot 10^{+53}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+91}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -1.6e+53) (/ a c) (if (<= c 2.1e+91) (/ b d) (/ a c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -1.6e+53) {
		tmp = a / c;
	} else if (c <= 2.1e+91) {
		tmp = b / d;
	} else {
		tmp = a / 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 (c <= (-1.6d+53)) then
        tmp = a / c
    else if (c <= 2.1d+91) then
        tmp = b / d
    else
        tmp = a / c
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -1.6e+53) {
		tmp = a / c;
	} else if (c <= 2.1e+91) {
		tmp = b / d;
	} else {
		tmp = a / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -1.6e+53:
		tmp = a / c
	elif c <= 2.1e+91:
		tmp = b / d
	else:
		tmp = a / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -1.6e+53)
		tmp = Float64(a / c);
	elseif (c <= 2.1e+91)
		tmp = Float64(b / d);
	else
		tmp = Float64(a / c);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (c <= -1.6e+53)
		tmp = a / c;
	elseif (c <= 2.1e+91)
		tmp = b / d;
	else
		tmp = a / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.6e+53], N[(a / c), $MachinePrecision], If[LessEqual[c, 2.1e+91], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.6 \cdot 10^{+53}:\\
\;\;\;\;\frac{a}{c}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.6e53 or 2.10000000000000008e91 < c

    1. Initial program 42.3%

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

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

    if -1.6e53 < c < 2.10000000000000008e91

    1. Initial program 71.7%

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

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

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

Alternative 13: 43.4% accurate, 3.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -2.4000000000000003e195

    1. Initial program 33.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.4000000000000003e195 < d

    1. Initial program 61.7%

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

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

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

Alternative 14: 42.5% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \frac{a}{c} \end{array} \]
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
	return a / 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 = a / c
end function
public static double code(double a, double b, double c, double d) {
	return a / c;
}
def code(a, b, c, d):
	return a / c
function code(a, b, c, d)
	return Float64(a / c)
end
function tmp = code(a, b, c, d)
	tmp = a / c;
end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}

\\
\frac{a}{c}
\end{array}
Derivation
  1. Initial program 59.0%

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  3. Final simplification42.8%

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

Developer target: 99.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \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))
   (/ (+ a (* b (/ d c))) (+ c (* d (/ d c))))
   (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (fabs(d) < fabs(c)) {
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)))
    else
        tmp = (b + (a * (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 = (a + (b * (d / c))) / (c + (d * (d / c)));
	} else {
		tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if math.fabs(d) < math.fabs(c):
		tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
	else:
		tmp = (b + (a * (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(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c))));
	else
		tmp = Float64(Float64(b + Float64(a * 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 = (a + (b * (d / c))) / (c + (d * (d / c)));
	else
		tmp = (b + (a * (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[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * 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{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023293 
(FPCore (a b c d)
  :name "Complex division, real part"
  :precision binary64

  :herbie-target
  (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))

  (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))