?

Average Error: 26.2 → 11.2
Time: 14.0s
Precision: binary64
Cost: 14552

?

\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;d \leq -4 \cdot 10^{+152}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.7 \cdot 10^{-25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-78}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 8.8 \cdot 10^{+36}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 6.8 \cdot 10^{+76}:\\ \;\;\;\;\frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{-d}}\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{+140}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(FPCore (a b c d)
 :precision binary64
 (let* ((t_0 (* (/ 1.0 (hypot c d)) (/ (- (* c b) (* d a)) (hypot c d)))))
   (if (<= d -4e+152)
     (/ (- (* c (/ b d)) a) d)
     (if (<= d -1.7e-25)
       t_0
       (if (<= d 1.4e-78)
         (/ (- b (/ (* d a) c)) c)
         (if (<= d 8.8e+36)
           t_0
           (if (<= d 6.8e+76)
             (/ a (/ (fma d d (* c c)) (- d)))
             (if (<= d 3.2e+140) t_0 (- (* (/ b d) (/ c d)) (/ a d))))))))))
double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
double code(double a, double b, double c, double d) {
	double t_0 = (1.0 / hypot(c, d)) * (((c * b) - (d * a)) / hypot(c, d));
	double tmp;
	if (d <= -4e+152) {
		tmp = ((c * (b / d)) - a) / d;
	} else if (d <= -1.7e-25) {
		tmp = t_0;
	} else if (d <= 1.4e-78) {
		tmp = (b - ((d * a) / c)) / c;
	} else if (d <= 8.8e+36) {
		tmp = t_0;
	} else if (d <= 6.8e+76) {
		tmp = a / (fma(d, d, (c * c)) / -d);
	} else if (d <= 3.2e+140) {
		tmp = t_0;
	} else {
		tmp = ((b / d) * (c / d)) - (a / d);
	}
	return tmp;
}
function code(a, b, c, d)
	return Float64(Float64(Float64(b * c) - Float64(a * 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(Float64(Float64(c * b) - Float64(d * a)) / hypot(c, d)))
	tmp = 0.0
	if (d <= -4e+152)
		tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d);
	elseif (d <= -1.7e-25)
		tmp = t_0;
	elseif (d <= 1.4e-78)
		tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c);
	elseif (d <= 8.8e+36)
		tmp = t_0;
	elseif (d <= 6.8e+76)
		tmp = Float64(a / Float64(fma(d, d, Float64(c * c)) / Float64(-d)));
	elseif (d <= 3.2e+140)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(b / d) * Float64(c / d)) - Float64(a / d));
	end
	return tmp
end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * 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[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4e+152], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.7e-25], t$95$0, If[LessEqual[d, 1.4e-78], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 8.8e+36], t$95$0, If[LessEqual[d, 6.8e+76], N[(a / N[(N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision] / (-d)), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.2e+140], t$95$0, N[(N[(N[(b / d), $MachinePrecision] * N[(c / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]]]]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -4 \cdot 10^{+152}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\

\mathbf{elif}\;d \leq -1.7 \cdot 10^{-25}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 1.4 \cdot 10^{-78}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\

\mathbf{elif}\;d \leq 8.8 \cdot 10^{+36}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq 6.8 \cdot 10^{+76}:\\
\;\;\;\;\frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{-d}}\\

\mathbf{elif}\;d \leq 3.2 \cdot 10^{+140}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Target

Original26.2
Target0.4
Herbie11.2
\[\begin{array}{l} \mathbf{if}\;\left|d\right| < \left|c\right|:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array} \]

Derivation?

  1. Split input into 5 regimes
  2. if d < -4.0000000000000002e152

    1. Initial program 45.5

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

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

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

      [Start]15.0

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

      +-commutative [=>]15.0

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

      mul-1-neg [=>]15.0

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

      unsub-neg [=>]15.0

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

      *-commutative [<=]15.0

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

      unpow2 [=>]15.0

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

      times-frac [=>]6.6

      \[ \color{blue}{\frac{b}{d} \cdot \frac{c}{d}} - \frac{a}{d} \]
    4. Taylor expanded in b around 0 15.0

      \[\leadsto \color{blue}{-1 \cdot \frac{a}{d} + \frac{c \cdot b}{{d}^{2}}} \]
    5. Simplified6.5

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

      [Start]15.0

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

      +-commutative [=>]15.0

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

      *-commutative [=>]15.0

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

      unpow2 [=>]15.0

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

      associate-/l* [=>]13.5

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

      mul-1-neg [=>]13.5

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

      sub-neg [<=]13.5

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

      associate-/l* [<=]15.0

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

      associate-/r* [=>]11.6

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

      div-sub [<=]11.6

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

      *-commutative [<=]11.6

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

      associate-*r/ [<=]6.5

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

    if -4.0000000000000002e152 < d < -1.70000000000000001e-25 or 1.40000000000000012e-78 < d < 8.80000000000000002e36 or 6.7999999999999994e76 < d < 3.20000000000000011e140

    1. Initial program 18.0

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

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

    if -1.70000000000000001e-25 < d < 1.40000000000000012e-78

    1. Initial program 19.7

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

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

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

      [Start]14.9

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

      +-commutative [=>]14.9

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

      mul-1-neg [=>]14.9

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

      unsub-neg [=>]14.9

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

      *-commutative [=>]14.9

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

      unpow2 [=>]14.9

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

      times-frac [=>]13.4

      \[ \frac{b}{c} - \color{blue}{\frac{d}{c} \cdot \frac{a}{c}} \]
    4. Applied egg-rr11.8

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

    if 8.80000000000000002e36 < d < 6.7999999999999994e76

    1. Initial program 17.4

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

      \[\leadsto \color{blue}{-1 \cdot \frac{a \cdot d}{{d}^{2} + {c}^{2}}} \]
    3. Simplified24.3

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

      [Start]31.1

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

      associate-*r/ [=>]31.1

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

      mul-1-neg [=>]31.1

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

      distribute-rgt-neg-out [<=]31.1

      \[ \frac{\color{blue}{a \cdot \left(-d\right)}}{{d}^{2} + {c}^{2}} \]

      associate-/l* [=>]24.3

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

      unpow2 [=>]24.3

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

      fma-def [=>]24.3

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

      unpow2 [=>]24.3

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

    if 3.20000000000000011e140 < d

    1. Initial program 43.6

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

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

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

      [Start]15.0

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

      +-commutative [=>]15.0

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

      mul-1-neg [=>]15.0

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

      unsub-neg [=>]15.0

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

      *-commutative [<=]15.0

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

      unpow2 [=>]15.0

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

      times-frac [=>]7.3

      \[ \color{blue}{\frac{b}{d} \cdot \frac{c}{d}} - \frac{a}{d} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification11.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -4 \cdot 10^{+152}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq -1.7 \cdot 10^{-25}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq 1.4 \cdot 10^{-78}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 8.8 \cdot 10^{+36}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq 6.8 \cdot 10^{+76}:\\ \;\;\;\;\frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{-d}}\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{+140}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \end{array} \]

Alternatives

Alternative 1
Error12.7
Cost7700
\[\begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \mathbf{if}\;d \leq -1.7 \cdot 10^{+118}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -1.7 \cdot 10^{-25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{-78}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 70000000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.56 \cdot 10^{+80}:\\ \;\;\;\;\frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{-d}}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+139}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error12.7
Cost7700
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{c \cdot b - d \cdot a}{t_0}\\ t_2 := \frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \mathbf{if}\;d \leq -8.6 \cdot 10^{+116}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;d \leq -2.3 \cdot 10^{-25}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, b, d \cdot \left(-a\right)\right)}{t_0}\\ \mathbf{elif}\;d \leq 5 \cdot 10^{-78}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 70000000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 7.8 \cdot 10^{+76}:\\ \;\;\;\;\frac{a}{\frac{\mathsf{fma}\left(d, d, c \cdot c\right)}{-d}}\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{+139}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error13.8
Cost1752
\[\begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \mathbf{if}\;d \leq -1.15 \cdot 10^{+116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -1.95 \cdot 10^{-22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 4.6 \cdot 10^{-76}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 1.7 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{+107}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+139}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error15.7
Cost1232
\[\begin{array}{l} \mathbf{if}\;d \leq -5.2 \cdot 10^{-22}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-75}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 3.65 \cdot 10^{+87}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 2.5 \cdot 10^{+107}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \end{array} \]
Alternative 5
Error15.8
Cost1232
\[\begin{array}{l} \mathbf{if}\;d \leq -7.5 \cdot 10^{-21}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 3.8 \cdot 10^{-76}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 1.02 \cdot 10^{+89}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 7.5 \cdot 10^{+111}:\\ \;\;\;\;\frac{b}{c} - \frac{d}{c} \cdot \frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} \cdot \frac{c}{d} - \frac{a}{d}\\ \end{array} \]
Alternative 6
Error20.1
Cost1106
\[\begin{array}{l} \mathbf{if}\;d \leq -7.6 \cdot 10^{-21} \lor \neg \left(d \leq 1.45 \cdot 10^{+16} \lor \neg \left(d \leq 2.25 \cdot 10^{+65}\right) \land d \leq 1.05 \cdot 10^{+108}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]
Alternative 7
Error19.7
Cost1105
\[\begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -5.6 \cdot 10^{-21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 4.4 \cdot 10^{+15}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 3.2 \cdot 10^{+65} \lor \neg \left(d \leq 6.8 \cdot 10^{+109}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]
Alternative 8
Error15.3
Cost1105
\[\begin{array}{l} t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{if}\;d \leq -2 \cdot 10^{-21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.9 \cdot 10^{-46}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 1.02 \cdot 10^{+89} \lor \neg \left(d \leq 2.6 \cdot 10^{+107}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \end{array} \]
Alternative 9
Error15.7
Cost1104
\[\begin{array}{l} t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\ \mathbf{if}\;d \leq -7.6 \cdot 10^{-21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{-75}:\\ \;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\ \mathbf{elif}\;d \leq 1.02 \cdot 10^{+89}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+108}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error23.7
Cost786
\[\begin{array}{l} \mathbf{if}\;d \leq -4 \cdot 10^{-21} \lor \neg \left(d \leq 2.7 \cdot 10^{-46} \lor \neg \left(d \leq 1.32 \cdot 10^{+87}\right) \land d \leq 2.5 \cdot 10^{+107}\right):\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
Alternative 11
Error38.1
Cost192
\[\frac{b}{c} \]

Error

Reproduce?

herbie shell --seed 2023066 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

  :herbie-target
  (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))

  (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))