Complex division, real part

Percentage Accurate: 62.0% → 84.9%
Time: 9.7s
Alternatives: 14
Speedup: 2.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 62.0% accurate, 1.0× speedup?

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

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

Alternative 1: 84.9% 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}:\\ \;\;\;\;b \cdot \left(\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{d}{\mathsf{hypot}\left(d, c\right)}\right)\\ \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 (* (/ 1.0 (hypot d c)) (/ d (hypot d c))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if ((((a * c) + (b * d)) / ((c * c) + (d * d))) <= ((double) INFINITY)) {
		tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
	} else {
		tmp = b * ((1.0 / hypot(d, c)) * (d / hypot(d, c)));
	}
	return tmp;
}
function code(a, b, c, d)
	tmp = 0.0
	if (Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) <= Inf)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d)));
	else
		tmp = Float64(b * Float64(Float64(1.0 / hypot(d, c)) * Float64(d / hypot(d, c))));
	end
	return tmp
end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(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[(b * N[(N[(1.0 / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $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}:\\
\;\;\;\;b \cdot \left(\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{d}{\mathsf{hypot}\left(d, c\right)}\right)\\


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

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

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

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

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

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

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

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

    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 a around 0 1.2%

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

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

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

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

        \[\leadsto \frac{d}{d \cdot d + \color{blue}{c \cdot c}} \cdot b \]
      5. fma-udef3.6%

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

      \[\leadsto \color{blue}{\frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot b} \]
    5. Step-by-step derivation
      1. *-un-lft-identity3.6%

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

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

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

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

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

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

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

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

    \[\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}:\\ \;\;\;\;b \cdot \left(\frac{1}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{d}{\mathsf{hypot}\left(d, c\right)}\right)\\ \end{array} \]

Alternative 2: 84.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\ t_1 := \frac{b \cdot d}{t_0} + \frac{a}{\frac{t_0}{c}}\\ t_2 := \frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\ \mathbf{if}\;d \leq -5 \cdot 10^{+65}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq -9 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{-162}:\\ \;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{\frac{b}{\frac{c}{d}}}}\\ \mathbf{elif}\;d \leq 4.9 \cdot 10^{+61}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (fma d d (* c c)))
        (t_1 (+ (/ (* b d) t_0) (/ a (/ t_0 c))))
        (t_2 (+ (/ b d) (/ (* c (/ a d)) d))))
   (if (<= d -5e+65)
     t_2
     (if (<= d -9e-160)
       t_1
       (if (<= d 2.7e-162)
         (+ (/ a c) (/ 1.0 (/ c (/ b (/ c d)))))
         (if (<= d 4.9e+61) t_1 t_2))))))
double code(double a, double b, double c, double d) {
	double t_0 = fma(d, d, (c * c));
	double t_1 = ((b * d) / t_0) + (a / (t_0 / c));
	double t_2 = (b / d) + ((c * (a / d)) / d);
	double tmp;
	if (d <= -5e+65) {
		tmp = t_2;
	} else if (d <= -9e-160) {
		tmp = t_1;
	} else if (d <= 2.7e-162) {
		tmp = (a / c) + (1.0 / (c / (b / (c / d))));
	} else if (d <= 4.9e+61) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(a, b, c, d)
	t_0 = fma(d, d, Float64(c * c))
	t_1 = Float64(Float64(Float64(b * d) / t_0) + Float64(a / Float64(t_0 / c)))
	t_2 = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d))
	tmp = 0.0
	if (d <= -5e+65)
		tmp = t_2;
	elseif (d <= -9e-160)
		tmp = t_1;
	elseif (d <= 2.7e-162)
		tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(c / Float64(b / Float64(c / d)))));
	elseif (d <= 4.9e+61)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * d), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(a / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5e+65], t$95$2, If[LessEqual[d, -9e-160], t$95$1, If[LessEqual[d, 2.7e-162], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(c / N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.9e+61], t$95$1, t$95$2]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;d \leq -9 \cdot 10^{-160}:\\
\;\;\;\;t_1\\

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

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

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d < -4.99999999999999973e65 or 4.90000000000000025e61 < d

    1. Initial program 35.3%

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

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

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

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

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

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

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

    if -4.99999999999999973e65 < d < -9.00000000000000053e-160 or 2.69999999999999984e-162 < d < 4.90000000000000025e61

    1. Initial program 76.1%

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

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

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

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

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

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

        \[\leadsto \frac{d \cdot b}{\mathsf{fma}\left(d, d, c \cdot c\right)} + \color{blue}{\frac{a}{\frac{{d}^{2} + {c}^{2}}{c}}} \]
      6. unpow279.7%

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

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

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

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

    if -9.00000000000000053e-160 < d < 2.69999999999999984e-162

    1. Initial program 67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5 \cdot 10^{+65}:\\ \;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\ \mathbf{elif}\;d \leq -9 \cdot 10^{-160}:\\ \;\;\;\;\frac{b \cdot d}{\mathsf{fma}\left(d, d, c \cdot c\right)} + \frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{c}}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{-162}:\\ \;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{\frac{b}{\frac{c}{d}}}}\\ \mathbf{elif}\;d \leq 4.9 \cdot 10^{+61}:\\ \;\;\;\;\frac{b \cdot d}{\mathsf{fma}\left(d, d, c \cdot c\right)} + \frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\ \end{array} \]

Alternative 3: 78.9% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\ \mathbf{elif}\;c \leq 8 \cdot 10^{-138}:\\ \;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{+57}:\\ \;\;\;\;\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(a + \frac{d}{\frac{c}{b}}\right)\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= c -1.15e+91)
   (+ (/ a c) (/ d (/ c (/ b c))))
   (if (<= c 8e-138)
     (+ (/ b d) (/ (* c (/ a d)) d))
     (if (<= c 1.15e+57)
       (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
       (* (/ 1.0 (hypot c d)) (+ a (/ d (/ c b))))))))
double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -1.15e+91) {
		tmp = (a / c) + (d / (c / (b / c)));
	} else if (c <= 8e-138) {
		tmp = (b / d) + ((c * (a / d)) / d);
	} else if (c <= 1.15e+57) {
		tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
	} else {
		tmp = (1.0 / hypot(c, d)) * (a + (d / (c / b)));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (c <= -1.15e+91) {
		tmp = (a / c) + (d / (c / (b / c)));
	} else if (c <= 8e-138) {
		tmp = (b / d) + ((c * (a / d)) / d);
	} else if (c <= 1.15e+57) {
		tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
	} else {
		tmp = (1.0 / Math.hypot(c, d)) * (a + (d / (c / b)));
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if c <= -1.15e+91:
		tmp = (a / c) + (d / (c / (b / c)))
	elif c <= 8e-138:
		tmp = (b / d) + ((c * (a / d)) / d)
	elif c <= 1.15e+57:
		tmp = ((a * c) + (b * d)) / ((c * c) + (d * d))
	else:
		tmp = (1.0 / math.hypot(c, d)) * (a + (d / (c / b)))
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (c <= -1.15e+91)
		tmp = Float64(Float64(a / c) + Float64(d / Float64(c / Float64(b / c))));
	elseif (c <= 8e-138)
		tmp = Float64(Float64(b / d) + Float64(Float64(c * Float64(a / d)) / d));
	elseif (c <= 1.15e+57)
		tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)));
	else
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a + Float64(d / Float64(c / b))));
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (c <= -1.15e+91)
		tmp = (a / c) + (d / (c / (b / c)));
	elseif (c <= 8e-138)
		tmp = (b / d) + ((c * (a / d)) / d);
	elseif (c <= 1.15e+57)
		tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
	else
		tmp = (1.0 / hypot(c, d)) * (a + (d / (c / b)));
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.15e+91], N[(N[(a / c), $MachinePrecision] + N[(d / N[(c / N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8e-138], N[(N[(b / d), $MachinePrecision] + N[(N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.15e+57], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;c \leq 1.15 \cdot 10^{+57}:\\
\;\;\;\;\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(a + \frac{d}{\frac{c}{b}}\right)\\


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

    1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.14999999999999996e91 < c < 8.00000000000000054e-138

    1. Initial program 66.8%

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

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

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

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

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

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

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

    if 8.00000000000000054e-138 < c < 1.1499999999999999e57

    1. Initial program 80.4%

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

    if 1.1499999999999999e57 < c

    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-def54.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\ \mathbf{elif}\;c \leq 8 \cdot 10^{-138}:\\ \;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{+57}:\\ \;\;\;\;\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(a + \frac{d}{\frac{c}{b}}\right)\\ \end{array} \]

Alternative 4: 63.1% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;d \leq -2.1 \cdot 10^{-81}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 1.7 \cdot 10^{+87}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if d < -2.2999999999999999e121 or 1.7000000000000001e87 < d

    1. Initial program 30.5%

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

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

    if -2.2999999999999999e121 < d < -9.5000000000000003e29

    1. Initial program 58.5%

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

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

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

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

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

        \[\leadsto \frac{c \cdot a}{\color{blue}{d \cdot d}} \]
    7. Simplified51.3%

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

    if -9.5000000000000003e29 < d < -2.0999999999999999e-81 or 1.2499999999999999e-145 < d < 1.7000000000000001e87

    1. Initial program 78.9%

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

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

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

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

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

        \[\leadsto \frac{d}{d \cdot d + \color{blue}{c \cdot c}} \cdot b \]
      5. fma-udef60.6%

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

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

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

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

    if -2.0999999999999999e-81 < d < 1.2499999999999999e-145

    1. Initial program 67.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.3 \cdot 10^{+121}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -9.5 \cdot 10^{+29}:\\ \;\;\;\;\frac{a \cdot c}{d \cdot d}\\ \mathbf{elif}\;d \leq -2.1 \cdot 10^{-81}:\\ \;\;\;\;b \cdot \frac{d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 1.25 \cdot 10^{-145}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+87}:\\ \;\;\;\;b \cdot \frac{d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]

Alternative 5: 78.6% accurate, 0.7× speedup?

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

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

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

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

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


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

    1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.19999999999999991e91 < c < 1.29999999999999998e-136

    1. Initial program 66.8%

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

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

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

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

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

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

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

    if 1.29999999999999998e-136 < c < 1.00000000000000005e57

    1. Initial program 80.4%

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

    if 1.00000000000000005e57 < c

    1. Initial program 37.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.2 \cdot 10^{+91}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{\frac{c}{\frac{b}{c}}}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-136}:\\ \;\;\;\;\frac{b}{d} + \frac{c \cdot \frac{a}{d}}{d}\\ \mathbf{elif}\;c \leq 10^{+57}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{\frac{b}{\frac{c}{d}}}}\\ \end{array} \]

Alternative 6: 76.6% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.14999999999999996e91 < c < 4.5e8

    1. Initial program 68.9%

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

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

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

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

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

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

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

    if 4.5e8 < c

    1. Initial program 43.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 76.5% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.14999999999999996e91 < c < 3.1e7

    1. Initial program 68.9%

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

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

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

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

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

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

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

    if 3.1e7 < c

    1. Initial program 43.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 69.6% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d < -6.4999999999999997e142 or 3.0500000000000001e66 < d

    1. Initial program 34.6%

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

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

    if -6.4999999999999997e142 < d < 3.0500000000000001e66

    1. Initial program 71.3%

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

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

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

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

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

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

Alternative 9: 76.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.14999999999999996e91 < c < 1.5e7

    1. Initial program 68.9%

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

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

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

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

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

    if 1.5e7 < c

    1. Initial program 43.4%

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

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

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

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

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

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

Alternative 10: 75.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.14999999999999996e91 < c < 5.2e-51

    1. Initial program 69.3%

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

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

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

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

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

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

        \[\leadsto \frac{b}{d} + \color{blue}{\frac{1 \cdot a}{\frac{d}{c} \cdot d}} \]
      3. *-un-lft-identity78.5%

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

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

    if 5.2e-51 < c

    1. Initial program 47.5%

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

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

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

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

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

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

Alternative 11: 76.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.14999999999999996e91 < c < 1.75e8

    1. Initial program 68.9%

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

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

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

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

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

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

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

    if 1.75e8 < c

    1. Initial program 43.4%

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

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

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

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

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

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

Alternative 12: 62.4% accurate, 1.1× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if c < -1.14999999999999996e91 or 1.3000000000000001e-50 < c

    1. Initial program 43.2%

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

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

    if -1.14999999999999996e91 < c < 1.15e-144 or 7.1999999999999999e-110 < c < 1.3000000000000001e-50

    1. Initial program 68.4%

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

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

    if 1.15e-144 < c < 7.1999999999999999e-110

    1. Initial program 99.7%

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

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

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

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

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

        \[\leadsto \frac{a}{\frac{d \cdot d + \color{blue}{c \cdot c}}{c}} \]
      5. fma-udef99.7%

        \[\leadsto \frac{a}{\frac{\color{blue}{\mathsf{fma}\left(d, d, c \cdot c\right)}}{c}} \]
    4. Simplified99.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.15 \cdot 10^{+91}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{-144}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-110}:\\ \;\;\;\;\frac{a}{\frac{d \cdot d}{c}}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-50}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]

Alternative 13: 63.2% accurate, 2.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -5.80000000000000028e91 or 1.3000000000000001e-50 < c

    1. Initial program 43.2%

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

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

    if -5.80000000000000028e91 < c < 1.3000000000000001e-50

    1. Initial program 69.5%

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

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

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

Alternative 14: 42.3% 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 58.3%

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

    \[\leadsto \color{blue}{\frac{a}{c}} \]
  3. Final simplification36.0%

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