?

Average Error: 40.48% → 6.36%
Time: 18.0s
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 -1 \cdot 10^{+34}:\\ \;\;\;\;t_0 \cdot \left(t_1 - a\right)\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+96}:\\ \;\;\;\;t_0 \cdot \left(t_1 + \frac{c \cdot a}{\mathsf{hypot}\left(c, d\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(t_1 + a\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 -1e+34)
     (* t_0 (- t_1 a))
     (if (<= c 6e+96)
       (* t_0 (+ t_1 (/ (* c a) (hypot c d))))
       (* t_0 (+ t_1 a))))))
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 <= -1e+34) {
		tmp = t_0 * (t_1 - a);
	} else if (c <= 6e+96) {
		tmp = t_0 * (t_1 + ((c * a) / hypot(c, d)));
	} else {
		tmp = t_0 * (t_1 + a);
	}
	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 <= -1e+34) {
		tmp = t_0 * (t_1 - a);
	} else if (c <= 6e+96) {
		tmp = t_0 * (t_1 + ((c * a) / Math.hypot(c, d)));
	} else {
		tmp = t_0 * (t_1 + a);
	}
	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 <= -1e+34:
		tmp = t_0 * (t_1 - a)
	elif c <= 6e+96:
		tmp = t_0 * (t_1 + ((c * a) / math.hypot(c, d)))
	else:
		tmp = t_0 * (t_1 + a)
	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 <= -1e+34)
		tmp = Float64(t_0 * Float64(t_1 - a));
	elseif (c <= 6e+96)
		tmp = Float64(t_0 * Float64(t_1 + Float64(Float64(c * a) / hypot(c, d))));
	else
		tmp = Float64(t_0 * Float64(t_1 + a));
	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 <= -1e+34)
		tmp = t_0 * (t_1 - a);
	elseif (c <= 6e+96)
		tmp = t_0 * (t_1 + ((c * a) / hypot(c, d)));
	else
		tmp = t_0 * (t_1 + a);
	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, -1e+34], N[(t$95$0 * N[(t$95$1 - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6e+96], 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[(t$95$1 + a), $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 -1 \cdot 10^{+34}:\\
\;\;\;\;t_0 \cdot \left(t_1 - a\right)\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.48%
Target0.63%
Herbie6.36%
\[\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 < -9.99999999999999946e33

    1. Initial program 53.52

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

      \[\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-rr37

      \[\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. Simplified28.19

      \[\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]37

      \[ \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 [=>]37

      \[ \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* [=>]28.19

      \[ \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 [<=]28.19

      \[ \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 11.96

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

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

      [Start]11.96

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

      mul-1-neg [=>]11.96

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

    if -9.99999999999999946e33 < c < 6.0000000000000001e96

    1. Initial program 28.48

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied egg-rr16.99

      \[\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-rr16.99

      \[\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. Simplified3.14

      \[\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]16.99

      \[ \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 [=>]16.99

      \[ \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* [=>]3.14

      \[ \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 [<=]3.14

      \[ \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 6.0000000000000001e96 < c

    1. Initial program 62.4

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied egg-rr43.02

      \[\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-rr43.02

      \[\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. Simplified35.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]43.02

      \[ \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 [=>]43.02

      \[ \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* [=>]35.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 [<=]35.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 9.43

      \[\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 simplification6.36

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -1 \cdot 10^{+34}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} - a\right)\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+96}:\\ \;\;\;\;\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(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} + a\right)\\ \end{array} \]

Alternatives

Alternative 1
Error12.6%
Cost20932
\[\begin{array}{l} \mathbf{if}\;\frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+268}:\\ \;\;\;\;\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{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} - a\right)\\ \end{array} \]
Alternative 2
Error15.39%
Cost20168
\[\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 -6 \cdot 10^{-41}:\\ \;\;\;\;t_0 \cdot \left(t_1 - a\right)\\ \mathbf{elif}\;c \leq -9.8 \cdot 10^{-113}:\\ \;\;\;\;\mathsf{fma}\left(a, c, d \cdot b\right) \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\ \mathbf{elif}\;c \leq 5.3 \cdot 10^{-163}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(t_1 + a\right)\\ \end{array} \]
Alternative 3
Error17%
Cost14028
\[\begin{array}{l} \mathbf{if}\;c \leq -2.8 \cdot 10^{+108}:\\ \;\;\;\;\frac{\left(-a\right) - \frac{d}{\frac{c}{b}}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -7.5 \cdot 10^{-113}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-162}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{d}} + a\right)\\ \end{array} \]
Alternative 4
Error15.37%
Cost14028
\[\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.9 \cdot 10^{-40}:\\ \;\;\;\;t_0 \cdot \left(t_1 - a\right)\\ \mathbf{elif}\;c \leq -1.4 \cdot 10^{-112}:\\ \;\;\;\;\frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\ \mathbf{elif}\;c \leq 2.15 \cdot 10^{-163}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(t_1 + a\right)\\ \end{array} \]
Alternative 5
Error19.55%
Cost7828
\[\begin{array}{l} t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -6 \cdot 10^{+103}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-133}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-40}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 2.1 \cdot 10^{+27}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{+67}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\ \end{array} \]
Alternative 6
Error19.35%
Cost7828
\[\begin{array}{l} t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -1.8 \cdot 10^{+103}:\\ \;\;\;\;\frac{\left(-b\right) - a \cdot \frac{c}{d}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq -4.1 \cdot 10^{-134}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.6 \cdot 10^{-40}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 5.2 \cdot 10^{+27}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 7 \cdot 10^{+67}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\ \end{array} \]
Alternative 7
Error25.17%
Cost1628
\[\begin{array}{l} t_0 := \frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\ t_1 := c \cdot c + d \cdot d\\ t_2 := \frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\ \mathbf{if}\;c \leq -1.65 \cdot 10^{+19}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -600:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -1.05 \cdot 10^{-51}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq -1.15 \cdot 10^{-66}:\\ \;\;\;\;\frac{d \cdot b}{t_1}\\ \mathbf{elif}\;c \leq -2.3 \cdot 10^{-75}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -8.8 \cdot 10^{-97}:\\ \;\;\;\;\frac{c \cdot a}{t_1}\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{-67}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error19.78%
Cost1488
\[\begin{array}{l} t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\ t_1 := \frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{if}\;d \leq -4.2 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -2.4 \cdot 10^{-134}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.2 \cdot 10^{-37}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\ \mathbf{elif}\;d \leq 1.06 \cdot 10^{+27}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 6.5 \cdot 10^{+67}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error31.41%
Cost1234
\[\begin{array}{l} \mathbf{if}\;c \leq -1.65 \cdot 10^{+19} \lor \neg \left(c \leq -1.1 \cdot 10^{-66} \lor \neg \left(c \leq -7.4 \cdot 10^{-97}\right) \land c \leq 6.4 \cdot 10^{-62}\right):\\ \;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
Alternative 10
Error24.59%
Cost1232
\[\begin{array}{l} t_0 := \frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\ t_1 := \frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\ \mathbf{if}\;c \leq -3 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3 \cdot 10^{-75}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -3.8 \cdot 10^{-99}:\\ \;\;\;\;\frac{c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-59}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error24.62%
Cost969
\[\begin{array}{l} \mathbf{if}\;c \leq -5.8 \cdot 10^{+19} \lor \neg \left(c \leq 6.2 \cdot 10^{-68}\right):\\ \;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\ \end{array} \]
Alternative 12
Error24.47%
Cost969
\[\begin{array}{l} \mathbf{if}\;c \leq -2.35 \cdot 10^{+19} \lor \neg \left(c \leq 1.3 \cdot 10^{-66}\right):\\ \;\;\;\;\frac{a}{c} + \frac{d \cdot \frac{b}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\ \end{array} \]
Alternative 13
Error24.11%
Cost969
\[\begin{array}{l} \mathbf{if}\;d \leq -4.1 \cdot 10^{+17} \lor \neg \left(d \leq 6.2 \cdot 10^{-40}\right):\\ \;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{\frac{d}{c}}{c}\\ \end{array} \]
Alternative 14
Error24.71%
Cost968
\[\begin{array}{l} \mathbf{if}\;c \leq -2.4 \cdot 10^{+19}:\\ \;\;\;\;\frac{1}{c} \cdot \left(a + d \cdot \frac{b}{c}\right)\\ \mathbf{elif}\;c \leq 6.6 \cdot 10^{-72}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + \frac{c \cdot a}{d}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]
Alternative 15
Error37.77%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -1.65 \cdot 10^{+19}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{-69}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 16
Error59.19%
Cost192
\[\frac{a}{c} \]

Error

Reproduce?

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