Average Error: 26.2 → 1.0
Time: 15.5s
Precision: binary64
Cost: 26816
\[\left(\left(\left(-1.79 \cdot 10^{+308} \leq a \land a \leq 1.79 \cdot 10^{+308}\right) \land \left(-1.79 \cdot 10^{+308} \leq c \land c \leq 1.79 \cdot 10^{+308}\right)\right) \land \left(-1.79 \cdot 10^{+308} \leq b \land b \leq 1.79 \cdot 10^{+308}\right)\right) \land \left(-1.79 \cdot 10^{+308} \leq d \land d \leq 1.79 \cdot 10^{+308}\right)\]
\[\frac{a \cdot c - b \cdot d}{c \cdot c + d \cdot d} \]
\[\frac{\frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)} - \frac{\frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}}{\mathsf{hypot}\left(c, d\right)} \]
(FPCore (a c b d)
 :precision binary64
 (/ (- (* a c) (* b d)) (+ (* c c) (* d d))))
(FPCore (a c b d)
 :precision binary64
 (-
  (/ (/ a (/ (hypot c d) c)) (hypot c d))
  (/ (/ d (/ (hypot c d) b)) (hypot c d))))
double code(double a, double c, double b, double d) {
	return ((a * c) - (b * d)) / ((c * c) + (d * d));
}
double code(double a, double c, double b, double d) {
	return ((a / (hypot(c, d) / c)) / hypot(c, d)) - ((d / (hypot(c, d) / b)) / hypot(c, d));
}
public static double code(double a, double c, double b, double d) {
	return ((a * c) - (b * d)) / ((c * c) + (d * d));
}
public static double code(double a, double c, double b, double d) {
	return ((a / (Math.hypot(c, d) / c)) / Math.hypot(c, d)) - ((d / (Math.hypot(c, d) / b)) / Math.hypot(c, d));
}
def code(a, c, b, d):
	return ((a * c) - (b * d)) / ((c * c) + (d * d))
def code(a, c, b, d):
	return ((a / (math.hypot(c, d) / c)) / math.hypot(c, d)) - ((d / (math.hypot(c, d) / b)) / math.hypot(c, d))
function code(a, c, b, d)
	return Float64(Float64(Float64(a * c) - Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d)))
end
function code(a, c, b, d)
	return Float64(Float64(Float64(a / Float64(hypot(c, d) / c)) / hypot(c, d)) - Float64(Float64(d / Float64(hypot(c, d) / b)) / hypot(c, d)))
end
function tmp = code(a, c, b, d)
	tmp = ((a * c) - (b * d)) / ((c * c) + (d * d));
end
function tmp = code(a, c, b, d)
	tmp = ((a / (hypot(c, d) / c)) / hypot(c, d)) - ((d / (hypot(c, d) / b)) / hypot(c, d));
end
code[a_, c_, b_, 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_, c_, b_, d_] := N[(N[(N[(a / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] - N[(N[(d / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{a \cdot c - b \cdot d}{c \cdot c + d \cdot d}
\frac{\frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)} - \frac{\frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}}{\mathsf{hypot}\left(c, d\right)}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 26.2

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

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

    \[\leadsto \color{blue}{\frac{\frac{a}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}}{\mathsf{hypot}\left(c, d\right)} - \frac{\frac{d}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}}{\mathsf{hypot}\left(c, d\right)}} \]
  4. Final simplification1.0

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

Alternatives

Alternative 1
Error9.6
Cost14288
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := \frac{t_0}{\frac{\mathsf{hypot}\left(c, d\right)}{a \cdot c - d \cdot b}}\\ t_2 := \frac{c}{\frac{d}{a}}\\ \mathbf{if}\;d \leq -1.3027372499530742 \cdot 10^{+123}:\\ \;\;\;\;t_0 \cdot \left(b - t_2\right)\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 6.216280062894144 \cdot 10^{-112}:\\ \;\;\;\;\frac{a}{c} - \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 3.574730584504394 \cdot 10^{+82}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(t_2 - b\right)\\ \end{array} \]
Alternative 2
Error9.7
Cost14288
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := t_0 \cdot \frac{a \cdot c - d \cdot b}{\mathsf{hypot}\left(c, d\right)}\\ t_2 := \frac{c}{\frac{d}{a}}\\ \mathbf{if}\;d \leq -1.3027372499530742 \cdot 10^{+123}:\\ \;\;\;\;t_0 \cdot \left(b - t_2\right)\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq 5.239542721328399 \cdot 10^{-103}:\\ \;\;\;\;\frac{a}{c} - \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 3.574730584504394 \cdot 10^{+82}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(t_2 - b\right)\\ \end{array} \]
Alternative 3
Error14.3
Cost13508
\[\begin{array}{l} \mathbf{if}\;c \leq -1.262805334807822 \cdot 10^{+23}:\\ \;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -7.85730773862186 \cdot 10^{-116}:\\ \;\;\;\;\frac{a \cdot c - d \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 400634.2335095283:\\ \;\;\;\;\frac{c}{d} \cdot \frac{a}{d} - \frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - b \cdot \frac{d}{c}\right)\\ \end{array} \]
Alternative 4
Error15.3
Cost7564
\[\begin{array}{l} \mathbf{if}\;c \leq -9.918579807238071 \cdot 10^{+30}:\\ \;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\ \mathbf{elif}\;c \leq -7.85730773862186 \cdot 10^{-116}:\\ \;\;\;\;\frac{a \cdot c - d \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 400634.2335095283:\\ \;\;\;\;\frac{c}{d} \cdot \frac{a}{d} - \frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - b \cdot \frac{d}{c}\right)\\ \end{array} \]
Alternative 5
Error13.7
Cost7564
\[\begin{array}{l} t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\ t_1 := b \cdot \frac{d}{c}\\ \mathbf{if}\;c \leq -9.918579807238071 \cdot 10^{+30}:\\ \;\;\;\;t_0 \cdot \left(t_1 - a\right)\\ \mathbf{elif}\;c \leq -7.85730773862186 \cdot 10^{-116}:\\ \;\;\;\;\frac{a \cdot c - d \cdot b}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 400634.2335095283:\\ \;\;\;\;\frac{c}{d} \cdot \frac{a}{d} - \frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(a - t_1\right)\\ \end{array} \]
Alternative 6
Error12.5
Cost1488
\[\begin{array}{l} t_0 := \frac{a \cdot c - d \cdot b}{c \cdot c + d \cdot d}\\ t_1 := \frac{c}{d} \cdot \frac{a}{d} - \frac{b}{d}\\ \mathbf{if}\;d \leq -1.3027372499530742 \cdot 10^{+123}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;d \leq -1 \cdot 10^{-141}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;d \leq 7.705799657995719 \cdot 10^{-28}:\\ \;\;\;\;\frac{a}{c} - \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{elif}\;d \leq 3.574730584504394 \cdot 10^{+82}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error17.6
Cost1364
\[\begin{array}{l} t_0 := \frac{c}{d} \cdot \frac{a}{d} - \frac{b}{d}\\ t_1 := \frac{a}{c} - \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{if}\;c \leq -4.408223691069166 \cdot 10^{+77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.262805334807822 \cdot 10^{+23}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq -2.29671811471494 \cdot 10^{+19}:\\ \;\;\;\;b \cdot \frac{-d}{c \cdot c}\\ \mathbf{elif}\;c \leq -7.692170396406744 \cdot 10^{-76}:\\ \;\;\;\;\frac{a \cdot c}{c \cdot c + d \cdot d}\\ \mathbf{elif}\;c \leq 400634.2335095283:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error21.6
Cost968
\[\begin{array}{l} t_0 := \frac{a}{c} - d \cdot \frac{b}{c \cdot c}\\ \mathbf{if}\;c \leq -4.408223691069166 \cdot 10^{+77}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 3.1912948015618026 \cdot 10^{-44}:\\ \;\;\;\;\frac{-b}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error17.7
Cost968
\[\begin{array}{l} t_0 := \frac{a}{c} - d \cdot \frac{b}{c \cdot c}\\ \mathbf{if}\;c \leq -4.408223691069166 \cdot 10^{+77}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 400634.2335095283:\\ \;\;\;\;\frac{c}{d} \cdot \frac{a}{d} - \frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error17.5
Cost968
\[\begin{array}{l} t_0 := \frac{a}{c} - \frac{b}{c \cdot \frac{c}{d}}\\ \mathbf{if}\;c \leq -4.408223691069166 \cdot 10^{+77}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;c \leq 400634.2335095283:\\ \;\;\;\;\frac{c}{d} \cdot \frac{a}{d} - \frac{b}{d}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error23.2
Cost520
\[\begin{array}{l} \mathbf{if}\;c \leq -4.408223691069166 \cdot 10^{+77}:\\ \;\;\;\;\frac{a}{c}\\ \mathbf{elif}\;c \leq 400634.2335095283:\\ \;\;\;\;\frac{-b}{d}\\ \mathbf{else}:\\ \;\;\;\;\frac{a}{c}\\ \end{array} \]
Alternative 12
Error37.3
Cost192
\[\frac{a}{c} \]

Error

Reproduce

herbie shell --seed 1 
(FPCore (a c b d)
  :name "(a*c-b*d)/(c*c+d*d)"
  :precision binary64
  :pre (and (and (and (and (<= -1.79e+308 a) (<= a 1.79e+308)) (and (<= -1.79e+308 c) (<= c 1.79e+308))) (and (<= -1.79e+308 b) (<= b 1.79e+308))) (and (<= -1.79e+308 d) (<= d 1.79e+308)))
  (/ (- (* a c) (* b d)) (+ (* c c) (* d d))))