?

Average Accuracy: 58.4% → 83.4%
Time: 16.0s
Precision: binary64
Cost: 14160

?

\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
\[\begin{array}{l} t_0 := \frac{\frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;d \leq -5.6 \cdot 10^{+162}:\\ \;\;\;\;\frac{\frac{c}{\frac{d}{b}}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -5.8 \cdot 10^{-149}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{-158}:\\ \;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\ \mathbf{elif}\;d \leq 920000000000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\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 (/ (/ (- (* c b) (* d a)) (hypot c d)) (hypot c d))))
   (if (<= d -5.6e+162)
     (- (/ (/ c (/ d b)) d) (/ a d))
     (if (<= d -5.8e-149)
       t_0
       (if (<= d 3.1e-158)
         (/ (- b (/ d (/ c a))) c)
         (if (<= d 920000000000.0)
           t_0
           (/ (- (* b (/ c d)) a) (hypot c 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 = (((c * b) - (d * a)) / hypot(c, d)) / hypot(c, d);
	double tmp;
	if (d <= -5.6e+162) {
		tmp = ((c / (d / b)) / d) - (a / d);
	} else if (d <= -5.8e-149) {
		tmp = t_0;
	} else if (d <= 3.1e-158) {
		tmp = (b - (d / (c / a))) / c;
	} else if (d <= 920000000000.0) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / hypot(c, d);
	}
	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 = (((c * b) - (d * a)) / Math.hypot(c, d)) / Math.hypot(c, d);
	double tmp;
	if (d <= -5.6e+162) {
		tmp = ((c / (d / b)) / d) - (a / d);
	} else if (d <= -5.8e-149) {
		tmp = t_0;
	} else if (d <= 3.1e-158) {
		tmp = (b - (d / (c / a))) / c;
	} else if (d <= 920000000000.0) {
		tmp = t_0;
	} else {
		tmp = ((b * (c / d)) - a) / Math.hypot(c, d);
	}
	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 = (((c * b) - (d * a)) / math.hypot(c, d)) / math.hypot(c, d)
	tmp = 0
	if d <= -5.6e+162:
		tmp = ((c / (d / b)) / d) - (a / d)
	elif d <= -5.8e-149:
		tmp = t_0
	elif d <= 3.1e-158:
		tmp = (b - (d / (c / a))) / c
	elif d <= 920000000000.0:
		tmp = t_0
	else:
		tmp = ((b * (c / d)) - a) / math.hypot(c, 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(Float64(Float64(c * b) - Float64(d * a)) / hypot(c, d)) / hypot(c, d))
	tmp = 0.0
	if (d <= -5.6e+162)
		tmp = Float64(Float64(Float64(c / Float64(d / b)) / d) - Float64(a / d));
	elseif (d <= -5.8e-149)
		tmp = t_0;
	elseif (d <= 3.1e-158)
		tmp = Float64(Float64(b - Float64(d / Float64(c / a))) / c);
	elseif (d <= 920000000000.0)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / hypot(c, d));
	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 = (((c * b) - (d * a)) / hypot(c, d)) / hypot(c, d);
	tmp = 0.0;
	if (d <= -5.6e+162)
		tmp = ((c / (d / b)) / d) - (a / d);
	elseif (d <= -5.8e-149)
		tmp = t_0;
	elseif (d <= 3.1e-158)
		tmp = (b - (d / (c / a))) / c;
	elseif (d <= 920000000000.0)
		tmp = t_0;
	else
		tmp = ((b * (c / d)) - a) / hypot(c, d);
	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[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.6e+162], N[(N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.8e-149], t$95$0, If[LessEqual[d, 3.1e-158], N[(N[(b - N[(d / N[(c / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 920000000000.0], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\begin{array}{l}
t_0 := \frac{\frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -5.6 \cdot 10^{+162}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}}}{d} - \frac{a}{d}\\

\mathbf{elif}\;d \leq -5.8 \cdot 10^{-149}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;d \leq 920000000000:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original58.4%
Target99.3%
Herbie83.4%
\[\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 4 regimes
  2. if d < -5.59999999999999981e162

    1. Initial program 31.2%

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \]
    2. Applied egg-rr54.5%

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

      [Start]31.2

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

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

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

      add-sqr-sqrt [=>]31.2

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

      times-frac [=>]31.2

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

      hypot-def [=>]31.2

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

      hypot-def [=>]54.5

      \[ \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    3. Applied egg-rr54.6%

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

      [Start]54.5

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

      associate-*l/ [=>]54.6

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

      *-un-lft-identity [<=]54.6

      \[ \frac{\color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}}{\mathsf{hypot}\left(c, d\right)} \]
    4. Applied egg-rr54.2%

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

      [Start]54.6

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

      add-cube-cbrt [=>]54.2

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

      add-sqr-sqrt [=>]54.2

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

      times-frac [=>]54.2

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

      pow2 [=>]54.2

      \[ \frac{\frac{\color{blue}{{\left(\sqrt[3]{b \cdot c - a \cdot d}\right)}^{2}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{\sqrt[3]{b \cdot c - a \cdot d}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\mathsf{hypot}\left(c, d\right)} \]
    5. Simplified54.4%

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

      [Start]54.2

      \[ \frac{\frac{{\left(\sqrt[3]{b \cdot c - a \cdot d}\right)}^{2}}{\sqrt{\mathsf{hypot}\left(c, d\right)}} \cdot \frac{\sqrt[3]{b \cdot c - a \cdot d}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\mathsf{hypot}\left(c, d\right)} \]

      associate-*l/ [=>]54.2

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

      associate-*r/ [=>]54.2

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

      unpow2 [=>]54.2

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

      rem-3cbrt-lft [=>]54.4

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

      *-commutative [=>]54.4

      \[ \frac{\frac{\frac{\color{blue}{c \cdot b} - a \cdot d}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\sqrt{\mathsf{hypot}\left(c, d\right)}}}{\mathsf{hypot}\left(c, d\right)} \]
    6. Taylor expanded in c around 0 76.1%

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

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

      [Start]76.1

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

      +-commutative [=>]76.1

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

      mul-1-neg [=>]76.1

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

      unsub-neg [=>]76.1

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

      unpow2 [=>]76.1

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

      associate-/r* [=>]81.6

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

      associate-/l* [=>]89.4

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

    if -5.59999999999999981e162 < d < -5.8e-149 or 3.10000000000000018e-158 < d < 9.2e11

    1. Initial program 72.1%

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

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

      [Start]72.1

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

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

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

      add-sqr-sqrt [=>]72.1

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

      times-frac [=>]72.1

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

      hypot-def [=>]72.1

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

      hypot-def [=>]81.2

      \[ \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    3. Applied egg-rr81.4%

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

      [Start]81.2

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

      associate-*l/ [=>]81.4

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

      *-un-lft-identity [<=]81.4

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

    if -5.8e-149 < d < 3.10000000000000018e-158

    1. Initial program 62.7%

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

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

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

      [Start]83.9

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

      +-commutative [=>]83.9

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

      mul-1-neg [=>]83.9

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

      unsub-neg [=>]83.9

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

      unpow2 [=>]83.9

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

      times-frac [=>]87.4

      \[ \frac{b}{c} - \color{blue}{\frac{a}{c} \cdot \frac{d}{c}} \]
    4. Applied egg-rr81.5%

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

      [Start]87.4

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

      clear-num [=>]87.4

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

      frac-times [=>]81.5

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

      *-un-lft-identity [<=]81.5

      \[ \frac{b}{c} - \frac{\color{blue}{d}}{\frac{c}{a} \cdot c} \]
    5. Applied egg-rr88.9%

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

      [Start]81.5

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

      associate-/r* [=>]88.9

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

      sub-div [=>]88.9

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

    if 9.2e11 < d

    1. Initial program 47.1%

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

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

      [Start]47.1

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

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

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

      add-sqr-sqrt [=>]47.1

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

      times-frac [=>]47.1

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

      hypot-def [=>]47.1

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

      hypot-def [=>]61.6

      \[ \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b \cdot c - a \cdot d}{\color{blue}{\mathsf{hypot}\left(c, d\right)}} \]
    3. Applied egg-rr61.7%

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

      [Start]61.6

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

      associate-*l/ [=>]61.7

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

      *-un-lft-identity [<=]61.7

      \[ \frac{\color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{hypot}\left(c, d\right)}}}{\mathsf{hypot}\left(c, d\right)} \]
    4. Taylor expanded in c around 0 74.0%

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

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

      [Start]74.0

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

      mul-1-neg [=>]74.0

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

      unsub-neg [=>]74.0

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

      associate-/l* [=>]79.0

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

      associate-/r/ [=>]78.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -5.6 \cdot 10^{+162}:\\ \;\;\;\;\frac{\frac{c}{\frac{d}{b}}}{d} - \frac{a}{d}\\ \mathbf{elif}\;d \leq -5.8 \cdot 10^{-149}:\\ \;\;\;\;\frac{\frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;d \leq 3.1 \cdot 10^{-158}:\\ \;\;\;\;\frac{b - \frac{d}{\frac{c}{a}}}{c}\\ \mathbf{elif}\;d \leq 920000000000:\\ \;\;\;\;\frac{\frac{c \cdot b - d \cdot a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy77.2%
Cost1752
\[\begin{array}{l} t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\ t_1 := \frac{b - \frac{d}{\frac{c}{a}}}{c}\\ \mathbf{if}\;c \leq -4 \cdot 10^{+119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-129}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq -2.7 \cdot 10^{-183}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{d}{c}}{\frac{c}{a}}\\ \mathbf{elif}\;c \leq 6.2 \cdot 10^{-51}:\\ \;\;\;\;\frac{\frac{c}{\frac{d}{b}}}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq 5 \cdot 10^{+30}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 10^{+51}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Accuracy73.1%
Cost1232
\[\begin{array}{l} t_0 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ t_1 := \frac{b - \frac{d}{\frac{c}{a}}}{c}\\ \mathbf{if}\;c \leq -8.4 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-129}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -2.7 \cdot 10^{-183}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 1.02 \cdot 10^{+51}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy73.1%
Cost1232
\[\begin{array}{l} t_0 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ t_1 := \frac{b - \frac{d}{\frac{c}{a}}}{c}\\ \mathbf{if}\;c \leq -4.6 \cdot 10^{-26}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-129}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -2.7 \cdot 10^{-183}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{d}{c}}{\frac{c}{a}}\\ \mathbf{elif}\;c \leq 1.25 \cdot 10^{+57}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy73.3%
Cost1232
\[\begin{array}{l} t_0 := \frac{b - \frac{d}{\frac{c}{a}}}{c}\\ \mathbf{if}\;c \leq -1.45 \cdot 10^{-25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-129}:\\ \;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\ \mathbf{elif}\;c \leq -2.7 \cdot 10^{-183}:\\ \;\;\;\;\frac{b}{c} - \frac{\frac{d}{c}}{\frac{c}{a}}\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{+53}:\\ \;\;\;\;\frac{\frac{c}{\frac{d}{b}}}{d} - \frac{a}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Accuracy67.6%
Cost1106
\[\begin{array}{l} \mathbf{if}\;c \leq -3.1 \cdot 10^{-26} \lor \neg \left(c \leq -1.9 \cdot 10^{-129} \lor \neg \left(c \leq -2.7 \cdot 10^{-183}\right) \land c \leq 10^{+51}\right):\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{-a}{d}\\ \end{array} \]
Alternative 6
Accuracy67.9%
Cost1104
\[\begin{array}{l} t_0 := \frac{-a}{d}\\ t_1 := \frac{b - \frac{d}{\frac{c}{a}}}{c}\\ \mathbf{if}\;c \leq -2.25 \cdot 10^{-26}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-129}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -2.7 \cdot 10^{-183}:\\ \;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{+52}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Accuracy61.6%
Cost785
\[\begin{array}{l} \mathbf{if}\;c \leq -5.6 \cdot 10^{-26}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-129} \lor \neg \left(c \leq -2.7 \cdot 10^{-183}\right) \land c \leq 1.8 \cdot 10^{+55}:\\ \;\;\;\;\frac{-a}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{c}\\ \end{array} \]
Alternative 8
Accuracy45.5%
Cost456
\[\begin{array}{l} \mathbf{if}\;d \leq -8 \cdot 10^{+155}:\\ \;\;\;\;\frac{a}{d}\\ \mathbf{elif}\;d \leq 8.4 \cdot 10^{+228}:\\ \;\;\;\;\frac{b}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{d}\\ \end{array} \]
Alternative 9
Accuracy11.2%
Cost192
\[\frac{a}{d} \]

Error

Reproduce?

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