?

Average Accuracy: 58.1% → 82.8%
Time: 13.2s
Precision: binary64
Cost: 20560

?

\[\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 := t_0 \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;c \leq -4.6 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{fma}\left(\frac{d}{c}, \frac{b}{c}, \frac{a}{c}\right)\\ \mathbf{elif}\;c \leq -6.2 \cdot 10^{-112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.42 \cdot 10^{-301}:\\ \;\;\;\;\frac{-1}{d} \cdot \left(\left(-b\right) - \frac{a}{\frac{d}{c}}\right)\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{+81}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(a + \frac{d}{\frac{c}{b}}\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 (* t_0 (/ (fma a c (* d b)) (hypot c d)))))
   (if (<= c -4.6e+73)
     (fma (/ d c) (/ b c) (/ a c))
     (if (<= c -6.2e-112)
       t_1
       (if (<= c 1.42e-301)
         (* (/ -1.0 d) (- (- b) (/ a (/ d c))))
         (if (<= c 2.8e+81) t_1 (* t_0 (+ a (/ d (/ c b))))))))))
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 = t_0 * (fma(a, c, (d * b)) / hypot(c, d));
	double tmp;
	if (c <= -4.6e+73) {
		tmp = fma((d / c), (b / c), (a / c));
	} else if (c <= -6.2e-112) {
		tmp = t_1;
	} else if (c <= 1.42e-301) {
		tmp = (-1.0 / d) * (-b - (a / (d / c)));
	} else if (c <= 2.8e+81) {
		tmp = t_1;
	} else {
		tmp = t_0 * (a + (d / (c / b)));
	}
	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(t_0 * Float64(fma(a, c, Float64(d * b)) / hypot(c, d)))
	tmp = 0.0
	if (c <= -4.6e+73)
		tmp = fma(Float64(d / c), Float64(b / c), Float64(a / c));
	elseif (c <= -6.2e-112)
		tmp = t_1;
	elseif (c <= 1.42e-301)
		tmp = Float64(Float64(-1.0 / d) * Float64(Float64(-b) - Float64(a / Float64(d / c))));
	elseif (c <= 2.8e+81)
		tmp = t_1;
	else
		tmp = Float64(t_0 * Float64(a + Float64(d / Float64(c / b))));
	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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4.6e+73], N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision] + N[(a / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -6.2e-112], t$95$1, If[LessEqual[c, 1.42e-301], N[(N[(-1.0 / d), $MachinePrecision] * N[((-b) - N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.8e+81], t$95$1, N[(t$95$0 * N[(a + N[(d / N[(c / b), $MachinePrecision]), $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)}\\
t_1 := t_0 \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -4.6 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{fma}\left(\frac{d}{c}, \frac{b}{c}, \frac{a}{c}\right)\\

\mathbf{elif}\;c \leq -6.2 \cdot 10^{-112}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;c \leq 2.8 \cdot 10^{+81}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Target

Original58.1%
Target99.3%
Herbie82.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 4 regimes
  2. if c < -4.6e73

    1. Initial program 40.3%

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

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

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

      [Start]72.9

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

      +-commutative [=>]72.9

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

      unpow2 [=>]72.9

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

      times-frac [=>]81.8

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

      fma-def [=>]81.8

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

    if -4.6e73 < c < -6.1999999999999995e-112 or 1.42000000000000004e-301 < c < 2.79999999999999995e81

    1. Initial program 71.5%

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

      [Start]71.5

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

      *-un-lft-identity [=>]71.5

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

      add-sqr-sqrt [=>]71.5

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

      times-frac [=>]71.5

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

      hypot-def [=>]71.5

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

      fma-def [=>]71.5

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

      hypot-def [=>]81.1

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

    if -6.1999999999999995e-112 < c < 1.42000000000000004e-301

    1. Initial program 65.6%

      \[\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)}} \]
      Proof

      [Start]65.6

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

      *-un-lft-identity [=>]65.6

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

      add-sqr-sqrt [=>]65.6

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

      times-frac [=>]65.6

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

      hypot-def [=>]65.6

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

      fma-def [=>]65.6

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

      hypot-def [=>]81.0

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

      \[\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. Simplified52.3%

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

      [Start]52.9

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

      mul-1-neg [=>]52.9

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

      unsub-neg [=>]52.9

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

      mul-1-neg [=>]52.9

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

      *-commutative [<=]52.9

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

      associate-/l* [=>]52.3

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

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

    if 2.79999999999999995e81 < c

    1. Initial program 41.1%

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

      [Start]41.1

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

      *-un-lft-identity [=>]41.1

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

      add-sqr-sqrt [=>]41.1

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

      times-frac [=>]41.1

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

      hypot-def [=>]41.1

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

      fma-def [=>]41.1

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

      hypot-def [=>]60.0

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

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

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

      [Start]77.2

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

      associate-/l* [=>]83.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -4.6 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{fma}\left(\frac{d}{c}, \frac{b}{c}, \frac{a}{c}\right)\\ \mathbf{elif}\;c \leq -6.2 \cdot 10^{-112}:\\ \;\;\;\;\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 1.42 \cdot 10^{-301}:\\ \;\;\;\;\frac{-1}{d} \cdot \left(\left(-b\right) - \frac{a}{\frac{d}{c}}\right)\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{+81}:\\ \;\;\;\;\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{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy80.6%
Cost7828
\[\begin{array}{l} t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -2.7 \cdot 10^{+79}:\\ \;\;\;\;\mathsf{fma}\left(\frac{d}{c}, \frac{b}{c}, \frac{a}{c}\right)\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-111}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.7 \cdot 10^{-152}:\\ \;\;\;\;\frac{-1}{d} \cdot \left(\left(-b\right) - \frac{a}{\frac{d}{c}}\right)\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.8 \cdot 10^{+75}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + \frac{d}{\frac{c}{b}}\right)\\ \end{array} \]
Alternative 2
Accuracy80.3%
Cost7636
\[\begin{array}{l} t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \mathsf{fma}\left(\frac{d}{c}, \frac{b}{c}, \frac{a}{c}\right)\\ \mathbf{if}\;c \leq -8.5 \cdot 10^{+82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.05 \cdot 10^{-111}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 7.3 \cdot 10^{-152}:\\ \;\;\;\;\frac{-1}{d} \cdot \left(\left(-b\right) - \frac{a}{\frac{d}{c}}\right)\\ \mathbf{elif}\;c \leq 1.95 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 6.5 \cdot 10^{+75}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy80.2%
Cost1488
\[\begin{array}{l} t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{a}{c} + \frac{\frac{d}{c} \cdot b}{c}\\ \mathbf{if}\;c \leq -9.5 \cdot 10^{+82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -7.2 \cdot 10^{-112}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{-152}:\\ \;\;\;\;\frac{-1}{d} \cdot \left(\left(-b\right) - \frac{a}{\frac{d}{c}}\right)\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 4 \cdot 10^{+75}:\\ \;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy76.0%
Cost1232
\[\begin{array}{l} t_0 := \frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{if}\;d \leq -1.6 \cdot 10^{+92}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -2.75 \cdot 10^{+60}:\\ \;\;\;\;\frac{d}{\frac{c \cdot c + d \cdot d}{b}}\\ \mathbf{elif}\;d \leq -3.6 \cdot 10^{-44}:\\ \;\;\;\;\frac{b}{d} + \frac{c \cdot a}{d \cdot d}\\ \mathbf{elif}\;d \leq 5.5 \cdot 10^{+58}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{d}{c} \cdot b}{c}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Accuracy67.8%
Cost969
\[\begin{array}{l} \mathbf{if}\;d \leq -1.55 \cdot 10^{-32} \lor \neg \left(d \leq 2.7 \cdot 10^{+59}\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + b \cdot \frac{d}{c \cdot c}\\ \end{array} \]
Alternative 6
Accuracy69.3%
Cost969
\[\begin{array}{l} \mathbf{if}\;d \leq -1.25 \cdot 10^{-34} \lor \neg \left(d \leq 5 \cdot 10^{+58}\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{b}{\frac{c}{\frac{d}{c}}}\\ \end{array} \]
Alternative 7
Accuracy70.7%
Cost969
\[\begin{array}{l} \mathbf{if}\;d \leq -8.8 \cdot 10^{-32} \lor \neg \left(d \leq 1.4 \cdot 10^{+59}\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{d}{c} \cdot b}{c}\\ \end{array} \]
Alternative 8
Accuracy75.8%
Cost969
\[\begin{array}{l} \mathbf{if}\;d \leq -6.5 \cdot 10^{-51} \lor \neg \left(d \leq 3.5 \cdot 10^{+59}\right):\\ \;\;\;\;\frac{b}{d} + \frac{a}{d} \cdot \frac{c}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{d}{c} \cdot b}{c}\\ \end{array} \]
Alternative 9
Accuracy63.2%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -0.012:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 5.9 \cdot 10^{+105}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 10
Accuracy42.0%
Cost192
\[\frac{a}{c} \]

Error

Reproduce?

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