?

Average Accuracy: 55.3% → 76.4%
Time: 15.1s
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)} \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{if}\;d \leq -2.7 \cdot 10^{+58}:\\ \;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{elif}\;d \leq -9.5 \cdot 10^{-224}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq -3.4 \cdot 10^{-299}:\\ \;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{\frac{d \cdot d}{a}}\\ \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)) (/ (fma a c (* d b)) (hypot c d)))))
   (if (<= d -2.7e+58)
     (* (/ d (hypot d c)) (/ b (hypot d c)))
     (if (<= d -9.5e-224)
       t_0
       (if (<= d -3.4e-299)
         (/ (+ a (/ b (/ c d))) c)
         (if (<= d 9.2e+76) t_0 (+ (/ b d) (/ c (/ (* d d) a)))))))))
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)) * (fma(a, c, (d * b)) / hypot(c, d));
	double tmp;
	if (d <= -2.7e+58) {
		tmp = (d / hypot(d, c)) * (b / hypot(d, c));
	} else if (d <= -9.5e-224) {
		tmp = t_0;
	} else if (d <= -3.4e-299) {
		tmp = (a + (b / (c / d))) / c;
	} else if (d <= 9.2e+76) {
		tmp = t_0;
	} else {
		tmp = (b / d) + (c / ((d * d) / a));
	}
	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(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(d * b)) / hypot(c, d)))
	tmp = 0.0
	if (d <= -2.7e+58)
		tmp = Float64(Float64(d / hypot(d, c)) * Float64(b / hypot(d, c)));
	elseif (d <= -9.5e-224)
		tmp = t_0;
	elseif (d <= -3.4e-299)
		tmp = Float64(Float64(a + Float64(b / Float64(c / d))) / c);
	elseif (d <= 9.2e+76)
		tmp = t_0;
	else
		tmp = Float64(Float64(b / d) + Float64(c / Float64(Float64(d * d) / a)));
	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[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(d * b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.7e+58], N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -9.5e-224], t$95$0, If[LessEqual[d, -3.4e-299], N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 9.2e+76], t$95$0, N[(N[(b / d), $MachinePrecision] + N[(c / N[(N[(d * d), $MachinePrecision] / a), $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)} \cdot \frac{\mathsf{fma}\left(a, c, d \cdot b\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -2.7 \cdot 10^{+58}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\

\mathbf{elif}\;d \leq -9.5 \cdot 10^{-224}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;d \leq -3.4 \cdot 10^{-299}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{c}\\

\mathbf{elif}\;d \leq 9.2 \cdot 10^{+76}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Target

Original55.3%
Target93.7%
Herbie76.4%
\[\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 d < -2.7000000000000001e58

    1. Initial program 36.4%

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

      \[\leadsto \frac{\color{blue}{d \cdot b}}{c \cdot c + d \cdot d} \]
    3. Applied egg-rr82.4%

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

      [Start]35.0

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

      add-sqr-sqrt [=>]35.0

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

      times-frac [=>]48.6

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

      +-commutative [=>]48.6

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

      hypot-def [=>]48.6

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

      +-commutative [=>]48.6

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

      hypot-def [=>]82.4

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

    if -2.7000000000000001e58 < d < -9.5000000000000003e-224 or -3.3999999999999998e-299 < d < 9.20000000000000005e76

    1. Initial program 73.5%

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

      \[\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)}} \]
      Step-by-step derivation

      [Start]73.5

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

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

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

      add-sqr-sqrt [=>]73.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 [=>]73.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 [=>]73.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 [=>]73.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 [=>]84.8

      \[ \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 -9.5000000000000003e-224 < d < -3.3999999999999998e-299

    1. Initial program 55.0%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Simplified55.0%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      Step-by-step derivation

      [Start]55.0

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

      fma-def [=>]55.0

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

      fma-def [=>]55.0

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

      \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{{c}^{2}}} \]
    4. Simplified55.0%

      \[\leadsto \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{c \cdot c}} \]
      Step-by-step derivation

      [Start]55.0

      \[ \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{{c}^{2}} \]

      unpow2 [=>]55.0

      \[ \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\color{blue}{c \cdot c}} \]
    5. Applied egg-rr57.9%

      \[\leadsto \color{blue}{0 + \mathsf{fma}\left(a, c, b \cdot d\right) \cdot {c}^{-2}} \]
      Step-by-step derivation

      [Start]55.0

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

      add-log-exp [=>]6.1

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

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

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

      log-prod [=>]6.1

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

      metadata-eval [=>]6.1

      \[ \color{blue}{0} + \log \left(e^{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{c \cdot c}}\right) \]

      add-log-exp [<=]55.0

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

      div-inv [=>]54.8

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

      pow2 [=>]54.8

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

      pow-flip [=>]57.9

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

      metadata-eval [=>]57.9

      \[ 0 + \mathsf{fma}\left(a, c, b \cdot d\right) \cdot {c}^{\color{blue}{-2}} \]
    6. Simplified89.9%

      \[\leadsto \color{blue}{\frac{a + \frac{b}{\frac{c}{d}}}{c}} \]
      Step-by-step derivation

      [Start]57.9

      \[ 0 + \mathsf{fma}\left(a, c, b \cdot d\right) \cdot {c}^{-2} \]

      +-lft-identity [=>]57.9

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

      *-commutative [<=]57.9

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

      metadata-eval [<=]57.9

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

      pow-sqr [<=]57.7

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

      unpow-1 [=>]57.7

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

      unpow-1 [=>]57.7

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

      associate-*l* [=>]64.5

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

      associate-*l/ [=>]64.7

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

      *-lft-identity [=>]64.7

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

      associate-*l/ [=>]65.1

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

      associate-*r/ [=>]65.1

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

      associate-*l/ [<=]65.0

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

      fma-udef [=>]65.0

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

      *-commutative [<=]65.0

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

      distribute-rgt-in [=>]65.0

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

      associate-*l* [=>]89.8

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

      rgt-mult-inverse [=>]89.9

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

      *-rgt-identity [=>]89.9

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

      associate-*r/ [=>]89.9

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

      *-rgt-identity [=>]89.9

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

      *-commutative [=>]89.9

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

      associate-/l* [=>]89.9

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

    if 9.20000000000000005e76 < d

    1. Initial program 46.7%

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
    2. Simplified46.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}} \]
      Step-by-step derivation

      [Start]46.7

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

      fma-def [=>]46.7

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

      fma-def [=>]46.7

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

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

      \[\leadsto \color{blue}{\frac{b}{d} + \frac{c}{\frac{d \cdot d}{a}}} \]
      Step-by-step derivation

      [Start]79.6

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

      unpow2 [=>]79.6

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

      associate-/l* [=>]85.1

      \[ \frac{b}{d} + \color{blue}{\frac{c}{\frac{d \cdot d}{a}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification84.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \leq -2.7 \cdot 10^{+58}:\\ \;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{elif}\;d \leq -9.5 \cdot 10^{-224}:\\ \;\;\;\;\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}\;d \leq -3.4 \cdot 10^{-299}:\\ \;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{+76}:\\ \;\;\;\;\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{b}{d} + \frac{c}{\frac{d \cdot d}{a}}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy72.8%
Cost20700
\[\begin{array}{l} t_0 := \mathsf{fma}\left(d, b, c \cdot a\right) \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\ t_1 := \frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{if}\;d \leq -3.5 \cdot 10^{+48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -1.45 \cdot 10^{-37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 7 \cdot 10^{-140}:\\ \;\;\;\;\left(a + \frac{d \cdot b}{c}\right) \cdot \frac{1}{c}\\ \mathbf{elif}\;d \leq 7 \cdot 10^{-66}:\\ \;\;\;\;\frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{elif}\;d \leq 9 \cdot 10^{-13}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{d}{c}}{\frac{c}{b}}\\ \mathbf{elif}\;d \leq 1.5 \cdot 10^{+34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 9.2 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{\frac{d \cdot d}{a}}\\ \end{array} \]
Alternative 2
Accuracy72.7%
Cost14168
\[\begin{array}{l} t_0 := \frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ t_1 := \frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\ \mathbf{if}\;d \leq -1.45 \cdot 10^{+48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -1.45 \cdot 10^{-37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 1.56 \cdot 10^{-139}:\\ \;\;\;\;\left(a + \frac{d \cdot b}{c}\right) \cdot \frac{1}{c}\\ \mathbf{elif}\;d \leq 1.05 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 2.15 \cdot 10^{-13}:\\ \;\;\;\;\frac{a}{c} + \frac{\frac{d}{c}}{\frac{c}{b}}\\ \mathbf{elif}\;d \leq 8.6 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 9 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{\frac{d \cdot d}{a}}\\ \end{array} \]
Alternative 3
Accuracy76.0%
Cost1488
\[\begin{array}{l} t_0 := \frac{d \cdot b + c \cdot a}{d \cdot d + c \cdot c}\\ \mathbf{if}\;c \leq -8 \cdot 10^{+85}:\\ \;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{c}\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-162}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-156}:\\ \;\;\;\;\frac{b + \frac{c \cdot a}{d}}{d}\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{+46}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]
Alternative 4
Accuracy71.0%
Cost1232
\[\begin{array}{l} t_0 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\ \mathbf{if}\;c \leq -3.8 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -3.7 \cdot 10^{+21}:\\ \;\;\;\;\frac{b + \frac{c}{\frac{d}{a}}}{d}\\ \mathbf{elif}\;c \leq -1.85 \cdot 10^{-44}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 5.6 \cdot 10^{+58}:\\ \;\;\;\;\frac{b + \frac{c \cdot a}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]
Alternative 5
Accuracy70.9%
Cost1232
\[\begin{array}{l} t_0 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\ \mathbf{if}\;c \leq -4.8 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -2.25 \cdot 10^{+21}:\\ \;\;\;\;\frac{b}{d} + \frac{c}{\frac{d}{\frac{a}{d}}}\\ \mathbf{elif}\;c \leq -7.5 \cdot 10^{-46}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 5.6 \cdot 10^{+55}:\\ \;\;\;\;\frac{b + \frac{c \cdot a}{d}}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\ \end{array} \]
Alternative 6
Accuracy70.3%
Cost1106
\[\begin{array}{l} \mathbf{if}\;c \leq -2.8 \cdot 10^{+68} \lor \neg \left(c \leq -3.7 \cdot 10^{+19} \lor \neg \left(c \leq -2.9 \cdot 10^{-46}\right) \land c \leq 4.2 \cdot 10^{+57}\right):\\ \;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + \frac{c}{\frac{d}{a}}}{d}\\ \end{array} \]
Alternative 7
Accuracy70.7%
Cost1105
\[\begin{array}{l} t_0 := \frac{a + \frac{b}{\frac{c}{d}}}{c}\\ \mathbf{if}\;c \leq -3.8 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -2.8 \cdot 10^{+21}:\\ \;\;\;\;\frac{b + \frac{c}{\frac{d}{a}}}{d}\\ \mathbf{elif}\;c \leq -2.7 \cdot 10^{-47} \lor \neg \left(c \leq 4.7 \cdot 10^{+55}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{b + \frac{c \cdot a}{d}}{d}\\ \end{array} \]
Alternative 8
Accuracy66.3%
Cost841
\[\begin{array}{l} \mathbf{if}\;d \leq -2.2 \cdot 10^{-28} \lor \neg \left(d \leq 9.2 \cdot 10^{-13}\right):\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{c}\\ \end{array} \]
Alternative 9
Accuracy60.7%
Cost456
\[\begin{array}{l} \mathbf{if}\;d \leq -1.35 \cdot 10^{-27}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 2.7 \cdot 10^{-12}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
Alternative 10
Accuracy39.1%
Cost192
\[\frac{a}{c} \]

Error

Reproduce?

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