Complex division, real part

Percentage Accurate: 61.8% → 84.8%
Time: 13.3s
Alternatives: 14
Speedup: 2.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 61.8% accurate, 1.0× speedup?

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

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

Alternative 1: 84.8% 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{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) INFINITY)
   (* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d)))
   (+ (/ b d) (* (/ c d) (/ a d)))))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
		tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
	} else {
		tmp = (b / d) + ((c / d) * (a / d));
	}
	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(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d)));
	else
		tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d)));
	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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $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}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\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)}\\

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


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

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

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

        \[\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-frac74.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-def74.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-def74.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-def94.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-rr94.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)}} \]

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{\frac{2}{2}}{\frac{d}{c}} \cdot \frac{a}{d}} \]
      6. metadata-eval65.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \leq \infty:\\ \;\;\;\;\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)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \end{array} \]

Alternative 2: 81.8% accurate, 0.0× speedup?

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

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

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

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

\mathbf{elif}\;d \leq 3.8 \cdot 10^{+68}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{\frac{\mathsf{hypot}\left(c, d\right)}{t_0}}\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(b + c \cdot \frac{a}{d}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -1.59999999999999992e159

    1. Initial program 34.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999992e159 < d < -3.9000000000000001e-106

    1. Initial program 77.3%

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

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

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

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

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

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

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

    if -3.9000000000000001e-106 < d < 1.80000000000000003e-89

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

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

    if 1.80000000000000003e-89 < d < 3.8000000000000001e68

    1. Initial program 81.2%

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

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

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

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

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

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

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

        \[\leadsto \frac{a \cdot c + b \cdot d}{\frac{\color{blue}{c \cdot c + d \cdot d}}{1}} \]
      8. add-sqr-sqrt81.1%

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

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

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

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

    if 3.8000000000000001e68 < d

    1. Initial program 41.4%

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

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

        \[\leadsto \frac{1 \cdot \left(a \cdot c + b \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac41.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-def41.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-def41.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-def60.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-rr60.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 0 82.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq -3.9 \cdot 10^{-106}:\\ \;\;\;\;\mathsf{fma}\left(a, c, b \cdot d\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{-89}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{+68}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{\frac{\mathsf{hypot}\left(c, d\right)}{\frac{1}{\mathsf{hypot}\left(c, d\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + c \cdot \frac{a}{d}\right)\\ \end{array} \]

Alternative 3: 81.8% accurate, 0.1× speedup?

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

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

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

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

\mathbf{elif}\;d \leq 5 \cdot 10^{+62}:\\
\;\;\;\;\frac{t_0}{\frac{\mathsf{hypot}\left(c, d\right)}{t_1}}\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b + c \cdot \frac{a}{d}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if d < -1.59999999999999992e159

    1. Initial program 34.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999992e159 < d < -6.19999999999999971e-106

    1. Initial program 77.3%

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

    if -6.19999999999999971e-106 < d < 2.8e-91

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

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

    if 2.8e-91 < d < 5.00000000000000029e62

    1. Initial program 81.2%

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

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

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

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

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

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

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

        \[\leadsto \frac{a \cdot c + b \cdot d}{\frac{\color{blue}{c \cdot c + d \cdot d}}{1}} \]
      8. add-sqr-sqrt81.1%

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

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

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

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

    if 5.00000000000000029e62 < d

    1. Initial program 41.4%

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

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

        \[\leadsto \frac{1 \cdot \left(a \cdot c + b \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac41.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-def41.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-def41.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-def60.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-rr60.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 0 82.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq -6.2 \cdot 10^{-106}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.8 \cdot 10^{-91}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 5 \cdot 10^{+62}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{\frac{\mathsf{hypot}\left(c, d\right)}{\frac{1}{\mathsf{hypot}\left(c, d\right)}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + c \cdot \frac{a}{d}\right)\\ \end{array} \]

Alternative 4: 81.8% 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}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq -3.2 \cdot 10^{-108}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.05 \cdot 10^{-90}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.05 \cdot 10^{+69}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + c \cdot \frac{a}{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 (<= d -1.6e+159)
     (+ (/ b d) (* (/ c d) (/ a d)))
     (if (<= d -3.2e-108)
       t_0
       (if (<= d 2.05e-90)
         (+ (/ a c) (/ (/ (* b d) c) c))
         (if (<= d 3.05e+69)
           t_0
           (* (/ 1.0 (hypot c d)) (+ b (* c (/ a 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 (d <= -1.6e+159) {
		tmp = (b / d) + ((c / d) * (a / d));
	} else if (d <= -3.2e-108) {
		tmp = t_0;
	} else if (d <= 2.05e-90) {
		tmp = (a / c) + (((b * d) / c) / c);
	} else if (d <= 3.05e+69) {
		tmp = t_0;
	} else {
		tmp = (1.0 / hypot(c, d)) * (b + (c * (a / 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 (d <= -1.6e+159) {
		tmp = (b / d) + ((c / d) * (a / d));
	} else if (d <= -3.2e-108) {
		tmp = t_0;
	} else if (d <= 2.05e-90) {
		tmp = (a / c) + (((b * d) / c) / c);
	} else if (d <= 3.05e+69) {
		tmp = t_0;
	} else {
		tmp = (1.0 / Math.hypot(c, d)) * (b + (c * (a / d)));
	}
	return tmp;
}
def code(a, b, c, d):
	t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
	tmp = 0
	if d <= -1.6e+159:
		tmp = (b / d) + ((c / d) * (a / d))
	elif d <= -3.2e-108:
		tmp = t_0
	elif d <= 2.05e-90:
		tmp = (a / c) + (((b * d) / c) / c)
	elif d <= 3.05e+69:
		tmp = t_0
	else:
		tmp = (1.0 / math.hypot(c, d)) * (b + (c * (a / 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 (d <= -1.6e+159)
		tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d)));
	elseif (d <= -3.2e-108)
		tmp = t_0;
	elseif (d <= 2.05e-90)
		tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c));
	elseif (d <= 3.05e+69)
		tmp = t_0;
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b + Float64(c * Float64(a / 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 (d <= -1.6e+159)
		tmp = (b / d) + ((c / d) * (a / d));
	elseif (d <= -3.2e-108)
		tmp = t_0;
	elseif (d <= 2.05e-90)
		tmp = (a / c) + (((b * d) / c) / c);
	elseif (d <= 3.05e+69)
		tmp = t_0;
	else
		tmp = (1.0 / hypot(c, d)) * (b + (c * (a / 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[d, -1.6e+159], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.2e-108], t$95$0, If[LessEqual[d, 2.05e-90], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.05e+69], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -3.2 \cdot 10^{-108}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 3.05 \cdot 10^{+69}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 34.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999992e159 < d < -3.2e-108 or 2.05000000000000017e-90 < d < 3.05e69

    1. Initial program 78.8%

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

    if -3.2e-108 < d < 2.05000000000000017e-90

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

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

    if 3.05e69 < d

    1. Initial program 40.3%

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

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

        \[\leadsto \frac{1 \cdot \left(a \cdot c + b \cdot d\right)}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} \]
      3. times-frac40.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-def40.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-def40.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-def59.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq -3.2 \cdot 10^{-108}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 2.05 \cdot 10^{-90}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 3.05 \cdot 10^{+69}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + c \cdot \frac{a}{d}\right)\\ \end{array} \]

Alternative 5: 81.4% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;d \leq -5.6 \cdot 10^{-100}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 2 \cdot 10^{+71}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -1.59999999999999992e159 or 2.0000000000000001e71 < d

    1. Initial program 38.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.59999999999999992e159 < d < -5.59999999999999991e-100 or 8.4999999999999994e-84 < d < 2.0000000000000001e71

    1. Initial program 78.8%

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

    if -5.59999999999999991e-100 < d < 8.4999999999999994e-84

    1. Initial program 66.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -1.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq -5.6 \cdot 10^{-100}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{-84}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 2 \cdot 10^{+71}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \end{array} \]

Alternative 6: 76.8% accurate, 0.7× speedup?

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

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

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

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

\mathbf{elif}\;d \leq 1.02 \cdot 10^{+65}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\left(-a\right) - \frac{b}{\frac{c}{d}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.7500000000000001e-23 or 1.02000000000000005e65 < 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 74.1%

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

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

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

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

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

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

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

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

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

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

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

    if -2.7500000000000001e-23 < d < 3.7e-22

    1. Initial program 67.8%

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

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

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

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

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

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

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

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

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

    if 3.7e-22 < d < 8.29999999999999951e46

    1. Initial program 92.9%

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

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

    if 8.29999999999999951e46 < d < 1.02000000000000005e65

    1. Initial program 37.8%

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

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

        \[\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-frac37.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-def37.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-def37.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-def99.5%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.75 \cdot 10^{-23}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq 3.7 \cdot 10^{-22}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 8.3 \cdot 10^{+46}:\\ \;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.02 \cdot 10^{+65}:\\ \;\;\;\;\frac{-1}{c} \cdot \left(\left(-a\right) - \frac{b}{\frac{c}{d}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \end{array} \]

Alternative 7: 76.9% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;d \leq 5.8 \cdot 10^{-23}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 4.9 \cdot 10^{+61}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -3.19999999999999976e-23 or 4.90000000000000025e61 < 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 74.1%

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

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

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

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

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

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

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

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

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

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

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

    if -3.19999999999999976e-23 < d < 5.8000000000000003e-23 or 7.4999999999999995e49 < d < 4.90000000000000025e61

    1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

    if 5.8000000000000003e-23 < d < 7.4999999999999995e49

    1. Initial program 92.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.2 \cdot 10^{-23}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq 5.8 \cdot 10^{-23}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{+49}:\\ \;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 4.9 \cdot 10^{+61}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \end{array} \]

Alternative 8: 75.4% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;c \leq 6.4 \cdot 10^{+53}:\\
\;\;\;\;\frac{b}{d} + \frac{1}{d} \cdot \frac{a}{\frac{d}{c}}\\

\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + d \cdot \left(\frac{1}{c} \cdot \frac{b}{c}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -2.70000000000000003e39

    1. Initial program 46.8%

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

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

        \[\leadsto \color{blue}{\frac{a}{\frac{{c}^{2} + {d}^{2}}{c}}} \]
      2. +-commutative44.6%

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

        \[\leadsto \frac{a}{\frac{\color{blue}{d \cdot d} + {c}^{2}}{c}} \]
      4. fma-udef44.6%

        \[\leadsto \frac{a}{\frac{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}}{c}} \]
    4. Simplified44.6%

      \[\leadsto \color{blue}{\frac{a}{\frac{\mathsf{fma}\left(d, d, {c}^{2}\right)}{c}}} \]
    5. Taylor expanded in d around 0 65.3%

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

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

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

        \[\leadsto \frac{a}{c + \color{blue}{d \cdot \left(d \cdot \frac{1}{c}\right)}} \]
      4. div-inv74.5%

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

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

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

        \[\leadsto \frac{a}{c + \color{blue}{\frac{d}{\frac{c}{d}}}} \]
    9. Applied egg-rr74.6%

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

    if -2.70000000000000003e39 < c < 6.4e53

    1. Initial program 70.7%

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

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

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

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

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

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

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

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

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

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

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

    if 6.4e53 < c

    1. Initial program 52.4%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.7 \cdot 10^{+39}:\\ \;\;\;\;\frac{a}{c + \frac{d}{\frac{c}{d}}}\\ \mathbf{elif}\;c \leq 6.4 \cdot 10^{+53}:\\ \;\;\;\;\frac{b}{d} + \frac{1}{d} \cdot \frac{a}{\frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + d \cdot \left(\frac{1}{c} \cdot \frac{b}{c}\right)\\ \end{array} \]

Alternative 9: 71.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.5 \cdot 10^{-13} \lor \neg \left(d \leq 155000000000\right):\\
\;\;\;\;\frac{b}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -8.5000000000000001e-13 or 1.55e11 < d

    1. Initial program 53.3%

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

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

    if -8.5000000000000001e-13 < d < 1.55e11

    1. Initial program 70.4%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 77.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d \leq -7.2 \cdot 10^{-24} \lor \neg \left(d \leq 850\right):\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{b \cdot d}{c}}{c}\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (or (<= d -7.2e-24) (not (<= d 850.0)))
   (+ (/ 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 <= -7.2e-24) || !(d <= 850.0)) {
		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 <= (-7.2d-24)) .or. (.not. (d <= 850.0d0))) 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 <= -7.2e-24) || !(d <= 850.0)) {
		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 <= -7.2e-24) or not (d <= 850.0):
		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 <= -7.2e-24) || !(d <= 850.0))
		tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d)));
	else
		tmp = Float64(Float64(a / c) + Float64(Float64(Float64(b * d) / c) / c));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if ((d <= -7.2e-24) || ~((d <= 850.0)))
		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, -7.2e-24], N[Not[LessEqual[d, 850.0]], $MachinePrecision]], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.2 \cdot 10^{-24} \lor \neg \left(d \leq 850\right):\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -7.2000000000000002e-24 or 850 < d

    1. Initial program 55.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.2000000000000002e-24 < d < 850

    1. Initial program 69.1%

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

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

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

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

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

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

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

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

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

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

Alternative 11: 67.1% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -3 \cdot 10^{-8} \lor \neg \left(c \leq 2.4 \cdot 10^{-171}\right):\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -2.99999999999999973e-8 or 2.39999999999999987e-171 < c

    1. Initial program 55.9%

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

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

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

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

        \[\leadsto \frac{a}{\frac{\color{blue}{d \cdot d} + {c}^{2}}{c}} \]
      4. fma-udef46.2%

        \[\leadsto \frac{a}{\frac{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}}{c}} \]
    4. Simplified46.2%

      \[\leadsto \color{blue}{\frac{a}{\frac{\mathsf{fma}\left(d, d, {c}^{2}\right)}{c}}} \]
    5. Taylor expanded in d around 0 64.2%

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

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

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

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

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

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

    if -2.99999999999999973e-8 < c < 2.39999999999999987e-171

    1. Initial program 71.0%

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

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

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

Alternative 12: 67.1% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 53.0%

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

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

        \[\leadsto \color{blue}{\frac{a}{\frac{{c}^{2} + {d}^{2}}{c}}} \]
      2. +-commutative45.9%

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

        \[\leadsto \frac{a}{\frac{\color{blue}{d \cdot d} + {c}^{2}}{c}} \]
      4. fma-udef45.9%

        \[\leadsto \frac{a}{\frac{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}}{c}} \]
    4. Simplified45.9%

      \[\leadsto \color{blue}{\frac{a}{\frac{\mathsf{fma}\left(d, d, {c}^{2}\right)}{c}}} \]
    5. Taylor expanded in d around 0 62.3%

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

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

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

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

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

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

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

        \[\leadsto \frac{a}{c + \color{blue}{\frac{d}{\frac{c}{d}}}} \]
    9. Applied egg-rr70.9%

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

    if -1.45e-11 < c < 1.25e-168

    1. Initial program 71.0%

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

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

    if 1.25e-168 < c

    1. Initial program 58.2%

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

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

        \[\leadsto \color{blue}{\frac{a}{\frac{{c}^{2} + {d}^{2}}{c}}} \]
      2. +-commutative46.5%

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

        \[\leadsto \frac{a}{\frac{\color{blue}{d \cdot d} + {c}^{2}}{c}} \]
      4. fma-udef46.5%

        \[\leadsto \frac{a}{\frac{\color{blue}{\mathsf{fma}\left(d, d, {c}^{2}\right)}}{c}} \]
    4. Simplified46.5%

      \[\leadsto \color{blue}{\frac{a}{\frac{\mathsf{fma}\left(d, d, {c}^{2}\right)}{c}}} \]
    5. Taylor expanded in d around 0 65.8%

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

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

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

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

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

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

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

Alternative 13: 63.9% accurate, 2.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.7 \cdot 10^{+39} \lor \neg \left(c \leq 6 \cdot 10^{+53}\right):\\
\;\;\;\;\frac{a}{c}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -1.6999999999999999e39 or 5.99999999999999996e53 < c

    1. Initial program 49.6%

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

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

    if -1.6999999999999999e39 < c < 5.99999999999999996e53

    1. Initial program 70.7%

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

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

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

Alternative 14: 43.4% 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.5%

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

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

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