Complex division, real part

Percentage Accurate: 61.0% → 85.4%
Time: 9.7s
Alternatives: 14
Speedup: 1.3×

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.0% 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: 85.4% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{c} \cdot \frac{a + d \cdot \frac{b}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) INFINITY)
   (/ (/ (fma a c (* b d)) (hypot c d)) (hypot c d))
   (* (/ c c) (/ (+ a (* d (/ b c))) c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
		tmp = (fma(a, c, (b * d)) / hypot(c, d)) / hypot(c, d);
	} else {
		tmp = (c / c) * ((a + (d * (b / c))) / c);
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) <= Inf)
		tmp = Float64(Float64(fma(a, c, Float64(b * d)) / hypot(c, d)) / hypot(c, d));
	else
		tmp = Float64(Float64(c / c) * Float64(Float64(a + Float64(d * Float64(b / c))) / c));
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(c / c), $MachinePrecision] * N[(N[(a + N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 78.1%

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

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

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

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

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

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

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

      \[\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-*l/96.0%

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

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

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

    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. Step-by-step derivation
      1. *-un-lft-identity0.0%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt0.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-frac0.0%

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

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

        \[\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-def2.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-rr2.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. Step-by-step derivation
      1. associate-*l/2.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 80.7% 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 -5.6 \cdot 10^{+94}:\\ \;\;\;\;\frac{\frac{-d}{\frac{c}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
   (if (<= c -5.6e+94)
     (/ (- (/ (- d) (/ c b)) a) (hypot c d))
     (if (<= c -1e-33)
       t_0
       (if (<= c 7e-92)
         (+ (/ b d) (* a (/ (/ c d) d)))
         (if (<= c 3.6e+61) t_0 (/ (* a (/ c (hypot c d))) (hypot c d))))))))
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 <= -5.6e+94) {
		tmp = ((-d / (c / b)) - a) / hypot(c, d);
	} else if (c <= -1e-33) {
		tmp = t_0;
	} else if (c <= 7e-92) {
		tmp = (b / d) + (a * ((c / d) / d));
	} else if (c <= 3.6e+61) {
		tmp = t_0;
	} else {
		tmp = (a * (c / hypot(c, d))) / hypot(c, d);
	}
	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 <= -5.6e+94) {
		tmp = ((-d / (c / b)) - a) / Math.hypot(c, d);
	} else if (c <= -1e-33) {
		tmp = t_0;
	} else if (c <= 7e-92) {
		tmp = (b / d) + (a * ((c / d) / d));
	} else if (c <= 3.6e+61) {
		tmp = t_0;
	} else {
		tmp = (a * (c / Math.hypot(c, d))) / Math.hypot(c, d);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -5.6e+94:
		tmp = ((-d / (c / b)) - a) / math.hypot(c, d)
	elif c <= -1e-33:
		tmp = t_0
	elif c <= 7e-92:
		tmp = (b / d) + (a * ((c / d) / d))
	elif c <= 3.6e+61:
		tmp = t_0
	else:
		tmp = (a * (c / math.hypot(c, d))) / math.hypot(c, d)
	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 <= -5.6e+94)
		tmp = Float64(Float64(Float64(Float64(-d) / Float64(c / b)) - a) / hypot(c, d));
	elseif (c <= -1e-33)
		tmp = t_0;
	elseif (c <= 7e-92)
		tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) / d)));
	elseif (c <= 3.6e+61)
		tmp = t_0;
	else
		tmp = Float64(Float64(a * Float64(c / hypot(c, d))) / hypot(c, d));
	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 <= -5.6e+94)
		tmp = ((-d / (c / b)) - a) / hypot(c, d);
	elseif (c <= -1e-33)
		tmp = t_0;
	elseif (c <= 7e-92)
		tmp = (b / d) + (a * ((c / d) / d));
	elseif (c <= 3.6e+61)
		tmp = t_0;
	else
		tmp = (a * (c / hypot(c, d))) / hypot(c, d);
	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, -5.6e+94], N[(N[(N[((-d) / N[(c / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1e-33], t$95$0, If[LessEqual[c, 7e-92], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.6e+61], t$95$0, N[(N[(a * N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $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 -5.6 \cdot 10^{+94}:\\
\;\;\;\;\frac{\frac{-d}{\frac{c}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\

\mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 3.6 \cdot 10^{+61}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 30.6%

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

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

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

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

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

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

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

      \[\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-*l/57.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\frac{d}{\frac{c}{b}}}\right) - a}{\mathsf{hypot}\left(c, d\right)} \]
      5. distribute-neg-frac87.0%

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

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

    if -5.59999999999999997e94 < c < -1.0000000000000001e-33 or 7e-92 < c < 3.6000000000000001e61

    1. Initial program 92.5%

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

    if -1.0000000000000001e-33 < c < 7e-92

    1. Initial program 68.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{c}{d} \cdot \frac{a}{d}} \]
      3. clear-num80.8%

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{\frac{c}{d}}{\frac{d}{a}}} \]
    6. Applied egg-rr81.4%

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

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

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

    if 3.6000000000000001e61 < c

    1. Initial program 36.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt36.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-frac36.8%

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

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

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

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

      \[\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 a around inf 58.0%

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\color{blue}{c \cdot a}}{\mathsf{hypot}\left(c, d\right)} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt58.0%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{c}{\sqrt{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{a}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}}{\mathsf{hypot}\left(c, d\right)} \]
      3. frac-times58.0%

        \[\leadsto \frac{\color{blue}{\frac{c \cdot a}{\sqrt{\mathsf{hypot}\left(c, d\right)} \cdot \sqrt{\mathsf{hypot}\left(c, d\right)}}}}{\mathsf{hypot}\left(c, d\right)} \]
      4. add-sqr-sqrt58.1%

        \[\leadsto \frac{\frac{c \cdot a}{\color{blue}{\mathsf{hypot}\left(c, d\right)}}}{\mathsf{hypot}\left(c, d\right)} \]
      5. associate-/l*88.5%

        \[\leadsto \frac{\color{blue}{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}}{\mathsf{hypot}\left(c, d\right)} \]
      6. associate-/r/88.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5.6 \cdot 10^{+94}:\\ \;\;\;\;\frac{\frac{-d}{\frac{c}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{+61}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \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 -4 \cdot 10^{+93}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 1.22 \cdot 10^{+148}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
   (if (<= c -4e+93)
     (+ (/ a c) (* (/ b c) (/ d c)))
     (if (<= c -1e-33)
       t_0
       (if (<= c 2.4e-92)
         (+ (/ b d) (* a (/ (/ c d) d)))
         (if (<= c 1.22e+148) t_0 (/ (+ a (/ d (/ c b))) (hypot c d))))))))
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 <= -4e+93) {
		tmp = (a / c) + ((b / c) * (d / c));
	} else if (c <= -1e-33) {
		tmp = t_0;
	} else if (c <= 2.4e-92) {
		tmp = (b / d) + (a * ((c / d) / d));
	} else if (c <= 1.22e+148) {
		tmp = t_0;
	} else {
		tmp = (a + (d / (c / b))) / hypot(c, d);
	}
	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 <= -4e+93) {
		tmp = (a / c) + ((b / c) * (d / c));
	} else if (c <= -1e-33) {
		tmp = t_0;
	} else if (c <= 2.4e-92) {
		tmp = (b / d) + (a * ((c / d) / d));
	} else if (c <= 1.22e+148) {
		tmp = t_0;
	} else {
		tmp = (a + (d / (c / b))) / Math.hypot(c, d);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -4e+93:
		tmp = (a / c) + ((b / c) * (d / c))
	elif c <= -1e-33:
		tmp = t_0
	elif c <= 2.4e-92:
		tmp = (b / d) + (a * ((c / d) / d))
	elif c <= 1.22e+148:
		tmp = t_0
	else:
		tmp = (a + (d / (c / b))) / math.hypot(c, d)
	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 <= -4e+93)
		tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c)));
	elseif (c <= -1e-33)
		tmp = t_0;
	elseif (c <= 2.4e-92)
		tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) / d)));
	elseif (c <= 1.22e+148)
		tmp = t_0;
	else
		tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / hypot(c, d));
	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 <= -4e+93)
		tmp = (a / c) + ((b / c) * (d / c));
	elseif (c <= -1e-33)
		tmp = t_0;
	elseif (c <= 2.4e-92)
		tmp = (b / d) + (a * ((c / d) / d));
	elseif (c <= 1.22e+148)
		tmp = t_0;
	else
		tmp = (a + (d / (c / b))) / hypot(c, d);
	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, -4e+93], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1e-33], t$95$0, If[LessEqual[c, 2.4e-92], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.22e+148], t$95$0, N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $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 -4 \cdot 10^{+93}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\

\mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 1.22 \cdot 10^{+148}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 30.6%

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

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

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

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

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

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

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

      \[\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 inf 76.1%

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

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

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

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

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

    if -4.00000000000000017e93 < c < -1.0000000000000001e-33 or 2.4000000000000001e-92 < c < 1.22000000000000007e148

    1. Initial program 88.1%

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

    if -1.0000000000000001e-33 < c < 2.4000000000000001e-92

    1. Initial program 68.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{c}{d} \cdot \frac{a}{d}} \]
      3. clear-num80.8%

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{\frac{c}{d}}{\frac{d}{a}}} \]
    6. Applied egg-rr81.4%

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

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

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

    if 1.22000000000000007e148 < c

    1. Initial program 29.1%

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

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

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

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

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

        \[\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.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-rr53.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. Step-by-step derivation
      1. associate-*l/53.8%

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

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

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

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

        \[\leadsto \frac{a + \color{blue}{\frac{d}{\frac{c}{b}}}}{\mathsf{hypot}\left(c, d\right)} \]
    8. Simplified88.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4 \cdot 10^{+93}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 1.22 \cdot 10^{+148}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 4: 81.4% 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 -4.1 \cdot 10^{+92}:\\ \;\;\;\;\frac{\frac{-d}{\frac{c}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 4.2 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 4.6 \cdot 10^{+139}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
   (if (<= c -4.1e+92)
     (/ (- (/ (- d) (/ c b)) a) (hypot c d))
     (if (<= c -1e-33)
       t_0
       (if (<= c 4.2e-92)
         (+ (/ b d) (* a (/ (/ c d) d)))
         (if (<= c 4.6e+139) t_0 (/ (+ a (/ d (/ c b))) (hypot c d))))))))
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 <= -4.1e+92) {
		tmp = ((-d / (c / b)) - a) / hypot(c, d);
	} else if (c <= -1e-33) {
		tmp = t_0;
	} else if (c <= 4.2e-92) {
		tmp = (b / d) + (a * ((c / d) / d));
	} else if (c <= 4.6e+139) {
		tmp = t_0;
	} else {
		tmp = (a + (d / (c / b))) / hypot(c, d);
	}
	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 <= -4.1e+92) {
		tmp = ((-d / (c / b)) - a) / Math.hypot(c, d);
	} else if (c <= -1e-33) {
		tmp = t_0;
	} else if (c <= 4.2e-92) {
		tmp = (b / d) + (a * ((c / d) / d));
	} else if (c <= 4.6e+139) {
		tmp = t_0;
	} else {
		tmp = (a + (d / (c / b))) / Math.hypot(c, d);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -4.1e+92:
		tmp = ((-d / (c / b)) - a) / math.hypot(c, d)
	elif c <= -1e-33:
		tmp = t_0
	elif c <= 4.2e-92:
		tmp = (b / d) + (a * ((c / d) / d))
	elif c <= 4.6e+139:
		tmp = t_0
	else:
		tmp = (a + (d / (c / b))) / math.hypot(c, d)
	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 <= -4.1e+92)
		tmp = Float64(Float64(Float64(Float64(-d) / Float64(c / b)) - a) / hypot(c, d));
	elseif (c <= -1e-33)
		tmp = t_0;
	elseif (c <= 4.2e-92)
		tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) / d)));
	elseif (c <= 4.6e+139)
		tmp = t_0;
	else
		tmp = Float64(Float64(a + Float64(d / Float64(c / b))) / hypot(c, d));
	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 <= -4.1e+92)
		tmp = ((-d / (c / b)) - a) / hypot(c, d);
	elseif (c <= -1e-33)
		tmp = t_0;
	elseif (c <= 4.2e-92)
		tmp = (b / d) + (a * ((c / d) / d));
	elseif (c <= 4.6e+139)
		tmp = t_0;
	else
		tmp = (a + (d / (c / b))) / hypot(c, d);
	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, -4.1e+92], N[(N[(N[((-d) / N[(c / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1e-33], t$95$0, If[LessEqual[c, 4.2e-92], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.6e+139], t$95$0, N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $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 -4.1 \cdot 10^{+92}:\\
\;\;\;\;\frac{\frac{-d}{\frac{c}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\

\mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 4.6 \cdot 10^{+139}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 30.6%

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

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

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

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

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

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

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

      \[\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-*l/57.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\frac{d}{\frac{c}{b}}}\right) - a}{\mathsf{hypot}\left(c, d\right)} \]
      5. distribute-neg-frac87.0%

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

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

    if -4.10000000000000024e92 < c < -1.0000000000000001e-33 or 4.2e-92 < c < 4.6e139

    1. Initial program 88.1%

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

    if -1.0000000000000001e-33 < c < 4.2e-92

    1. Initial program 68.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{c}{d} \cdot \frac{a}{d}} \]
      3. clear-num80.8%

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{\frac{c}{d}}{\frac{d}{a}}} \]
    6. Applied egg-rr81.4%

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

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

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

    if 4.6e139 < c

    1. Initial program 29.1%

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

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

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

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

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

        \[\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.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-rr53.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. Step-by-step derivation
      1. associate-*l/53.8%

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

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

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

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

        \[\leadsto \frac{a + \color{blue}{\frac{d}{\frac{c}{b}}}}{\mathsf{hypot}\left(c, d\right)} \]
    8. Simplified88.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.1 \cdot 10^{+92}:\\ \;\;\;\;\frac{\frac{-d}{\frac{c}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 4.2 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 4.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + \frac{d}{\frac{c}{b}}}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternative 5: 81.1% 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}\\ \mathbf{if}\;c \leq -9.2 \cdot 10^{+93}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 4.6 \cdot 10^{+139}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
   (if (<= c -9.2e+93)
     (+ (/ a c) (* (/ b c) (/ d c)))
     (if (<= c -1e-33)
       t_0
       (if (<= c 2.7e-92)
         (+ (/ b d) (* a (/ (/ c d) d)))
         (if (<= c 4.6e+139) t_0 (+ (/ a c) (/ (* d (/ b c)) c))))))))
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 <= -9.2e+93) {
		tmp = (a / c) + ((b / c) * (d / c));
	} else if (c <= -1e-33) {
		tmp = t_0;
	} else if (c <= 2.7e-92) {
		tmp = (b / d) + (a * ((c / d) / d));
	} else if (c <= 4.6e+139) {
		tmp = t_0;
	} else {
		tmp = (a / c) + ((d * (b / c)) / c);
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
    if (c <= (-9.2d+93)) then
        tmp = (a / c) + ((b / c) * (d / c))
    else if (c <= (-1d-33)) then
        tmp = t_0
    else if (c <= 2.7d-92) then
        tmp = (b / d) + (a * ((c / d) / d))
    else if (c <= 4.6d+139) then
        tmp = t_0
    else
        tmp = (a / c) + ((d * (b / c)) / c)
    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 tmp;
	if (c <= -9.2e+93) {
		tmp = (a / c) + ((b / c) * (d / c));
	} else if (c <= -1e-33) {
		tmp = t_0;
	} else if (c <= 2.7e-92) {
		tmp = (b / d) + (a * ((c / d) / d));
	} else if (c <= 4.6e+139) {
		tmp = t_0;
	} else {
		tmp = (a / c) + ((d * (b / c)) / c);
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
	tmp = 0
	if c <= -9.2e+93:
		tmp = (a / c) + ((b / c) * (d / c))
	elif c <= -1e-33:
		tmp = t_0
	elif c <= 2.7e-92:
		tmp = (b / d) + (a * ((c / d) / d))
	elif c <= 4.6e+139:
		tmp = t_0
	else:
		tmp = (a / c) + ((d * (b / c)) / c)
	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 <= -9.2e+93)
		tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c)));
	elseif (c <= -1e-33)
		tmp = t_0;
	elseif (c <= 2.7e-92)
		tmp = Float64(Float64(b / d) + Float64(a * Float64(Float64(c / d) / d)));
	elseif (c <= 4.6e+139)
		tmp = t_0;
	else
		tmp = Float64(Float64(a / c) + Float64(Float64(d * Float64(b / c)) / c));
	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 <= -9.2e+93)
		tmp = (a / c) + ((b / c) * (d / c));
	elseif (c <= -1e-33)
		tmp = t_0;
	elseif (c <= 2.7e-92)
		tmp = (b / d) + (a * ((c / d) / d));
	elseif (c <= 4.6e+139)
		tmp = t_0;
	else
		tmp = (a / c) + ((d * (b / c)) / c);
	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, -9.2e+93], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1e-33], t$95$0, If[LessEqual[c, 2.7e-92], N[(N[(b / d), $MachinePrecision] + N[(a * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.6e+139], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(N[(d * N[(b / c), $MachinePrecision]), $MachinePrecision] / c), $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 -9.2 \cdot 10^{+93}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\

\mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 4.6 \cdot 10^{+139}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 30.6%

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

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

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

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

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

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

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

      \[\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 inf 76.1%

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

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

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

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

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

    if -9.2000000000000006e93 < c < -1.0000000000000001e-33 or 2.69999999999999995e-92 < c < 4.6e139

    1. Initial program 88.1%

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

    if -1.0000000000000001e-33 < c < 2.69999999999999995e-92

    1. Initial program 68.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{c}{d} \cdot \frac{a}{d}} \]
      3. clear-num80.8%

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{\frac{c}{d}}{\frac{d}{a}}} \]
    6. Applied egg-rr81.4%

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

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

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

    if 4.6e139 < c

    1. Initial program 29.1%

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

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

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

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

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

        \[\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.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-rr53.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. Step-by-step derivation
      1. associate-*l/53.8%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -9.2 \cdot 10^{+93}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-33}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d} + a \cdot \frac{\frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 4.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\ \end{array} \]

Alternative 6: 77.2% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -6.6e20

    1. Initial program 46.0%

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{c}{{d}^{2}} \cdot a} \]
      3. unpow270.6%

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{\frac{c}{d}}{\frac{d}{a}}} \]
    6. Applied egg-rr81.4%

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

    if -6.6e20 < d < 2.5e-31

    1. Initial program 70.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt70.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-frac70.8%

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

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

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

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

      \[\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-*l/86.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\left(\frac{d}{c} \cdot b\right) \cdot c + c \cdot a}{c \cdot c}} \]
    10. Applied egg-rr55.9%

      \[\leadsto \color{blue}{\frac{\left(\frac{d}{c} \cdot b\right) \cdot c + c \cdot a}{c \cdot c}} \]
    11. Step-by-step derivation
      1. +-commutative55.9%

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

        \[\leadsto \frac{c \cdot a + \color{blue}{c \cdot \left(\frac{d}{c} \cdot b\right)}}{c \cdot c} \]
      3. distribute-lft-out55.9%

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

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

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

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

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

    if 2.5e-31 < d

    1. Initial program 58.7%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt58.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-frac58.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-def58.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-def58.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-def69.2%

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

      \[\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-*l/69.3%

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

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

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

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

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

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

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

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

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

Alternative 7: 69.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.7 \cdot 10^{-30} \lor \neg \left(c \leq 2.3 \cdot 10^{-68}\right):\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.69999999999999987e-30 or 2.29999999999999997e-68 < c

    1. Initial program 55.2%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt55.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-frac55.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-def55.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-def55.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-def73.0%

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

      \[\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 inf 70.1%

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

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

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

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

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

    if -2.69999999999999987e-30 < c < 2.29999999999999997e-68

    1. Initial program 70.3%

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

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

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

Alternative 8: 74.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.6 \cdot 10^{+20} \lor \neg \left(d \leq 2.2 \cdot 10^{-31}\right):\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -6.6e20 or 2.2000000000000001e-31 < d

    1. Initial program 52.9%

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{c}{{d}^{2}} \cdot a} \]
      3. unpow270.9%

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

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

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

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

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

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

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

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

    if -6.6e20 < d < 2.2000000000000001e-31

    1. Initial program 70.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt70.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-frac70.8%

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

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

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

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

      \[\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-*l/86.9%

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

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

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

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

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

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

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

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

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

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

Alternative 9: 77.2% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -3.2e21 or 1.99999999999999986e-34 < d

    1. Initial program 52.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt52.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-frac53.0%

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

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

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

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

      \[\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-*l/66.4%

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

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

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

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

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

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

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

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

    if -3.2e21 < d < 1.99999999999999986e-34

    1. Initial program 70.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt70.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-frac70.8%

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

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

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

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

      \[\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-*l/86.9%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 70.0% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;c \leq 2.3 \cdot 10^{-68}:\\
\;\;\;\;\frac{b}{d}\\

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


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

    1. Initial program 56.6%

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

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

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

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

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

        \[\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-def74.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-rr74.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-*l/74.2%

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

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

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

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

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

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

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

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

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

    if -1.6799999999999999e-31 < c < 2.29999999999999997e-68

    1. Initial program 70.3%

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

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

    if 2.29999999999999997e-68 < c

    1. Initial program 53.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt53.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-frac53.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-def53.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-def53.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-def71.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-rr71.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 inf 72.0%

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

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

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

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

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

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

Alternative 11: 69.9% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.05e-32

    1. Initial program 56.6%

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

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

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

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

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

        \[\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-def74.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-rr74.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-*l/74.2%

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

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

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

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

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

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

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

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

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

    if -1.05e-32 < c < 2.10000000000000008e-68

    1. Initial program 70.3%

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

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

    if 2.10000000000000008e-68 < c

    1. Initial program 53.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt53.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-frac53.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-def53.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-def53.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-def71.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-rr71.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-*l/72.1%

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

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

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

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

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

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

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

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

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

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

Alternative 12: 77.3% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -8e20

    1. Initial program 46.0%

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{c}{{d}^{2}} \cdot a} \]
      3. unpow270.6%

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{\frac{c}{d}}{\frac{d}{a}}} \]
    6. Applied egg-rr81.4%

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

    if -8e20 < d < 3.99999999999999971e-34

    1. Initial program 70.9%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt70.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-frac70.8%

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

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

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

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

      \[\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-*l/86.9%

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

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

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

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

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

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

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

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

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

    if 3.99999999999999971e-34 < d

    1. Initial program 58.7%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(a \cdot c + b \cdot d\right)}}{c \cdot c + d \cdot d} \]
      2. add-sqr-sqrt58.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-frac58.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-def58.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-def58.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-def69.2%

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

      \[\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-*l/69.3%

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

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

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

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

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

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

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

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

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

Alternative 13: 62.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -2.8 \cdot 10^{+113}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -4 \cdot 10^{+45} \lor \neg \left(c \leq -5 \cdot 10^{-31}\right) \land c \leq 1.62 \cdot 10^{-68}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -2.8e+113)
   (/ a c)
   (if (or (<= c -4e+45) (and (not (<= c -5e-31)) (<= c 1.62e-68)))
     (/ b d)
     (/ a c))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -2.8e+113) {
		tmp = a / c;
	} else if ((c <= -4e+45) || (!(c <= -5e-31) && (c <= 1.62e-68))) {
		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 <= (-2.8d+113)) then
        tmp = a / c
    else if ((c <= (-4d+45)) .or. (.not. (c <= (-5d-31))) .and. (c <= 1.62d-68)) 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 <= -2.8e+113) {
		tmp = a / c;
	} else if ((c <= -4e+45) || (!(c <= -5e-31) && (c <= 1.62e-68))) {
		tmp = b / d;
	} else {
		tmp = a / c;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -2.8e+113:
		tmp = a / c
	elif (c <= -4e+45) or (not (c <= -5e-31) and (c <= 1.62e-68)):
		tmp = b / d
	else:
		tmp = a / c
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -2.8e+113)
		tmp = Float64(a / c);
	elseif ((c <= -4e+45) || (!(c <= -5e-31) && (c <= 1.62e-68)))
		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 <= -2.8e+113)
		tmp = a / c;
	elseif ((c <= -4e+45) || (~((c <= -5e-31)) && (c <= 1.62e-68)))
		tmp = b / d;
	else
		tmp = a / c;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -2.8e+113], N[(a / c), $MachinePrecision], If[Or[LessEqual[c, -4e+45], And[N[Not[LessEqual[c, -5e-31]], $MachinePrecision], LessEqual[c, 1.62e-68]]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;c \leq -4 \cdot 10^{+45} \lor \neg \left(c \leq -5 \cdot 10^{-31}\right) \land c \leq 1.62 \cdot 10^{-68}:\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.79999999999999998e113 or -3.9999999999999997e45 < c < -5e-31 or 1.62000000000000005e-68 < c

    1. Initial program 54.8%

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

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

    if -2.79999999999999998e113 < c < -3.9999999999999997e45 or -5e-31 < c < 1.62000000000000005e-68

    1. Initial program 69.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.8 \cdot 10^{+113}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -4 \cdot 10^{+45} \lor \neg \left(c \leq -5 \cdot 10^{-31}\right) \land c \leq 1.62 \cdot 10^{-68}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]

Alternative 14: 42.0% 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 61.9%

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  3. Final simplification43.7%

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

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