?

Average Accuracy: 59.3% → 84.9%
Time: 17.3s
Precision: binary64
Cost: 14288

?

\[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
\[\begin{array}{l} t_0 := d \cdot d + c \cdot c\\ \mathbf{if}\;c \leq -1.5 \cdot 10^{+143}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -4 \cdot 10^{-159}:\\ \;\;\;\;b \cdot \frac{d}{t_0} + a \cdot \frac{c}{t_0}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-108}:\\ \;\;\;\;\left(b + \frac{c \cdot a}{d}\right) \cdot \frac{1}{d}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{+173}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot a + b \cdot d}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + \frac{b}{c} \cdot d}{\mathsf{hypot}\left(c, d\right)}\\ \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 (+ (* d d) (* c c))))
   (if (<= c -1.5e+143)
     (+ (/ a c) (* (/ b c) (/ d c)))
     (if (<= c -4e-159)
       (+ (* b (/ d t_0)) (* a (/ c t_0)))
       (if (<= c 7e-108)
         (* (+ b (/ (* c a) d)) (/ 1.0 d))
         (if (<= c 1.3e+173)
           (* (/ 1.0 (hypot c d)) (/ (+ (* c a) (* b d)) (hypot c d)))
           (/ (+ a (* (/ b c) d)) (hypot c d))))))))
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 = (d * d) + (c * c);
	double tmp;
	if (c <= -1.5e+143) {
		tmp = (a / c) + ((b / c) * (d / c));
	} else if (c <= -4e-159) {
		tmp = (b * (d / t_0)) + (a * (c / t_0));
	} else if (c <= 7e-108) {
		tmp = (b + ((c * a) / d)) * (1.0 / d);
	} else if (c <= 1.3e+173) {
		tmp = (1.0 / hypot(c, d)) * (((c * a) + (b * d)) / hypot(c, d));
	} else {
		tmp = (a + ((b / c) * d)) / hypot(c, d);
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (d * d) + (c * c);
	double tmp;
	if (c <= -1.5e+143) {
		tmp = (a / c) + ((b / c) * (d / c));
	} else if (c <= -4e-159) {
		tmp = (b * (d / t_0)) + (a * (c / t_0));
	} else if (c <= 7e-108) {
		tmp = (b + ((c * a) / d)) * (1.0 / d);
	} else if (c <= 1.3e+173) {
		tmp = (1.0 / Math.hypot(c, d)) * (((c * a) + (b * d)) / Math.hypot(c, d));
	} else {
		tmp = (a + ((b / c) * d)) / Math.hypot(c, d);
	}
	return tmp;
}
def code(a, b, c, d):
	return ((a * c) + (b * d)) / ((c * c) + (d * d))
def code(a, b, c, d):
	t_0 = (d * d) + (c * c)
	tmp = 0
	if c <= -1.5e+143:
		tmp = (a / c) + ((b / c) * (d / c))
	elif c <= -4e-159:
		tmp = (b * (d / t_0)) + (a * (c / t_0))
	elif c <= 7e-108:
		tmp = (b + ((c * a) / d)) * (1.0 / d)
	elif c <= 1.3e+173:
		tmp = (1.0 / math.hypot(c, d)) * (((c * a) + (b * d)) / math.hypot(c, d))
	else:
		tmp = (a + ((b / c) * d)) / math.hypot(c, d)
	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(d * d) + Float64(c * c))
	tmp = 0.0
	if (c <= -1.5e+143)
		tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * Float64(d / c)));
	elseif (c <= -4e-159)
		tmp = Float64(Float64(b * Float64(d / t_0)) + Float64(a * Float64(c / t_0)));
	elseif (c <= 7e-108)
		tmp = Float64(Float64(b + Float64(Float64(c * a) / d)) * Float64(1.0 / d));
	elseif (c <= 1.3e+173)
		tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(Float64(c * a) + Float64(b * d)) / hypot(c, d)));
	else
		tmp = Float64(Float64(a + Float64(Float64(b / c) * d)) / hypot(c, d));
	end
	return tmp
end
function tmp = code(a, b, c, d)
	tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
function tmp_2 = code(a, b, c, d)
	t_0 = (d * d) + (c * c);
	tmp = 0.0;
	if (c <= -1.5e+143)
		tmp = (a / c) + ((b / c) * (d / c));
	elseif (c <= -4e-159)
		tmp = (b * (d / t_0)) + (a * (c / t_0));
	elseif (c <= 7e-108)
		tmp = (b + ((c * a) / d)) * (1.0 / d);
	elseif (c <= 1.3e+173)
		tmp = (1.0 / hypot(c, d)) * (((c * a) + (b * d)) / hypot(c, d));
	else
		tmp = (a + ((b / c) * d)) / hypot(c, d);
	end
	tmp_2 = 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[(d * d), $MachinePrecision] + N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.5e+143], N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -4e-159], N[(N[(b * N[(d / t$95$0), $MachinePrecision]), $MachinePrecision] + N[(a * N[(c / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 7e-108], N[(N[(b + N[(N[(c * a), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[(1.0 / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.3e+173], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(c * a), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(N[(b / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\begin{array}{l}
t_0 := d \cdot d + c \cdot c\\
\mathbf{if}\;c \leq -1.5 \cdot 10^{+143}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\

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

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

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original59.3%
Target99.3%
Herbie84.9%
\[\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 c < -1.5e143

    1. Initial program 31.2%

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

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

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

      [Start]76.3

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

      *-commutative [<=]76.3

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

      unpow2 [=>]76.3

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

      times-frac [=>]88.4

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

    if -1.5e143 < c < -3.99999999999999995e-159

    1. Initial program 73.1%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied egg-rr81.0%

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

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

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

      [Start]73.1

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

      associate-/l* [=>]71.0

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

      associate-/r/ [=>]75.0

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

      unpow2 [=>]75.0

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

      unpow2 [=>]75.0

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

      associate-/l* [=>]75.3

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

      associate-/r/ [=>]80.3

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

      unpow2 [=>]80.3

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

      unpow2 [=>]80.3

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

    if -3.99999999999999995e-159 < c < 6.9999999999999997e-108

    1. Initial program 65.0%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied egg-rr79.8%

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

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

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

    if 6.9999999999999997e-108 < c < 1.2999999999999999e173

    1. Initial program 70.1%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied egg-rr80.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)}} \]
    3. Taylor expanded in a around 0 80.1%

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

    if 1.2999999999999999e173 < c

    1. Initial program 28.9%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied egg-rr51.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1.5 \cdot 10^{+143}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -4 \cdot 10^{-159}:\\ \;\;\;\;b \cdot \frac{d}{d \cdot d + c \cdot c} + a \cdot \frac{c}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-108}:\\ \;\;\;\;\left(b + \frac{c \cdot a}{d}\right) \cdot \frac{1}{d}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{+173}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot a + b \cdot d}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + \frac{b}{c} \cdot d}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy83.3%
Cost13904
\[\begin{array}{l} t_0 := d \cdot d + c \cdot c\\ t_1 := b \cdot \frac{d}{t_0} + a \cdot \frac{c}{t_0}\\ \mathbf{if}\;c \leq -1.3 \cdot 10^{+150}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.2 \cdot 10^{-108}:\\ \;\;\;\;\left(b + \frac{c \cdot a}{d}\right) \cdot \frac{1}{d}\\ \mathbf{elif}\;c \leq 1.76 \cdot 10^{+64}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
Alternative 2
Accuracy84.9%
Cost7568
\[\begin{array}{l} t_0 := d \cdot d + c \cdot c\\ t_1 := b \cdot \frac{d}{t_0} + a \cdot \frac{c}{t_0}\\ \mathbf{if}\;c \leq -7.8 \cdot 10^{+146}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;c \leq -4 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{-108}:\\ \;\;\;\;\left(b + \frac{c \cdot a}{d}\right) \cdot \frac{1}{d}\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{+158}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{a + \frac{b}{c} \cdot d}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]
Alternative 3
Accuracy84.7%
Cost2000
\[\begin{array}{l} t_0 := d \cdot d + c \cdot c\\ t_1 := b \cdot \frac{d}{t_0} + a \cdot \frac{c}{t_0}\\ t_2 := \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -2.2 \cdot 10^{+147}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -8.4 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{-108}:\\ \;\;\;\;\left(b + \frac{c \cdot a}{d}\right) \cdot \frac{1}{d}\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{+158}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Accuracy77.2%
Cost1620
\[\begin{array}{l} t_0 := \frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{if}\;d \leq -3.2 \cdot 10^{+52}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -95000:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\ \mathbf{elif}\;d \leq -1.1 \cdot 10^{-11}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{-50}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b \cdot d}{c}\right)\\ \mathbf{elif}\;d \leq 5.1 \cdot 10^{+46}:\\ \;\;\;\;\frac{c \cdot a + b \cdot d}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\left(b + \frac{c \cdot a}{d}\right) \cdot \frac{1}{d}\\ \end{array} \]
Alternative 5
Accuracy76.3%
Cost1496
\[\begin{array}{l} t_0 := \frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{if}\;d \leq -1.9 \cdot 10^{+51}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -1050000:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\ \mathbf{elif}\;d \leq -1.5 \cdot 10^{-12}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{-50}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b \cdot d}{c}\right)\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-13}:\\ \;\;\;\;\frac{b \cdot d}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+40}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Accuracy74.9%
Cost1496
\[\begin{array}{l} t_0 := \frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{if}\;d \leq -1.8 \cdot 10^{+53}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -800:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\ \mathbf{elif}\;d \leq -3.8 \cdot 10^{-12}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 6 \cdot 10^{-50}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b \cdot d}{c}\right)\\ \mathbf{elif}\;d \leq 4.2 \cdot 10^{-11}:\\ \;\;\;\;\frac{b \cdot d}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;d \leq 9.5 \cdot 10^{+38}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{else}:\\ \;\;\;\;\left(b + \frac{c \cdot a}{d}\right) \cdot \frac{1}{d}\\ \end{array} \]
Alternative 7
Accuracy70.8%
Cost1233
\[\begin{array}{l} \mathbf{if}\;d \leq -2 \cdot 10^{+74}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -92:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{elif}\;d \leq -1.4 \cdot 10^{-24} \lor \neg \left(d \leq 1.65 \cdot 10^{+39}\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b \cdot d}{c}\right)\\ \end{array} \]
Alternative 8
Accuracy76.2%
Cost1233
\[\begin{array}{l} t_0 := \frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{if}\;d \leq -1.5 \cdot 10^{+53}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -95:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\ \mathbf{elif}\;d \leq -8.8 \cdot 10^{-13} \lor \neg \left(d \leq 10^{+39}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b \cdot d}{c}\right)\\ \end{array} \]
Alternative 9
Accuracy70.7%
Cost1232
\[\begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{+72}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -9000000:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c \cdot \frac{c}{b}}\\ \mathbf{elif}\;d \leq -1.15 \cdot 10^{-24}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{+39}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b \cdot d}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
Alternative 10
Accuracy63.1%
Cost972
\[\begin{array}{l} \mathbf{if}\;d \leq -1.75 \cdot 10^{+24}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq -5.6 \cdot 10^{-162}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq -9.5 \cdot 10^{-208}:\\ \;\;\;\;\frac{b \cdot \frac{-d}{c}}{-c}\\ \mathbf{elif}\;d \leq 1.35 \cdot 10^{+39}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
Alternative 11
Accuracy71.3%
Cost968
\[\begin{array}{l} \mathbf{if}\;d \leq -6.8 \cdot 10^{+73}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 5.1 \cdot 10^{+39}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b \cdot d}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
Alternative 12
Accuracy42.7%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -1.76 \cdot 10^{-124}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{-190}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 13
Accuracy64.5%
Cost456
\[\begin{array}{l} \mathbf{if}\;d \leq -2.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 1.3 \cdot 10^{+40}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
Alternative 14
Accuracy42.2%
Cost192
\[\frac{a}{c} \]

Error

Reproduce?

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