Average Error: 26.4 → 10.8
Time: 19.3s
Precision: binary64
Cost: 27332
\[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
\[\begin{array}{l} t_0 := \frac{\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;\frac{0.5 \cdot \mathsf{fma}\left({\left(\frac{c}{d}\right)}^{3}, a, b \cdot \left(\frac{c}{d} \cdot \frac{c}{d}\right)\right) - \mathsf{fma}\left(\frac{c}{d}, a, b\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -5.174344703148754 \cdot 10^{+29}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -90.43388479818566:\\ \;\;\;\;\frac{c}{c \cdot \frac{c}{a} + d \cdot \frac{d}{a}}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-121}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 10^{-134}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 1.6166223276898808 \cdot 10^{+114}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (/ (/ (fma a c (* d b)) (hypot c d)) (hypot c d)))
        (t_1 (+ (/ a c) (/ (* b (/ d c)) c))))
   (if (<= d -3.185189906959867e+122)
     (/
      (-
       (* 0.5 (fma (pow (/ c d) 3.0) a (* b (* (/ c d) (/ c d)))))
       (fma (/ c d) a b))
      (hypot c d))
     (if (<= d -7.577584446069664e+94)
       t_1
       (if (<= d -5.174344703148754e+29)
         t_0
         (if (<= d -90.43388479818566)
           (/ c (+ (* c (/ c a)) (* d (/ d a))))
           (if (<= d -1e-121)
             t_0
             (if (<= d 1e-134)
               t_1
               (if (<= d 1.6166223276898808e+114)
                 t_0
                 (+ (/ b d) (/ (/ a d) (/ d c))))))))))))
double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
double code(double a, double b, double c, double d) {
	double t_0 = (fma(a, c, (d * b)) / hypot(c, d)) / hypot(c, d);
	double t_1 = (a / c) + ((b * (d / c)) / c);
	double tmp;
	if (d <= -3.185189906959867e+122) {
		tmp = ((0.5 * fma(pow((c / d), 3.0), a, (b * ((c / d) * (c / d))))) - fma((c / d), a, b)) / hypot(c, d);
	} else if (d <= -7.577584446069664e+94) {
		tmp = t_1;
	} else if (d <= -5.174344703148754e+29) {
		tmp = t_0;
	} else if (d <= -90.43388479818566) {
		tmp = c / ((c * (c / a)) + (d * (d / a)));
	} else if (d <= -1e-121) {
		tmp = t_0;
	} else if (d <= 1e-134) {
		tmp = t_1;
	} else if (d <= 1.6166223276898808e+114) {
		tmp = t_0;
	} else {
		tmp = (b / d) + ((a / d) / (d / c));
	}
	return tmp;
}
function code(a, b, c, d)
	return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function code(a, b, c, d)
	t_0 = Float64(Float64(fma(a, c, Float64(d * b)) / hypot(c, d)) / hypot(c, d))
	t_1 = Float64(Float64(a / c) + Float64(Float64(b * Float64(d / c)) / c))
	tmp = 0.0
	if (d <= -3.185189906959867e+122)
		tmp = Float64(Float64(Float64(0.5 * fma((Float64(c / d) ^ 3.0), a, Float64(b * Float64(Float64(c / d) * Float64(c / d))))) - fma(Float64(c / d), a, b)) / hypot(c, d));
	elseif (d <= -7.577584446069664e+94)
		tmp = t_1;
	elseif (d <= -5.174344703148754e+29)
		tmp = t_0;
	elseif (d <= -90.43388479818566)
		tmp = Float64(c / Float64(Float64(c * Float64(c / a)) + Float64(d * Float64(d / a))));
	elseif (d <= -1e-121)
		tmp = t_0;
	elseif (d <= 1e-134)
		tmp = t_1;
	elseif (d <= 1.6166223276898808e+114)
		tmp = t_0;
	else
		tmp = Float64(Float64(b / d) + Float64(Float64(a / d) / Float64(d / c)));
	end
	return tmp
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]
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.185189906959867e+122], N[(N[(N[(0.5 * N[(N[Power[N[(c / d), $MachinePrecision], 3.0], $MachinePrecision] * a + N[(b * N[(N[(c / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(c / d), $MachinePrecision] * a + b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.577584446069664e+94], t$95$1, If[LessEqual[d, -5.174344703148754e+29], t$95$0, If[LessEqual[d, -90.43388479818566], N[(c / N[(N[(c * N[(c / a), $MachinePrecision]), $MachinePrecision] + N[(d * N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1e-121], t$95$0, If[LessEqual[d, 1e-134], t$95$1, If[LessEqual[d, 1.6166223276898808e+114], t$95$0, N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\begin{array}{l}
t_0 := \frac{\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\
\mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\
\;\;\;\;\frac{0.5 \cdot \mathsf{fma}\left({\left(\frac{c}{d}\right)}^{3}, a, b \cdot \left(\frac{c}{d} \cdot \frac{c}{d}\right)\right) - \mathsf{fma}\left(\frac{c}{d}, a, b\right)}{\mathsf{hypot}\left(c, d\right)}\\

\mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq -5.174344703148754 \cdot 10^{+29}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -90.43388479818566:\\
\;\;\;\;\frac{c}{c \cdot \frac{c}{a} + d \cdot \frac{d}{a}}\\

\mathbf{elif}\;d \leq -1 \cdot 10^{-121}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 10^{-134}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;d \leq 1.6166223276898808 \cdot 10^{+114}:\\
\;\;\;\;t_0\\

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


\end{array}

Error

Target

Original26.4
Target0.5
Herbie10.8
\[\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} \]

Derivation

  1. Split input into 5 regimes
  2. if d < -3.1851899069598672e122

    1. Initial program 42.9

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Simplified42.9

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      Proof
      (/.f64 (fma.f64 a c (*.f64 b d)) (fma.f64 c c (*.f64 d d))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a c) (*.f64 b d))) (fma.f64 c c (*.f64 d d))): 1 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 c c) (*.f64 d d)))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr28.5

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

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

      \[\leadsto \frac{\color{blue}{0.5 \cdot \frac{{c}^{3} \cdot a}{{d}^{3}} + \left(0.5 \cdot \frac{{c}^{2} \cdot b}{{d}^{2}} + \left(-1 \cdot b + -1 \cdot \frac{c \cdot a}{d}\right)\right)}}{\mathsf{hypot}\left(c, d\right)} \]
    6. Simplified10.3

      \[\leadsto \frac{\color{blue}{0.5 \cdot \mathsf{fma}\left({\left(\frac{c}{d}\right)}^{3}, a, b \cdot \left(\frac{c}{d} \cdot \frac{c}{d}\right)\right) - \mathsf{fma}\left(\frac{c}{d}, a, b\right)}}{\mathsf{hypot}\left(c, d\right)} \]
      Proof
      (-.f64 (*.f64 1/2 (fma.f64 (pow.f64 (/.f64 c d) 3) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (Rewrite<= cube-unmult_binary64 (*.f64 (/.f64 c d) (*.f64 (/.f64 c d) (/.f64 c d)))) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 1 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (*.f64 (/.f64 c d) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 c c) (*.f64 d d)))) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 20 points increase in error, 1 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (*.f64 (/.f64 c d) (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 c 2)) (*.f64 d d))) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (*.f64 (/.f64 c d) (/.f64 (pow.f64 c 2) (Rewrite<= unpow2_binary64 (pow.f64 d 2)))) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 c (pow.f64 c 2)) (*.f64 d (pow.f64 d 2)))) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 15 points increase in error, 1 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (/.f64 (*.f64 c (Rewrite=> unpow2_binary64 (*.f64 c c))) (*.f64 d (pow.f64 d 2))) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (/.f64 (Rewrite<= cube-mult_binary64 (pow.f64 c 3)) (*.f64 d (pow.f64 d 2))) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 1 points increase in error, 1 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (/.f64 (pow.f64 c 3) (*.f64 d (Rewrite=> unpow2_binary64 (*.f64 d d)))) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (/.f64 (pow.f64 c 3) (Rewrite<= cube-mult_binary64 (pow.f64 d 3))) a (*.f64 b (*.f64 (/.f64 c d) (/.f64 c d))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (/.f64 (pow.f64 c 3) (pow.f64 d 3)) a (*.f64 b (Rewrite<= times-frac_binary64 (/.f64 (*.f64 c c) (*.f64 d d)))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 2 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (/.f64 (pow.f64 c 3) (pow.f64 d 3)) a (*.f64 b (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 c 2)) (*.f64 d d))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (/.f64 (pow.f64 c 3) (pow.f64 d 3)) a (*.f64 b (/.f64 (pow.f64 c 2) (Rewrite<= unpow2_binary64 (pow.f64 d 2)))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (/.f64 (pow.f64 c 3) (pow.f64 d 3)) a (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 (pow.f64 c 2) (pow.f64 d 2)) b)))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (fma.f64 (/.f64 (pow.f64 c 3) (pow.f64 d 3)) a (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2))))) (fma.f64 (/.f64 c d) a b)): 4 points increase in error, 1 points decrease in error
      (-.f64 (*.f64 1/2 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (/.f64 (pow.f64 c 3) (pow.f64 d 3)) a) (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 1/2 (+.f64 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 (pow.f64 c 3) a) (pow.f64 d 3))) (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2)))) (fma.f64 (/.f64 c d) a b)): 3 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= distribute-lft-out_binary64 (+.f64 (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 3) a) (pow.f64 d 3))) (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2))))) (fma.f64 (/.f64 c d) a b)): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 3) a) (pow.f64 d 3))) (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2)))) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (/.f64 c d) a) b))): 0 points increase in error, 0 points decrease in error
      (-.f64 (+.f64 (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 3) a) (pow.f64 d 3))) (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2)))) (+.f64 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 c a) d)) b)): 4 points increase in error, 4 points decrease in error
      (-.f64 (+.f64 (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 3) a) (pow.f64 d 3))) (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2)))) (Rewrite<= +-commutative_binary64 (+.f64 b (/.f64 (*.f64 c a) d)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (+.f64 (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 3) a) (pow.f64 d 3))) (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2)))) (neg.f64 (+.f64 b (/.f64 (*.f64 c a) d))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (+.f64 (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 3) a) (pow.f64 d 3))) (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2)))) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (+.f64 b (/.f64 (*.f64 c a) d))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (+.f64 (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 3) a) (pow.f64 d 3))) (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2)))) (Rewrite<= distribute-lft-out_binary64 (+.f64 (*.f64 -1 b) (*.f64 -1 (/.f64 (*.f64 c a) d))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-+r+_binary64 (+.f64 (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 3) a) (pow.f64 d 3))) (+.f64 (*.f64 1/2 (/.f64 (*.f64 (pow.f64 c 2) b) (pow.f64 d 2))) (+.f64 (*.f64 -1 b) (*.f64 -1 (/.f64 (*.f64 c a) d)))))): 0 points increase in error, 0 points decrease in error

    if -3.1851899069598672e122 < d < -7.5775844460696643e94 or -9.9999999999999998e-122 < d < 1.00000000000000004e-134

    1. Initial program 22.3

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Simplified22.3

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      Proof
      (/.f64 (fma.f64 a c (*.f64 b d)) (fma.f64 c c (*.f64 d d))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a c) (*.f64 b d))) (fma.f64 c c (*.f64 d d))): 1 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 c c) (*.f64 d d)))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in c around inf 17.2

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{d}{c \cdot c} \cdot \left(b - \frac{d \cdot a}{c}\right)} \]
      Proof
      (+.f64 (/.f64 a c) (*.f64 (/.f64 d (*.f64 c c)) (-.f64 b (/.f64 (*.f64 d a) c)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (*.f64 (/.f64 d (Rewrite<= unpow2_binary64 (pow.f64 c 2))) (-.f64 b (/.f64 (*.f64 d a) c)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (*.f64 (/.f64 d (pow.f64 c 2)) (-.f64 b (/.f64 (Rewrite=> *-commutative_binary64 (*.f64 a d)) c)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 b (/.f64 d (pow.f64 c 2))) (*.f64 (/.f64 (*.f64 a d) c) (/.f64 d (pow.f64 c 2)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 d (pow.f64 c 2)) b)) (*.f64 (/.f64 (*.f64 a d) c) (/.f64 d (pow.f64 c 2))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (-.f64 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 d b) (pow.f64 c 2))) (*.f64 (/.f64 (*.f64 a d) c) (/.f64 d (pow.f64 c 2))))): 15 points increase in error, 7 points decrease in error
      (+.f64 (/.f64 a c) (-.f64 (/.f64 (*.f64 d b) (pow.f64 c 2)) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 (*.f64 a d) d) (*.f64 c (pow.f64 c 2)))))): 17 points increase in error, 2 points decrease in error
      (+.f64 (/.f64 a c) (-.f64 (/.f64 (*.f64 d b) (pow.f64 c 2)) (/.f64 (Rewrite<= associate-*r*_binary64 (*.f64 a (*.f64 d d))) (*.f64 c (pow.f64 c 2))))): 11 points increase in error, 2 points decrease in error
      (+.f64 (/.f64 a c) (-.f64 (/.f64 (*.f64 d b) (pow.f64 c 2)) (/.f64 (*.f64 a (Rewrite<= unpow2_binary64 (pow.f64 d 2))) (*.f64 c (pow.f64 c 2))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (-.f64 (/.f64 (*.f64 d b) (pow.f64 c 2)) (/.f64 (*.f64 a (pow.f64 d 2)) (*.f64 c (Rewrite=> unpow2_binary64 (*.f64 c c)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (-.f64 (/.f64 (*.f64 d b) (pow.f64 c 2)) (/.f64 (*.f64 a (pow.f64 d 2)) (Rewrite<= cube-mult_binary64 (pow.f64 c 3))))): 1 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 (*.f64 d b) (pow.f64 c 2)) (neg.f64 (/.f64 (*.f64 a (pow.f64 d 2)) (pow.f64 c 3)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (+.f64 (/.f64 (*.f64 d b) (pow.f64 c 2)) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 (*.f64 a (pow.f64 d 2)) (pow.f64 c 3)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 a c) (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 -1 (/.f64 (*.f64 a (pow.f64 d 2)) (pow.f64 c 3))) (/.f64 (*.f64 d b) (pow.f64 c 2))))): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr9.6

      \[\leadsto \frac{a}{c} + \color{blue}{\frac{\frac{d}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)}{c}} \]
    6. Taylor expanded in d around 0 9.8

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

      \[\leadsto \frac{a}{c} + \frac{\color{blue}{b \cdot \frac{d}{c}}}{c} \]
      Proof
      (*.f64 b (/.f64 d c)): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 b d) c)): 42 points increase in error, 36 points decrease in error
      (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 d b)) c): 0 points increase in error, 0 points decrease in error

    if -7.5775844460696643e94 < d < -5.1743447031487538e29 or -90.433884798185659 < d < -9.9999999999999998e-122 or 1.00000000000000004e-134 < d < 1.61662232768988079e114

    1. Initial program 16.7

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Simplified16.7

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      Proof
      (/.f64 (fma.f64 a c (*.f64 b d)) (fma.f64 c c (*.f64 d d))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a c) (*.f64 b d))) (fma.f64 c c (*.f64 d d))): 1 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 c c) (*.f64 d d)))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr11.4

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

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

    if -5.1743447031487538e29 < d < -90.433884798185659

    1. Initial program 11.0

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Simplified11.0

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      Proof
      (/.f64 (fma.f64 a c (*.f64 b d)) (fma.f64 c c (*.f64 d d))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a c) (*.f64 b d))) (fma.f64 c c (*.f64 d d))): 1 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 c c) (*.f64 d d)))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr6.1

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

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

      \[\leadsto \color{blue}{\frac{c}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{a}}} \]
      Proof
      (/.f64 c (/.f64 (fma.f64 d d (*.f64 c c)) a)): 0 points increase in error, 0 points decrease in error
      (/.f64 c (/.f64 (fma.f64 d d (Rewrite<= unpow2_binary64 (pow.f64 c 2))) a)): 0 points increase in error, 0 points decrease in error
      (/.f64 c (/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 d d) (pow.f64 c 2))) a)): 0 points increase in error, 0 points decrease in error
      (/.f64 c (/.f64 (+.f64 (Rewrite<= unpow2_binary64 (pow.f64 d 2)) (pow.f64 c 2)) a)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 c a) (+.f64 (pow.f64 d 2) (pow.f64 c 2)))): 63 points increase in error, 28 points decrease in error
    6. Taylor expanded in d around 0 38.5

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

      \[\leadsto \frac{c}{\color{blue}{c \cdot \frac{c}{a} + d \cdot \frac{d}{a}}} \]
      Proof
      (+.f64 (*.f64 c (/.f64 c a)) (*.f64 d (/.f64 d a))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 c a) c)) (*.f64 d (/.f64 d a))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= associate-/r/_binary64 (/.f64 c (/.f64 a c))) (*.f64 d (/.f64 d a))): 12 points increase in error, 18 points decrease in error
      (+.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 c c) a)) (*.f64 d (/.f64 d a))): 34 points increase in error, 10 points decrease in error
      (+.f64 (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 c 2)) a) (*.f64 d (/.f64 d a))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (pow.f64 c 2) a) (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 d a) d))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (pow.f64 c 2) a) (Rewrite<= associate-/r/_binary64 (/.f64 d (/.f64 a d)))): 14 points increase in error, 9 points decrease in error
      (+.f64 (/.f64 (pow.f64 c 2) a) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 d d) a))): 24 points increase in error, 9 points decrease in error
      (+.f64 (/.f64 (pow.f64 c 2) a) (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 d 2)) a)): 0 points increase in error, 0 points decrease in error

    if 1.61662232768988079e114 < d

    1. Initial program 41.1

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Simplified41.1

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      Proof
      (/.f64 (fma.f64 a c (*.f64 b d)) (fma.f64 c c (*.f64 d d))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 a c) (*.f64 b d))) (fma.f64 c c (*.f64 d d))): 1 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 c c) (*.f64 d d)))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in c around 0 15.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{c}{d}, \frac{a}{d}, \frac{b}{d}\right)} \]
      Proof
      (fma.f64 (/.f64 c d) (/.f64 a d) (/.f64 b d)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (/.f64 c d) (/.f64 a d)) (/.f64 b d))): 0 points increase in error, 4 points decrease in error
      (+.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 c a) (*.f64 d d))) (/.f64 b d)): 40 points increase in error, 11 points decrease in error
      (+.f64 (/.f64 (*.f64 c a) (Rewrite<= unpow2_binary64 (pow.f64 d 2))) (/.f64 b d)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 b d) (/.f64 (*.f64 c a) (pow.f64 d 2)))): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr8.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;\frac{0.5 \cdot \mathsf{fma}\left({\left(\frac{c}{d}\right)}^{3}, a, b \cdot \left(\frac{c}{d} \cdot \frac{c}{d}\right)\right) - \mathsf{fma}\left(\frac{c}{d}, a, b\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq -5.174344703148754 \cdot 10^{+29}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -90.43388479818566:\\ \;\;\;\;\frac{c}{c \cdot \frac{c}{a} + d \cdot \frac{d}{a}}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-121}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq 10^{-134}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 1.6166223276898808 \cdot 10^{+114}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \end{array} \]

Alternatives

Alternative 1
Error9.4
Cost20432
\[\begin{array}{l} t_0 := \frac{\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;d \leq -3.184186209212187 \cdot 10^{+106}:\\ \;\;\;\;\frac{-\mathsf{fma}\left(\frac{c}{d}, a, b\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-121}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 10^{-134}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 1.6166223276898808 \cdot 10^{+114}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \end{array} \]
Alternative 2
Error12.2
Cost14164
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -1.11247770032971 \cdot 10^{-67}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.6166223276898808 \cdot 10^{+114}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \end{array} \]
Alternative 3
Error16.2
Cost1760
\[\begin{array}{l} t_0 := \frac{1}{c} \cdot \left(a + \frac{d \cdot b}{c}\right)\\ t_1 := \frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -5.174344703148754 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -0.22406358666434653:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -3.445044566550207 \cdot 10^{-38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 1.3745397382678178 \cdot 10^{-63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.1331976565155514 \cdot 10^{-6}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;d \leq 5.7761498226557776 \cdot 10^{+26}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error16.1
Cost1760
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ t_1 := \frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -5.174344703148754 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -0.22406358666434653:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -3.445044566550207 \cdot 10^{-38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 1.3745397382678178 \cdot 10^{-63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.1331976565155514 \cdot 10^{-6}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;d \leq 5.7761498226557776 \cdot 10^{+26}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error16.1
Cost1760
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ t_1 := \frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ t_2 := \frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -5.174344703148754 \cdot 10^{+29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq -0.22406358666434653:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -3.445044566550207 \cdot 10^{-38}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq 1.3745397382678178 \cdot 10^{-63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.1331976565155514 \cdot 10^{-6}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;d \leq 5.7761498226557776 \cdot 10^{+26}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error16.1
Cost1760
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ t_1 := \frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -5.174344703148754 \cdot 10^{+29}:\\ \;\;\;\;\frac{b}{d} - \frac{\frac{c}{d} \cdot a}{-d}\\ \mathbf{elif}\;d \leq -0.22406358666434653:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -3.445044566550207 \cdot 10^{-38}:\\ \;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \mathbf{elif}\;d \leq 1.3745397382678178 \cdot 10^{-63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.1331976565155514 \cdot 10^{-6}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;d \leq 5.7761498226557776 \cdot 10^{+26}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error16.5
Cost1760
\[\begin{array}{l} t_0 := \frac{c}{c \cdot \frac{c}{a} + d \cdot \frac{d}{a}}\\ t_1 := \frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \mathbf{if}\;c \leq -3.024851164729794 \cdot 10^{+118}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -4.5820428189916415 \cdot 10^{+57}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -4.0336545901129105 \cdot 10^{+32}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d \cdot b}{c}\right)\\ \mathbf{elif}\;c \leq -189435.4630368468:\\ \;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \mathbf{elif}\;c \leq -8.370943940408767 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.821178075742817 \cdot 10^{-63}:\\ \;\;\;\;\frac{b}{d} - \frac{\frac{c}{d} \cdot a}{-d}\\ \mathbf{elif}\;c \leq 1.3331030262292513 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.1551020739359037 \cdot 10^{+80}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error12.2
Cost1620
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ t_1 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -1.11247770032971 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.6166223276898808 \cdot 10^{+114}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \end{array} \]
Alternative 9
Error19.9
Cost1496
\[\begin{array}{l} t_0 := \frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -5.174344703148754 \cdot 10^{+29}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -0.22406358666434653:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -3.445044566550207 \cdot 10^{-38}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.3745397382678178 \cdot 10^{-63}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error20.1
Cost1496
\[\begin{array}{l} t_0 := \frac{b}{d} + \frac{\frac{a}{d}}{\frac{d}{c}}\\ \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -7.577584446069664 \cdot 10^{+94}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -5.174344703148754 \cdot 10^{+29}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -0.22406358666434653:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -1.11247770032971 \cdot 10^{-67}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\ \mathbf{elif}\;d \leq 1.3745397382678178 \cdot 10^{-63}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error24.2
Cost720
\[\begin{array}{l} \mathbf{if}\;d \leq -3.185189906959867 \cdot 10^{+122}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -0.22406358666434653:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -3.445044566550207 \cdot 10^{-38}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 1.3745397382678178 \cdot 10^{-63}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
Alternative 12
Error37.6
Cost192
\[\frac{b}{d} \]

Error

Reproduce

herbie shell --seed 2022295 
(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))))