Average Error: 26.2 → 13.3
Time: 15.1s
Precision: binary64
Cost: 14424
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
\[\begin{array}{l} t_0 := \frac{b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_2 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;c \leq -3.0844161161393104 \cdot 10^{+87}:\\ \;\;\;\;t_1 \cdot \left(\frac{d}{\frac{c}{a}} - b\right)\\ \mathbf{elif}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 10^{-100}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;c \leq 5.936106704635713 \cdot 10^{-5}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.1193682608307834 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(b - \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}\right)\\ \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 (/ (* b (/ c (hypot c d))) (hypot c d)))
        (t_1 (/ 1.0 (hypot c d)))
        (t_2 (/ (- (/ (* c b) d) a) d)))
   (if (<= c -3.0844161161393104e+87)
     (* t_1 (- (/ d (/ c a)) b))
     (if (<= c -9.004640130169398e-22)
       t_0
       (if (<= c 1e-100)
         t_2
         (if (<= c 2.810993454941876e-65)
           (/ (- b (/ a (/ c d))) c)
           (if (<= c 5.936106704635713e-5)
             t_2
             (if (<= c 2.1193682608307834e+67)
               t_0
               (* t_1 (- b (/ d (/ (hypot c d) a))))))))))))
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 = (b * (c / hypot(c, d))) / hypot(c, d);
	double t_1 = 1.0 / hypot(c, d);
	double t_2 = (((c * b) / d) - a) / d;
	double tmp;
	if (c <= -3.0844161161393104e+87) {
		tmp = t_1 * ((d / (c / a)) - b);
	} else if (c <= -9.004640130169398e-22) {
		tmp = t_0;
	} else if (c <= 1e-100) {
		tmp = t_2;
	} else if (c <= 2.810993454941876e-65) {
		tmp = (b - (a / (c / d))) / c;
	} else if (c <= 5.936106704635713e-5) {
		tmp = t_2;
	} else if (c <= 2.1193682608307834e+67) {
		tmp = t_0;
	} else {
		tmp = t_1 * (b - (d / (hypot(c, d) / a)));
	}
	return tmp;
}
public static double code(double a, double b, double c, double d) {
	return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (b * (c / Math.hypot(c, d))) / Math.hypot(c, d);
	double t_1 = 1.0 / Math.hypot(c, d);
	double t_2 = (((c * b) / d) - a) / d;
	double tmp;
	if (c <= -3.0844161161393104e+87) {
		tmp = t_1 * ((d / (c / a)) - b);
	} else if (c <= -9.004640130169398e-22) {
		tmp = t_0;
	} else if (c <= 1e-100) {
		tmp = t_2;
	} else if (c <= 2.810993454941876e-65) {
		tmp = (b - (a / (c / d))) / c;
	} else if (c <= 5.936106704635713e-5) {
		tmp = t_2;
	} else if (c <= 2.1193682608307834e+67) {
		tmp = t_0;
	} else {
		tmp = t_1 * (b - (d / (Math.hypot(c, d) / a)));
	}
	return tmp;
}
def code(a, b, c, d):
	return ((b * c) - (a * d)) / ((c * c) + (d * d))
def code(a, b, c, d):
	t_0 = (b * (c / math.hypot(c, d))) / math.hypot(c, d)
	t_1 = 1.0 / math.hypot(c, d)
	t_2 = (((c * b) / d) - a) / d
	tmp = 0
	if c <= -3.0844161161393104e+87:
		tmp = t_1 * ((d / (c / a)) - b)
	elif c <= -9.004640130169398e-22:
		tmp = t_0
	elif c <= 1e-100:
		tmp = t_2
	elif c <= 2.810993454941876e-65:
		tmp = (b - (a / (c / d))) / c
	elif c <= 5.936106704635713e-5:
		tmp = t_2
	elif c <= 2.1193682608307834e+67:
		tmp = t_0
	else:
		tmp = t_1 * (b - (d / (math.hypot(c, d) / a)))
	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(b * Float64(c / hypot(c, d))) / hypot(c, d))
	t_1 = Float64(1.0 / hypot(c, d))
	t_2 = Float64(Float64(Float64(Float64(c * b) / d) - a) / d)
	tmp = 0.0
	if (c <= -3.0844161161393104e+87)
		tmp = Float64(t_1 * Float64(Float64(d / Float64(c / a)) - b));
	elseif (c <= -9.004640130169398e-22)
		tmp = t_0;
	elseif (c <= 1e-100)
		tmp = t_2;
	elseif (c <= 2.810993454941876e-65)
		tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c);
	elseif (c <= 5.936106704635713e-5)
		tmp = t_2;
	elseif (c <= 2.1193682608307834e+67)
		tmp = t_0;
	else
		tmp = Float64(t_1 * Float64(b - Float64(d / Float64(hypot(c, d) / a))));
	end
	return tmp
end
function tmp = code(a, b, c, d)
	tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
end
function tmp_2 = code(a, b, c, d)
	t_0 = (b * (c / hypot(c, d))) / hypot(c, d);
	t_1 = 1.0 / hypot(c, d);
	t_2 = (((c * b) / d) - a) / d;
	tmp = 0.0;
	if (c <= -3.0844161161393104e+87)
		tmp = t_1 * ((d / (c / a)) - b);
	elseif (c <= -9.004640130169398e-22)
		tmp = t_0;
	elseif (c <= 1e-100)
		tmp = t_2;
	elseif (c <= 2.810993454941876e-65)
		tmp = (b - (a / (c / d))) / c;
	elseif (c <= 5.936106704635713e-5)
		tmp = t_2;
	elseif (c <= 2.1193682608307834e+67)
		tmp = t_0;
	else
		tmp = t_1 * (b - (d / (hypot(c, d) / a)));
	end
	tmp_2 = 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[(b * N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[c, -3.0844161161393104e+87], N[(t$95$1 * N[(N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -9.004640130169398e-22], t$95$0, If[LessEqual[c, 1e-100], t$95$2, If[LessEqual[c, 2.810993454941876e-65], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 5.936106704635713e-5], t$95$2, If[LessEqual[c, 2.1193682608307834e+67], t$95$0, N[(t$95$1 * N[(b - N[(d / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\begin{array}{l}
t_0 := \frac{b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := \frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{if}\;c \leq -3.0844161161393104 \cdot 10^{+87}:\\
\;\;\;\;t_1 \cdot \left(\frac{d}{\frac{c}{a}} - b\right)\\

\mathbf{elif}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;c \leq 10^{-100}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;c \leq 5.936106704635713 \cdot 10^{-5}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;c \leq 2.1193682608307834 \cdot 10^{+67}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(b - \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.2
Target0.4
Herbie13.3
\[\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 c < -3.0844161161393104e87

    1. Initial program 38.7

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

      \[\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)}} \]
    3. Applied egg-rr0.4

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

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

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

    if -3.0844161161393104e87 < c < -9.00464013016939771e-22 or 5.936106704635713e-5 < c < 2.11936826083078337e67

    1. Initial program 16.8

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\color{blue}{c \cdot b}}{\mathsf{hypot}\left(c, d\right)} \]
    4. Applied egg-rr25.0

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

    if -9.00464013016939771e-22 < c < 1e-100 or 2.81099345494187589e-65 < c < 5.936106704635713e-5

    1. Initial program 19.8

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

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

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

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

    if 1e-100 < c < 2.81099345494187589e-65

    1. Initial program 15.8

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

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

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

      \[\leadsto \color{blue}{\frac{b}{c} - \frac{\frac{a \cdot d}{c}}{c}} \]
    5. Applied egg-rr42.7

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

    if 2.11936826083078337e67 < c

    1. Initial program 36.7

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

      \[\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)}} \]
    3. Applied egg-rr0.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.0844161161393104 \cdot 10^{+87}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{d}{\frac{c}{a}} - b\right)\\ \mathbf{elif}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;\frac{b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq 10^{-100}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;c \leq 5.936106704635713 \cdot 10^{-5}:\\ \;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{elif}\;c \leq 2.1193682608307834 \cdot 10^{+67}:\\ \;\;\;\;\frac{b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - \frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error15.1
Cost14036
\[\begin{array}{l} t_0 := \frac{b \cdot \frac{c}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;c \leq -3.0844161161393104 \cdot 10^{+87}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\frac{d}{\frac{c}{a}} - b\right)\\ \mathbf{elif}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;c \leq 5.936106704635713 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error15.9
Cost7828
\[\begin{array}{l} t_0 := \frac{b - \frac{a}{\frac{c}{d}}}{c}\\ t_1 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;c \leq -3.0844161161393104 \cdot 10^{+87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.413535944840097 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b - d \cdot \frac{a}{c}\right)\\ \end{array} \]
Alternative 3
Error15.8
Cost7696
\[\begin{array}{l} t_0 := \frac{\frac{c \cdot b}{d} - a}{d}\\ t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;t_1 \cdot \left(\frac{d}{\frac{c}{a}} - b\right)\\ \mathbf{elif}\;c \leq 10^{-100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;c \leq 1.413535944840097 \cdot 10^{+99}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \left(b - d \cdot \frac{a}{c}\right)\\ \end{array} \]
Alternative 4
Error16.1
Cost7240
\[\begin{array}{l} t_0 := \frac{b - \frac{a}{\frac{c}{d}}}{c}\\ t_1 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;c \leq -3.0844161161393104 \cdot 10^{+87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;b \cdot \frac{c}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\ \mathbf{elif}\;c \leq 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.413535944840097 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error16.4
Cost1236
\[\begin{array}{l} t_0 := \frac{b - \frac{a}{\frac{c}{d}}}{c}\\ t_1 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;c \leq -3.0844161161393104 \cdot 10^{+87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;\frac{c \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.413535944840097 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error19.4
Cost1104
\[\begin{array}{l} t_0 := \frac{\frac{c \cdot b}{d} - a}{d}\\ \mathbf{if}\;c \leq -3.023733726081535 \cdot 10^{+48}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 6.5 \cdot 10^{-104}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;a \cdot \frac{-d}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.413535944840097 \cdot 10^{+99}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
Alternative 7
Error16.8
Cost1104
\[\begin{array}{l} t_0 := \frac{\frac{c \cdot b}{d} - a}{d}\\ t_1 := \frac{b - \frac{a}{\frac{c}{d}}}{c}\\ \mathbf{if}\;c \leq -2.900281961986854 \cdot 10^{+85}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 10^{-100}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.413535944840097 \cdot 10^{+99}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error24.0
Cost908
\[\begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;\frac{\left(-a\right) \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 1.413535944840097 \cdot 10^{+99}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
Alternative 9
Error24.0
Cost908
\[\begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{-105}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.810993454941876 \cdot 10^{-65}:\\ \;\;\;\;a \cdot \frac{-d}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.413535944840097 \cdot 10^{+99}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
Alternative 10
Error23.2
Cost520
\[\begin{array}{l} \mathbf{if}\;c \leq -9.004640130169398 \cdot 10^{-22}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq 1.413535944840097 \cdot 10^{+99}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
Alternative 11
Error37.5
Cost192
\[\frac{b}{c} \]

Error

Reproduce

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