?

Average Error: 59.4% → 82.5%
Time: 18.1s
Precision: binary64
Cost: 20824.00

?

\[\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)} \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;c \leq -5 \cdot 10^{+96}:\\ \;\;\;\;\left(a + \frac{d}{\frac{c}{b}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -3.5 \cdot 10^{-63}:\\ \;\;\;\;\frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq -3 \cdot 10^{-138}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-274}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.85 \cdot 10^{-98}:\\ \;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{+75}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \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 (* (/ 1.0 (hypot c d)) (/ (fma a c (* d b)) (hypot c d)))))
   (if (<= c -5e+96)
     (* (+ a (/ d (/ c b))) (/ -1.0 (hypot c d)))
     (if (<= c -3.5e-63)
       (/ (+ (* c a) (* d b)) (+ (* c c) (* d d)))
       (if (<= c -3e-138)
         (+ (/ b d) (* (/ a d) (/ c d)))
         (if (<= c -2e-274)
           t_0
           (if (<= c 2.85e-98)
             (+ (/ b d) (/ (* a (/ c d)) d))
             (if (<= c 2.8e+75) t_0 (+ (/ a c) (* (/ b c) (/ 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 = (1.0 / hypot(c, d)) * (fma(a, c, (d * b)) / hypot(c, d));
	double tmp;
	if (c <= -5e+96) {
		tmp = (a + (d / (c / b))) * (-1.0 / hypot(c, d));
	} else if (c <= -3.5e-63) {
		tmp = ((c * a) + (d * b)) / ((c * c) + (d * d));
	} else if (c <= -3e-138) {
		tmp = (b / d) + ((a / d) * (c / d));
	} else if (c <= -2e-274) {
		tmp = t_0;
	} else if (c <= 2.85e-98) {
		tmp = (b / d) + ((a * (c / d)) / d);
	} else if (c <= 2.8e+75) {
		tmp = t_0;
	} else {
		tmp = (a / c) + ((b / c) * (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(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(d * b)) / hypot(c, d)))
	tmp = 0.0
	if (c <= -5e+96)
		tmp = Float64(Float64(a + Float64(d / Float64(c / b))) * Float64(-1.0 / hypot(c, d)));
	elseif (c <= -3.5e-63)
		tmp = Float64(Float64(Float64(c * a) + Float64(d * b)) / Float64(Float64(c * c) + Float64(d * d)));
	elseif (c <= -3e-138)
		tmp = Float64(Float64(b / d) + Float64(Float64(a / d) * Float64(c / d)));
	elseif (c <= -2e-274)
		tmp = t_0;
	elseif (c <= 2.85e-98)
		tmp = Float64(Float64(b / d) + Float64(Float64(a * Float64(c / d)) / d));
	elseif (c <= 2.8e+75)
		tmp = t_0;
	else
		tmp = Float64(Float64(a / c) + Float64(Float64(b / c) * 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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -5e+96], N[(N[(a + N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -3.5e-63], N[(N[(N[(c * a), $MachinePrecision] + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -3e-138], N[(N[(b / d), $MachinePrecision] + N[(N[(a / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2e-274], t$95$0, If[LessEqual[c, 2.85e-98], N[(N[(b / d), $MachinePrecision] + N[(N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.8e+75], t$95$0, N[(N[(a / c), $MachinePrecision] + N[(N[(b / c), $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{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -5 \cdot 10^{+96}:\\
\;\;\;\;\left(a + \frac{d}{\frac{c}{b}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\

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

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

\mathbf{elif}\;c \leq -2 \cdot 10^{-274}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;c \leq 2.8 \cdot 10^{+75}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Target

Original59.4%
Target99.4%
Herbie82.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 6 regimes
  2. if c < -5.0000000000000004e96

    1. Initial program 39.4

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

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

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

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

      [Start]78.3

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

      distribute-lft-out [=>]78.3

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

      +-commutative [<=]78.3

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

      associate-/l* [=>]84.6

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

    if -5.0000000000000004e96 < c < -3.50000000000000003e-63

    1. Initial program 77.3

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

    if -3.50000000000000003e-63 < c < -3.0000000000000001e-138

    1. Initial program 78.4

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

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

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

      [Start]66.8

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

      *-commutative [<=]66.8

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

      unpow2 [=>]66.8

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

      times-frac [=>]67.6

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

    if -3.0000000000000001e-138 < c < -1.99999999999999993e-274 or 2.8499999999999999e-98 < c < 2.80000000000000012e75

    1. Initial program 70.8

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

      \[\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 -1.99999999999999993e-274 < c < 2.8499999999999999e-98

    1. Initial program 66.3

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

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

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

      [Start]82.4

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

      *-commutative [=>]82.4

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

      unpow2 [=>]82.4

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

      associate-/r* [=>]88.3

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

      *-commutative [<=]88.3

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

      associate-/l* [=>]85.8

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

      associate-/r/ [=>]88.5

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

    if 2.80000000000000012e75 < c

    1. Initial program 39.0

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

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

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

      [Start]72.1

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

      *-commutative [<=]72.1

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

      unpow2 [=>]72.1

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

      times-frac [=>]82.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -5 \cdot 10^{+96}:\\ \;\;\;\;\left(a + \frac{d}{\frac{c}{b}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -3.5 \cdot 10^{-63}:\\ \;\;\;\;\frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq -3 \cdot 10^{-138}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-274}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq 2.85 \cdot 10^{-98}:\\ \;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{+75}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \end{array} \]

Alternatives

Alternative 1
Error79.5%
Cost13904.00
\[\begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{+96}:\\ \;\;\;\;\left(a + \frac{d}{\frac{c}{b}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -1.5 \cdot 10^{-71}:\\ \;\;\;\;\frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{-97}:\\ \;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{+185}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{b \cdot \frac{d}{c}}{c}\\ \end{array} \]
Alternative 2
Error82.2%
Cost7300.00
\[\begin{array}{l} t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -3 \cdot 10^{+97}:\\ \;\;\;\;\left(a + \frac{d}{\frac{c}{b}}\right) \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -2.7 \cdot 10^{-71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{-98}:\\ \;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 4.7 \cdot 10^{+70}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \end{array} \]
Alternative 3
Error82.0%
Cost1488.00
\[\begin{array}{l} t_0 := \frac{c \cdot a + d \cdot b}{c \cdot c + d \cdot d}\\ t_1 := \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -2.2 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -6.1 \cdot 10^{-71}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{-99}:\\ \;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 6.4 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error59.8%
Cost1240.00
\[\begin{array}{l} \mathbf{if}\;c \leq -1.75 \cdot 10^{-15}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 0.205:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 5.2 \cdot 10^{+69}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 7 \cdot 10^{+220}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 2.35 \cdot 10^{+287}:\\ \;\;\;\;\frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 5
Error65.9%
Cost1240.00
\[\begin{array}{l} t_0 := \frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{if}\;c \leq -1.32 \cdot 10^{-15}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-92}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 0.35:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 1.9 \cdot 10^{+69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 7 \cdot 10^{+220}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{+285}:\\ \;\;\;\;\frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 6
Error66.0%
Cost1240.00
\[\begin{array}{l} \mathbf{if}\;c \leq -1.32 \cdot 10^{-15}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-92}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{elif}\;c \leq 0.118:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 1.9 \cdot 10^{+71}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + c \cdot \frac{a}{d}\right)\\ \mathbf{elif}\;c \leq 7 \cdot 10^{+220}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 8 \cdot 10^{+285}:\\ \;\;\;\;\frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 7
Error74.2%
Cost1233.00
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -2 \cdot 10^{-15}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{-93}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{elif}\;c \leq 0.17 \lor \neg \left(c \leq 7.5 \cdot 10^{+70}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + c \cdot \frac{a}{d}\right)\\ \end{array} \]
Alternative 8
Error74.4%
Cost1233.00
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -4.1 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-92}:\\ \;\;\;\;\frac{1}{d} \cdot \left(b + a \cdot \frac{c}{d}\right)\\ \mathbf{elif}\;c \leq 0.215 \lor \neg \left(c \leq 2.3 \cdot 10^{+72}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \end{array} \]
Alternative 9
Error74.4%
Cost1233.00
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -1.75 \cdot 10^{-15}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-92}:\\ \;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 0.35 \lor \neg \left(c \leq 5 \cdot 10^{+69}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \end{array} \]
Alternative 10
Error75.2%
Cost1232.00
\[\begin{array}{l} t_0 := \frac{a}{c} + \frac{b}{c} \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -1.56 \cdot 10^{-15}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{-97}:\\ \;\;\;\;\frac{b}{d} + \frac{a \cdot \frac{c}{d}}{d}\\ \mathbf{elif}\;c \leq 0.35:\\ \;\;\;\;\frac{c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 5 \cdot 10^{+69}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error62.1%
Cost721.00
\[\begin{array}{l} \mathbf{if}\;c \leq -1.32 \cdot 10^{-15}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-92} \lor \neg \left(c \leq 0.24\right) \land c \leq 6.8 \cdot 10^{+72}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 12
Error41.2%
Cost192.00
\[\frac{a}{c} \]

Error

Reproduce?

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