Average Error: 25.5 → 0.8
Time: 18.4s
Precision: binary64
Cost: 22408
\[\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 \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)\\ t_1 := b \cdot c - d \cdot a\\ t_2 := \frac{t_1}{c \cdot c + d \cdot d}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+286}:\\ \;\;\;\;\frac{\frac{t_1}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \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))
          (- (/ b (/ (hypot c d) c)) (* d (/ a (hypot c d))))))
        (t_1 (- (* b c) (* d a)))
        (t_2 (/ t_1 (+ (* c c) (* d d)))))
   (if (<= t_2 (- INFINITY))
     t_0
     (if (<= t_2 5e+286) (/ (/ t_1 (hypot c d)) (hypot c d)) t_0))))
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)) * ((b / (hypot(c, d) / c)) - (d * (a / hypot(c, d))));
	double t_1 = (b * c) - (d * a);
	double t_2 = t_1 / ((c * c) + (d * d));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_0;
	} else if (t_2 <= 5e+286) {
		tmp = (t_1 / hypot(c, d)) / hypot(c, d);
	} else {
		tmp = t_0;
	}
	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 = (1.0 / Math.hypot(c, d)) * ((b / (Math.hypot(c, d) / c)) - (d * (a / Math.hypot(c, d))));
	double t_1 = (b * c) - (d * a);
	double t_2 = t_1 / ((c * c) + (d * d));
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else if (t_2 <= 5e+286) {
		tmp = (t_1 / Math.hypot(c, d)) / Math.hypot(c, d);
	} else {
		tmp = t_0;
	}
	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 = (1.0 / math.hypot(c, d)) * ((b / (math.hypot(c, d) / c)) - (d * (a / math.hypot(c, d))))
	t_1 = (b * c) - (d * a)
	t_2 = t_1 / ((c * c) + (d * d))
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_0
	elif t_2 <= 5e+286:
		tmp = (t_1 / math.hypot(c, d)) / math.hypot(c, d)
	else:
		tmp = t_0
	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(b / Float64(hypot(c, d) / c)) - Float64(d * Float64(a / hypot(c, d)))))
	t_1 = Float64(Float64(b * c) - Float64(d * a))
	t_2 = Float64(t_1 / Float64(Float64(c * c) + Float64(d * d)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_0;
	elseif (t_2 <= 5e+286)
		tmp = Float64(Float64(t_1 / hypot(c, d)) / hypot(c, d));
	else
		tmp = t_0;
	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 = (1.0 / hypot(c, d)) * ((b / (hypot(c, d) / c)) - (d * (a / hypot(c, d))));
	t_1 = (b * c) - (d * a);
	t_2 = t_1 / ((c * c) + (d * d));
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_0;
	elseif (t_2 <= 5e+286)
		tmp = (t_1 / hypot(c, d)) / hypot(c, d);
	else
		tmp = t_0;
	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[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$0, If[LessEqual[t$95$2, 5e+286], N[(N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\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 \left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\right)\\
t_1 := b \cdot c - d \cdot a\\
t_2 := \frac{t_1}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+286}:\\
\;\;\;\;\frac{\frac{t_1}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original25.5
Target0.5
Herbie0.8
\[\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 2 regimes
  2. if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0 or 5.0000000000000004e286 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d)))

    1. Initial program 62.9

      \[\frac{b \cdot c - a \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{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}} \]
    3. Applied egg-rr32.1

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

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \color{blue}{\left(\frac{b}{\sqrt{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{c}{\sqrt{\mathsf{hypot}\left(c, d\right)}} - \frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot d\right)} \]
      Proof
      (-.f64 (*.f64 (/.f64 b (sqrt.f64 (hypot.f64 c d))) (/.f64 c (sqrt.f64 (hypot.f64 c d)))) (*.f64 (/.f64 a (hypot.f64 c d)) d)): 0 points increase in error, 0 points decrease in error
      (-.f64 (*.f64 (/.f64 b (sqrt.f64 (hypot.f64 c d))) (/.f64 c (sqrt.f64 (hypot.f64 c d)))) (Rewrite<= associate-/r/_binary64 (/.f64 a (/.f64 (hypot.f64 c d) d)))): 33 points increase in error, 26 points decrease in error
      (-.f64 (*.f64 (/.f64 b (sqrt.f64 (hypot.f64 c d))) (/.f64 c (sqrt.f64 (hypot.f64 c d)))) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 a d) (hypot.f64 c d)))): 41 points increase in error, 12 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (*.f64 (/.f64 b (sqrt.f64 (hypot.f64 c d))) (/.f64 c (sqrt.f64 (hypot.f64 c d)))) (neg.f64 (/.f64 (*.f64 a d) (hypot.f64 c d))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-udef_binary64 (fma.f64 (/.f64 b (sqrt.f64 (hypot.f64 c d))) (/.f64 c (sqrt.f64 (hypot.f64 c d))) (neg.f64 (/.f64 (*.f64 a d) (hypot.f64 c d))))): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr20.5

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\color{blue}{\left(e^{\mathsf{log1p}\left(\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}\right)} - 1\right)} - \frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot d\right) \]
    6. Simplified0.9

      \[\leadsto \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(\color{blue}{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}} - \frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot d\right) \]
      Proof
      (/.f64 b (/.f64 (hypot.f64 c d) c)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= expm1-log1p_binary64 (expm1.f64 (log1p.f64 (/.f64 b (/.f64 (hypot.f64 c d) c))))): 65 points increase in error, 17 points decrease in error
      (Rewrite<= expm1-def_binary64 (-.f64 (exp.f64 (log1p.f64 (/.f64 b (/.f64 (hypot.f64 c d) c)))) 1)): 41 points increase in error, 77 points decrease in error

    if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.0000000000000004e286

    1. Initial program 11.8

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

      \[\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.8

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

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

Alternatives

Alternative 1
Error0.6
Cost26816
\[\frac{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)} - \frac{\frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{d}}}{\mathsf{hypot}\left(c, d\right)} \]
Alternative 2
Error6.1
Cost15688
\[\begin{array}{l} t_0 := \frac{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{d}\\ t_1 := b \cdot c - d \cdot a\\ t_2 := \frac{t_1}{c \cdot c + d \cdot d}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_2 \leq 10^{+271}:\\ \;\;\;\;\frac{\frac{t_1}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error9.6
Cost14160
\[\begin{array}{l} t_0 := \frac{\frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)} - \frac{a}{d}\\ t_1 := c \cdot c + d \cdot d\\ \mathbf{if}\;d \leq -8.5 \cdot 10^{+45}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -1.08 \cdot 10^{-97}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{t_1}\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{-132}:\\ \;\;\;\;\frac{b}{c} - \frac{\left(d \cdot a\right) \cdot \frac{1}{c}}{c}\\ \mathbf{elif}\;d \leq 6.8 \cdot 10^{+81}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error12.3
Cost7824
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ \mathbf{if}\;d \leq -5.8 \cdot 10^{+47}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - d \cdot \frac{a}{d}}{d}\\ \mathbf{elif}\;d \leq -1.96 \cdot 10^{-97}:\\ \;\;\;\;\frac{b \cdot c - d \cdot a}{t_0}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{-134}:\\ \;\;\;\;\frac{b}{c} - \frac{\left(d \cdot a\right) \cdot \frac{1}{c}}{c}\\ \mathbf{elif}\;d \leq 1.1 \cdot 10^{+85}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-d, a, b \cdot c\right)}{t_0}\\ \mathbf{elif}\;d \leq 2.4 \cdot 10^{+114}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+148}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
Alternative 5
Error12.3
Cost1488
\[\begin{array}{l} t_0 := \frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\ \mathbf{if}\;d \leq -1.55 \cdot 10^{+48}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - d \cdot \frac{a}{d}}{d}\\ \mathbf{elif}\;d \leq -8.6 \cdot 10^{-98}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{-135}:\\ \;\;\;\;\frac{b}{c} - \frac{\left(d \cdot a\right) \cdot \frac{1}{c}}{c}\\ \mathbf{elif}\;d \leq 1.46 \cdot 10^{+83}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+114}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+148}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
Alternative 6
Error16.7
Cost1368
\[\begin{array}{l} t_0 := \frac{b - d \cdot \frac{a}{c}}{c}\\ t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{if}\;d \leq -8.2 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 1.38 \cdot 10^{-21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 3.3 \cdot 10^{+76}:\\ \;\;\;\;d \cdot \frac{-a}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 6.2 \cdot 10^{+85}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{+114}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+148}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error16.8
Cost1368
\[\begin{array}{l} t_0 := \frac{b - d \cdot \frac{a}{c}}{c}\\ t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{if}\;d \leq -2.3 \cdot 10^{-50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 2.2 \cdot 10^{-12}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 3.7 \cdot 10^{+76}:\\ \;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+85}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+114}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+148}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error16.3
Cost1368
\[\begin{array}{l} t_0 := \frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{if}\;d \leq -2.3 \cdot 10^{-50}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 5.1 \cdot 10^{-17}:\\ \;\;\;\;\frac{b}{c} - \frac{\left(d \cdot a\right) \cdot \frac{1}{c}}{c}\\ \mathbf{elif}\;d \leq 3.7 \cdot 10^{+76}:\\ \;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+85}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 3 \cdot 10^{+114}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+148}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error16.1
Cost1368
\[\begin{array}{l} \mathbf{if}\;d \leq -2.3 \cdot 10^{-50}:\\ \;\;\;\;\frac{c \cdot \frac{b}{d} - d \cdot \frac{a}{d}}{d}\\ \mathbf{elif}\;d \leq 1.9 \cdot 10^{-17}:\\ \;\;\;\;\frac{b}{c} - \frac{\left(d \cdot a\right) \cdot \frac{1}{c}}{c}\\ \mathbf{elif}\;d \leq 4.4 \cdot 10^{+75}:\\ \;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;d \leq 6 \cdot 10^{+85}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;d \leq 2.9 \cdot 10^{+114}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{elif}\;d \leq 8.5 \cdot 10^{+148}:\\ \;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\ \end{array} \]
Alternative 10
Error20.4
Cost1104
\[\begin{array}{l} t_0 := \frac{-a}{d}\\ t_1 := \frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -1.95 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{+64}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 8 \cdot 10^{+152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.95 \cdot 10^{+183}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error16.5
Cost1104
\[\begin{array}{l} t_0 := \frac{b - d \cdot \frac{a}{c}}{c}\\ t_1 := \frac{b \cdot \frac{c}{d} - a}{d}\\ \mathbf{if}\;d \leq -2.3 \cdot 10^{-50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 0.15:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{+114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 9.5 \cdot 10^{+148}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error16.2
Cost1104
\[\begin{array}{l} t_0 := \frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -1.95 \cdot 10^{-55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{+63}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 8 \cdot 10^{+152}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.95 \cdot 10^{+183}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 13
Error16.2
Cost1104
\[\begin{array}{l} t_0 := \frac{b - d \cdot \frac{a}{c}}{c}\\ \mathbf{if}\;c \leq -1.95 \cdot 10^{-55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+62}:\\ \;\;\;\;\frac{\frac{b \cdot c}{d} - a}{d}\\ \mathbf{elif}\;c \leq 8 \cdot 10^{+152}:\\ \;\;\;\;\frac{b}{c} - d \cdot \frac{a}{c \cdot c}\\ \mathbf{elif}\;c \leq 1.95 \cdot 10^{+183}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 14
Error23.3
Cost520
\[\begin{array}{l} t_0 := \frac{-a}{d}\\ \mathbf{if}\;d \leq -1.12 \cdot 10^{-73}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 8.8 \cdot 10^{-16}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 15
Error55.5
Cost456
\[\begin{array}{l} \mathbf{if}\;d \leq -1 \cdot 10^{+169}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{elif}\;d \leq 3.7 \cdot 10^{+190}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{d}\\ \end{array} \]
Alternative 16
Error35.0
Cost456
\[\begin{array}{l} \mathbf{if}\;d \leq -9.6 \cdot 10^{+169}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{elif}\;d \leq 4.5 \cdot 10^{+168}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{d}\\ \end{array} \]
Alternative 17
Error58.8
Cost192
\[\frac{a}{c} \]

Error

Reproduce

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