?

Average Error: 26.1 → 5.5
Time: 23.1s
Precision: binary64
Cost: 20616

?

\[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\\ \mathbf{if}\;c \leq -2.3 \cdot 10^{+87}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+23}:\\ \;\;\;\;t_0 \cdot \left(t_1 + \frac{c \cdot a}{\mathsf{hypot}\left(c, d\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(a + t_1\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 (/ 1.0 (hypot c d))) (t_1 (/ b (/ (hypot c d) d))))
   (if (<= c -2.3e+87)
     (+ (/ a c) (/ b (* c (/ c d))))
     (if (<= c 2.1e+23)
       (* t_0 (+ t_1 (/ (* c a) (hypot c d))))
       (* t_0 (+ a t_1))))))
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 = 1.0 / hypot(c, d);
	double t_1 = b / (hypot(c, d) / d);
	double tmp;
	if (c <= -2.3e+87) {
		tmp = (a / c) + (b / (c * (c / d)));
	} else if (c <= 2.1e+23) {
		tmp = t_0 * (t_1 + ((c * a) / hypot(c, d)));
	} else {
		tmp = t_0 * (a + t_1);
	}
	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 = 1.0 / Math.hypot(c, d);
	double t_1 = b / (Math.hypot(c, d) / d);
	double tmp;
	if (c <= -2.3e+87) {
		tmp = (a / c) + (b / (c * (c / d)));
	} else if (c <= 2.1e+23) {
		tmp = t_0 * (t_1 + ((c * a) / Math.hypot(c, d)));
	} else {
		tmp = t_0 * (a + t_1);
	}
	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 = 1.0 / math.hypot(c, d)
	t_1 = b / (math.hypot(c, d) / d)
	tmp = 0
	if c <= -2.3e+87:
		tmp = (a / c) + (b / (c * (c / d)))
	elif c <= 2.1e+23:
		tmp = t_0 * (t_1 + ((c * a) / math.hypot(c, d)))
	else:
		tmp = t_0 * (a + t_1)
	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(1.0 / hypot(c, d))
	t_1 = Float64(b / Float64(hypot(c, d) / d))
	tmp = 0.0
	if (c <= -2.3e+87)
		tmp = Float64(Float64(a / c) + Float64(b / Float64(c * Float64(c / d))));
	elseif (c <= 2.1e+23)
		tmp = Float64(t_0 * Float64(t_1 + Float64(Float64(c * a) / hypot(c, d))));
	else
		tmp = Float64(t_0 * Float64(a + t_1));
	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 = 1.0 / hypot(c, d);
	t_1 = b / (hypot(c, d) / d);
	tmp = 0.0;
	if (c <= -2.3e+87)
		tmp = (a / c) + (b / (c * (c / d)));
	elseif (c <= 2.1e+23)
		tmp = t_0 * (t_1 + ((c * a) / hypot(c, d)));
	else
		tmp = t_0 * (a + t_1);
	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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.3e+87], N[(N[(a / c), $MachinePrecision] + N[(b / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e+23], N[(t$95$0 * N[(t$95$1 + N[(N[(c * a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(a + t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\\
\mathbf{if}\;c \leq -2.3 \cdot 10^{+87}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\

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

\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(a + t_1\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.1
Target0.4
Herbie5.5
\[\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 3 regimes
  2. if c < -2.3000000000000002e87

    1. Initial program 37.9

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

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

      [Start]37.9

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

      fma-def [=>]37.9

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

      fma-def [=>]37.9

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

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

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

      [Start]17.1

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

      *-commutative [=>]17.1

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

      unpow2 [=>]17.1

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

      associate-/l* [=>]16.1

      \[ \frac{a}{c} + \color{blue}{\frac{b}{\frac{c \cdot c}{d}}} \]
    5. Applied egg-rr14.9

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

    if -2.3000000000000002e87 < c < 2.1000000000000001e23

    1. Initial program 18.6

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied egg-rr11.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. Applied egg-rr11.1

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

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

      [Start]11.1

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

      +-commutative [=>]11.1

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

      associate-/l* [=>]1.7

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

      *-commutative [<=]1.7

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

    if 2.1000000000000001e23 < c

    1. Initial program 34.2

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied egg-rr23.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)}} \]
    3. Applied egg-rr23.9

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

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

      [Start]23.9

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

      +-commutative [=>]23.9

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

      associate-/l* [=>]18.6

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

      *-commutative [<=]18.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -2.3 \cdot 10^{+87}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} + \frac{c \cdot a}{\mathsf{hypot}\left(c, d\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error10.4
Cost20560
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := t_0 \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;d \leq -2.5 \cdot 10^{+98}:\\ \;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{elif}\;d \leq -7.5 \cdot 10^{-157}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 4.1 \cdot 10^{-116}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{+130}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\ \end{array} \]
Alternative 2
Error12.4
Cost13768
\[\begin{array}{l} \mathbf{if}\;d \leq -7.2 \cdot 10^{+98}:\\ \;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{elif}\;d \leq -7.6 \cdot 10^{-157}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{-121}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 9 \cdot 10^{+131}:\\ \;\;\;\;\frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\ \end{array} \]
Alternative 3
Error12.3
Cost13508
\[\begin{array}{l} t_0 := \frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{if}\;d \leq -2.1 \cdot 10^{+98}:\\ \;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{elif}\;d \leq -9.2 \cdot 10^{-157}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.42 \cdot 10^{-120}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 5.4 \cdot 10^{+129}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\ \end{array} \]
Alternative 4
Error11.9
Cost7696
\[\begin{array}{l} t_0 := \frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{if}\;d \leq -3.2 \cdot 10^{+98}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{\frac{d}{\frac{a}{d}}}\\ \mathbf{elif}\;d \leq -1.02 \cdot 10^{-156}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{-121}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 10^{+127}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\ \end{array} \]
Alternative 5
Error11.8
Cost7696
\[\begin{array}{l} t_0 := \frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{if}\;d \leq -7 \cdot 10^{+97}:\\ \;\;\;\;\left(b + a \cdot \frac{c}{d}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -1.02 \cdot 10^{-156}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 9 \cdot 10^{-121}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 2.85 \cdot 10^{+134}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\ \end{array} \]
Alternative 6
Error16.6
Cost1628
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{\frac{d}{c}}{\frac{c}{b}}\\ t_1 := d \cdot d + c \cdot c\\ t_2 := \frac{c}{\frac{t_1}{a}}\\ \mathbf{if}\;c \leq -5.8 \cdot 10^{-46}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 8 \cdot 10^{-28}:\\ \;\;\;\;\left(b + a \cdot \frac{c}{d}\right) \cdot \frac{1}{d}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{-6}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.55 \cdot 10^{+17}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 1.9 \cdot 10^{+63}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{+94}:\\ \;\;\;\;\frac{d}{\frac{t_1}{b}}\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{+104}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error12.0
Cost1488
\[\begin{array}{l} t_0 := \frac{b \cdot d + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{if}\;d \leq -4.2 \cdot 10^{+98}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{\frac{d}{\frac{a}{d}}}\\ \mathbf{elif}\;d \leq -8.5 \cdot 10^{-157}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 5.8 \cdot 10^{-121}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 5.6 \cdot 10^{+131}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \end{array} \]
Alternative 8
Error19.7
Cost1233
\[\begin{array}{l} \mathbf{if}\;c \leq -1.02 \cdot 10^{-45}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{+26} \lor \neg \left(c \leq 1.9 \cdot 10^{+61}\right) \land c \leq 7.8 \cdot 10^{+95}:\\ \;\;\;\;\left(b + a \cdot \frac{c}{d}\right) \cdot \frac{1}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 9
Error16.1
Cost1232
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{if}\;c \leq -5.8 \cdot 10^{-46}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-48}:\\ \;\;\;\;\left(b + a \cdot \frac{c}{d}\right) \cdot \frac{1}{d}\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{-9}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;c \leq 2.35 \cdot 10^{+22}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error16.0
Cost1232
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{\frac{d}{c}}{\frac{c}{b}}\\ \mathbf{if}\;c \leq -1 \cdot 10^{-45}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{-47}:\\ \;\;\;\;\left(b + a \cdot \frac{c}{d}\right) \cdot \frac{1}{d}\\ \mathbf{elif}\;c \leq 0.0035:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;c \leq 1.95 \cdot 10^{+17}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error15.9
Cost1232
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{\frac{d}{c}}{\frac{c}{b}}\\ \mathbf{if}\;c \leq -7.5 \cdot 10^{-46}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-28}:\\ \;\;\;\;\left(b + a \cdot \frac{c}{d}\right) \cdot \frac{1}{d}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-8}:\\ \;\;\;\;\frac{c}{\frac{d \cdot d + c \cdot c}{a}}\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{+19}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Error15.7
Cost969
\[\begin{array}{l} \mathbf{if}\;c \leq -8.8 \cdot 10^{-46} \lor \neg \left(c \leq 3.8 \cdot 10^{+17}\right):\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\left(b + a \cdot \frac{c}{d}\right) \cdot \frac{1}{d}\\ \end{array} \]
Alternative 13
Error23.7
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -7.5 \cdot 10^{-46}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 1.06 \cdot 10^{+24}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 14
Error36.9
Cost192
\[\frac{a}{c} \]

Error

Reproduce?

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