?

Average Error: 26.6 → 14.7
Time: 16.0s
Precision: binary64
Cost: 7568

?

\[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d} \]
\[\begin{array}{l} t_0 := a \cdot c + b \cdot d\\ t_1 := \frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\ t_2 := c \cdot c + d \cdot d\\ \mathbf{if}\;c \leq -7.5 \cdot 10^{+63}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -6.9 \cdot 10^{-143}:\\ \;\;\;\;\frac{t_0}{t_2}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-125}:\\ \;\;\;\;\frac{b}{d} + c \cdot \frac{a}{{d}^{2}}\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+91}:\\ \;\;\;\;\frac{1}{t_2} \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (+ (* a c) (* b d)))
        (t_1 (+ (/ a c) (* d (/ b (pow c 2.0)))))
        (t_2 (+ (* c c) (* d d))))
   (if (<= c -7.5e+63)
     t_1
     (if (<= c -6.9e-143)
       (/ t_0 t_2)
       (if (<= c 1.2e-125)
         (+ (/ b d) (* c (/ a (pow d 2.0))))
         (if (<= c 5.5e+91) (* (/ 1.0 t_2) t_0) t_1))))))
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 = (a * c) + (b * d);
	double t_1 = (a / c) + (d * (b / pow(c, 2.0)));
	double t_2 = (c * c) + (d * d);
	double tmp;
	if (c <= -7.5e+63) {
		tmp = t_1;
	} else if (c <= -6.9e-143) {
		tmp = t_0 / t_2;
	} else if (c <= 1.2e-125) {
		tmp = (b / d) + (c * (a / pow(d, 2.0)));
	} else if (c <= 5.5e+91) {
		tmp = (1.0 / t_2) * t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = (a * c) + (b * d)
    t_1 = (a / c) + (d * (b / (c ** 2.0d0)))
    t_2 = (c * c) + (d * d)
    if (c <= (-7.5d+63)) then
        tmp = t_1
    else if (c <= (-6.9d-143)) then
        tmp = t_0 / t_2
    else if (c <= 1.2d-125) then
        tmp = (b / d) + (c * (a / (d ** 2.0d0)))
    else if (c <= 5.5d+91) then
        tmp = (1.0d0 / t_2) * t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
public static double code(double a, double b, double c, double d) {
	double t_0 = (a * c) + (b * d);
	double t_1 = (a / c) + (d * (b / Math.pow(c, 2.0)));
	double t_2 = (c * c) + (d * d);
	double tmp;
	if (c <= -7.5e+63) {
		tmp = t_1;
	} else if (c <= -6.9e-143) {
		tmp = t_0 / t_2;
	} else if (c <= 1.2e-125) {
		tmp = (b / d) + (c * (a / Math.pow(d, 2.0)));
	} else if (c <= 5.5e+91) {
		tmp = (1.0 / t_2) * t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(a, b, c, d):
	return ((a * c) + (b * d)) / ((c * c) + (d * d))
def code(a, b, c, d):
	t_0 = (a * c) + (b * d)
	t_1 = (a / c) + (d * (b / math.pow(c, 2.0)))
	t_2 = (c * c) + (d * d)
	tmp = 0
	if c <= -7.5e+63:
		tmp = t_1
	elif c <= -6.9e-143:
		tmp = t_0 / t_2
	elif c <= 1.2e-125:
		tmp = (b / d) + (c * (a / math.pow(d, 2.0)))
	elif c <= 5.5e+91:
		tmp = (1.0 / t_2) * t_0
	else:
		tmp = t_1
	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(a * c) + Float64(b * d))
	t_1 = Float64(Float64(a / c) + Float64(d * Float64(b / (c ^ 2.0))))
	t_2 = Float64(Float64(c * c) + Float64(d * d))
	tmp = 0.0
	if (c <= -7.5e+63)
		tmp = t_1;
	elseif (c <= -6.9e-143)
		tmp = Float64(t_0 / t_2);
	elseif (c <= 1.2e-125)
		tmp = Float64(Float64(b / d) + Float64(c * Float64(a / (d ^ 2.0))));
	elseif (c <= 5.5e+91)
		tmp = Float64(Float64(1.0 / t_2) * t_0);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(a, b, c, d)
	tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
end
function tmp_2 = code(a, b, c, d)
	t_0 = (a * c) + (b * d);
	t_1 = (a / c) + (d * (b / (c ^ 2.0)));
	t_2 = (c * c) + (d * d);
	tmp = 0.0;
	if (c <= -7.5e+63)
		tmp = t_1;
	elseif (c <= -6.9e-143)
		tmp = t_0 / t_2;
	elseif (c <= 1.2e-125)
		tmp = (b / d) + (c * (a / (d ^ 2.0)));
	elseif (c <= 5.5e+91)
		tmp = (1.0 / t_2) * t_0;
	else
		tmp = t_1;
	end
	tmp_2 = 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[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(d * N[(b / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -7.5e+63], t$95$1, If[LessEqual[c, -6.9e-143], N[(t$95$0 / t$95$2), $MachinePrecision], If[LessEqual[c, 1.2e-125], N[(N[(b / d), $MachinePrecision] + N[(c * N[(a / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.5e+91], N[(N[(1.0 / t$95$2), $MachinePrecision] * t$95$0), $MachinePrecision], t$95$1]]]]]]]
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
t_1 := \frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\
t_2 := c \cdot c + d \cdot d\\
\mathbf{if}\;c \leq -7.5 \cdot 10^{+63}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \leq -6.9 \cdot 10^{-143}:\\
\;\;\;\;\frac{t_0}{t_2}\\

\mathbf{elif}\;c \leq 1.2 \cdot 10^{-125}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{{d}^{2}}\\

\mathbf{elif}\;c \leq 5.5 \cdot 10^{+91}:\\
\;\;\;\;\frac{1}{t_2} \cdot t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.6
Target0.5
Herbie14.7
\[\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 c < -7.5000000000000005e63 or 5.4999999999999998e91 < c

    1. Initial program 38.2

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

      \[\leadsto \color{blue}{\frac{a}{c} + \frac{d \cdot b}{{c}^{2}}} \]
    3. Simplified15.0

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

      [Start]16.6

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

      rational.json-simplify-2 [<=]16.6

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

      rational.json-simplify-49 [=>]15.0

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

    if -7.5000000000000005e63 < c < -6.89999999999999989e-143

    1. Initial program 13.9

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

    if -6.89999999999999989e-143 < c < 1.2000000000000001e-125

    1. Initial program 24.0

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

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

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

      [Start]10.3

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

      rational.json-simplify-2 [<=]10.3

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

      rational.json-simplify-49 [=>]14.2

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

    if 1.2000000000000001e-125 < c < 5.4999999999999998e91

    1. Initial program 15.6

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

      \[\leadsto \color{blue}{\frac{1}{c \cdot c + d \cdot d} \cdot \left(a \cdot c + b \cdot d\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification14.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -7.5 \cdot 10^{+63}:\\ \;\;\;\;\frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\ \mathbf{elif}\;c \leq -6.9 \cdot 10^{-143}:\\ \;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-125}:\\ \;\;\;\;\frac{b}{d} + c \cdot \frac{a}{{d}^{2}}\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+91}:\\ \;\;\;\;\frac{1}{c \cdot c + d \cdot d} \cdot \left(a \cdot c + b \cdot d\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\ \end{array} \]

Alternatives

Alternative 1
Error15.1
Cost7568
\[\begin{array}{l} t_0 := a \cdot c + b \cdot d\\ t_1 := \frac{a}{c} + d \cdot \frac{b}{{c}^{2}}\\ t_2 := c \cdot c + d \cdot d\\ \mathbf{if}\;c \leq -8.5 \cdot 10^{+63}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -6.9 \cdot 10^{-143}:\\ \;\;\;\;\frac{t_0}{t_2}\\ \mathbf{elif}\;c \leq 2.9 \cdot 10^{-125}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 4.9 \cdot 10^{+92}:\\ \;\;\;\;\frac{1}{t_2} \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error22.7
Cost1892
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{c}{t_0} \cdot a\\ \mathbf{if}\;c \leq -1.25 \cdot 10^{+47}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -2.25 \cdot 10^{+29}:\\ \;\;\;\;\frac{b}{t_0} \cdot d\\ \mathbf{elif}\;c \leq -0.43:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.9 \cdot 10^{-40}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq -9.5 \cdot 10^{-120}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-122}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 2.9 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 850000:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 8.5 \cdot 10^{+151}:\\ \;\;\;\;\frac{a}{t_0} \cdot c\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 3
Error22.6
Cost1892
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{c}{t_0} \cdot a\\ \mathbf{if}\;c \leq -1.35 \cdot 10^{+47}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -2.1 \cdot 10^{+29}:\\ \;\;\;\;\frac{b}{t_0} \cdot d\\ \mathbf{elif}\;c \leq -0.24:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -5.8 \cdot 10^{-41}:\\ \;\;\;\;\frac{d}{t_0} \cdot b\\ \mathbf{elif}\;c \leq -3.85 \cdot 10^{-118}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-122}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 2.65 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 240000:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 8.5 \cdot 10^{+151}:\\ \;\;\;\;\frac{a}{t_0} \cdot c\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 4
Error22.7
Cost1892
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{a}{\frac{t_0}{c}}\\ \mathbf{if}\;c \leq -3.5 \cdot 10^{+47}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -2.25 \cdot 10^{+29}:\\ \;\;\;\;\frac{b}{t_0} \cdot d\\ \mathbf{elif}\;c \leq -0.85:\\ \;\;\;\;\frac{c}{t_0} \cdot a\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-40}:\\ \;\;\;\;\frac{d}{t_0} \cdot b\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-122}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 370000:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 8.5 \cdot 10^{+152}:\\ \;\;\;\;\frac{a}{t_0} \cdot c\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 5
Error22.7
Cost1892
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{b}{\frac{t_0}{d}}\\ t_2 := \frac{a}{\frac{t_0}{c}}\\ \mathbf{if}\;c \leq -1.25 \cdot 10^{+47}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -2.25 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -0.23:\\ \;\;\;\;\frac{c}{t_0} \cdot a\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -4.9 \cdot 10^{-119}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-122}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{-65}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 860000:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 9 \cdot 10^{+151}:\\ \;\;\;\;\frac{a}{t_0} \cdot c\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 6
Error22.7
Cost1892
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{b}{\frac{t_0}{d}}\\ \mathbf{if}\;c \leq -2.05 \cdot 10^{+45}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -1.95 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -9.5:\\ \;\;\;\;\frac{c}{t_0} \cdot a\\ \mathbf{elif}\;c \leq -9 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-119}:\\ \;\;\;\;\frac{a}{\frac{t_0}{c}}\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{-123}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{-65}:\\ \;\;\;\;\frac{c \cdot a}{t_0}\\ \mathbf{elif}\;c \leq 350000:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 8.5 \cdot 10^{+151}:\\ \;\;\;\;\frac{a}{t_0} \cdot c\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 7
Error22.7
Cost1892
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{b}{\frac{t_0}{d}}\\ \mathbf{if}\;c \leq -2.6 \cdot 10^{+45}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -2.9 \cdot 10^{+28}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -0.25:\\ \;\;\;\;\frac{c}{t_0} \cdot a\\ \mathbf{elif}\;c \leq -1.65 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.85 \cdot 10^{-118}:\\ \;\;\;\;\frac{a}{\frac{t_0}{c}}\\ \mathbf{elif}\;c \leq 1.06 \cdot 10^{-122}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{-65}:\\ \;\;\;\;\frac{1}{t_0} \cdot \left(c \cdot a\right)\\ \mathbf{elif}\;c \leq 300000:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{+152}:\\ \;\;\;\;\frac{a}{t_0} \cdot c\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 8
Error23.9
Cost1628
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := \frac{a}{t_0} \cdot c\\ \mathbf{if}\;c \leq -2.8 \cdot 10^{+46}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -7.4 \cdot 10^{+28}:\\ \;\;\;\;\frac{b}{t_0} \cdot d\\ \mathbf{elif}\;c \leq -5.7:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -4.4 \cdot 10^{-41}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq -3.85 \cdot 10^{-118}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-111}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{+76}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 9
Error16.0
Cost1616
\[\begin{array}{l} t_0 := c \cdot c + d \cdot d\\ t_1 := a \cdot c + b \cdot d\\ \mathbf{if}\;c \leq -5.7 \cdot 10^{+118}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -6.5 \cdot 10^{-148}:\\ \;\;\;\;\frac{t_1}{t_0}\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{-126}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 1.55 \cdot 10^{+95}:\\ \;\;\;\;\frac{1}{t_0} \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 10
Error16.0
Cost1488
\[\begin{array}{l} t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{if}\;c \leq -3.9 \cdot 10^{+117}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq -3.6 \cdot 10^{-145}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 1.4 \cdot 10^{-124}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{+90}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 11
Error23.9
Cost1100
\[\begin{array}{l} \mathbf{if}\;c \leq -3.5 \cdot 10^{+47}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-111}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{-65}:\\ \;\;\;\;\frac{a}{c \cdot c + d \cdot d} \cdot c\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{+76}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 12
Error23.8
Cost720
\[\begin{array}{l} \mathbf{if}\;d \leq -2.2 \cdot 10^{+52}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{-43}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;d \leq 1.8 \cdot 10^{-15}:\\ \;\;\;\;\frac{b}{d}\\ \mathbf{elif}\;d \leq 1.85 \cdot 10^{+43}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{d}\\ \end{array} \]
Alternative 13
Error37.1
Cost192
\[\frac{a}{c} \]

Error

Reproduce?

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