Average Error: 32.1 → 0.0
Time: 12.5s
Precision: binary64
Cost: 27584
\[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
\[\begin{array}{l} t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\ t_1 := \frac{x}{t_0}\\ \left(t_1 + \frac{y \cdot 2}{t_0}\right) \cdot \left(t_1 + \frac{y \cdot -2}{t_0}\right) \end{array} \]
(FPCore (x y)
 :precision binary64
 (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (hypot x (* y 2.0))) (t_1 (/ x t_0)))
   (* (+ t_1 (/ (* y 2.0) t_0)) (+ t_1 (/ (* y -2.0) t_0)))))
double code(double x, double y) {
	return ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y));
}
double code(double x, double y) {
	double t_0 = hypot(x, (y * 2.0));
	double t_1 = x / t_0;
	return (t_1 + ((y * 2.0) / t_0)) * (t_1 + ((y * -2.0) / t_0));
}
public static double code(double x, double y) {
	return ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y));
}
public static double code(double x, double y) {
	double t_0 = Math.hypot(x, (y * 2.0));
	double t_1 = x / t_0;
	return (t_1 + ((y * 2.0) / t_0)) * (t_1 + ((y * -2.0) / t_0));
}
def code(x, y):
	return ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y))
def code(x, y):
	t_0 = math.hypot(x, (y * 2.0))
	t_1 = x / t_0
	return (t_1 + ((y * 2.0) / t_0)) * (t_1 + ((y * -2.0) / t_0))
function code(x, y)
	return Float64(Float64(Float64(x * x) - Float64(Float64(y * 4.0) * y)) / Float64(Float64(x * x) + Float64(Float64(y * 4.0) * y)))
end
function code(x, y)
	t_0 = hypot(x, Float64(y * 2.0))
	t_1 = Float64(x / t_0)
	return Float64(Float64(t_1 + Float64(Float64(y * 2.0) / t_0)) * Float64(t_1 + Float64(Float64(y * -2.0) / t_0)))
end
function tmp = code(x, y)
	tmp = ((x * x) - ((y * 4.0) * y)) / ((x * x) + ((y * 4.0) * y));
end
function tmp = code(x, y)
	t_0 = hypot(x, (y * 2.0));
	t_1 = x / t_0;
	tmp = (t_1 + ((y * 2.0) / t_0)) * (t_1 + ((y * -2.0) / t_0));
end
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[(y * 2.0), $MachinePrecision] ^ 2], $MachinePrecision]}, Block[{t$95$1 = N[(x / t$95$0), $MachinePrecision]}, N[(N[(t$95$1 + N[(N[(y * 2.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[(N[(y * -2.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\
t_1 := \frac{x}{t_0}\\
\left(t_1 + \frac{y \cdot 2}{t_0}\right) \cdot \left(t_1 + \frac{y \cdot -2}{t_0}\right)
\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original32.1
Target31.8
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} < 0.9743233849626781:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot y\right) \cdot 4} - \frac{\left(y \cdot y\right) \cdot 4}{x \cdot x + \left(y \cdot y\right) \cdot 4}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{x}{\sqrt{x \cdot x + \left(y \cdot y\right) \cdot 4}}\right)}^{2} - \frac{\left(y \cdot y\right) \cdot 4}{x \cdot x + \left(y \cdot y\right) \cdot 4}\\ \end{array} \]

Derivation

  1. Initial program 32.1

    \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \]
  2. Applied egg-rr31.8

    \[\leadsto \color{blue}{\frac{x \cdot x}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} - \frac{y \cdot 4}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)} \cdot y} \]
  3. Applied egg-rr0.0

    \[\leadsto \color{blue}{\left(\frac{x}{\mathsf{hypot}\left(x, y \cdot 2\right)} + \frac{y \cdot 2}{\mathsf{hypot}\left(x, y \cdot 2\right)}\right) \cdot \left(\frac{x}{\mathsf{hypot}\left(x, y \cdot 2\right)} - \frac{y \cdot 2}{\mathsf{hypot}\left(x, y \cdot 2\right)}\right)} \]
  4. Final simplification0.0

    \[\leadsto \left(\frac{x}{\mathsf{hypot}\left(x, y \cdot 2\right)} + \frac{y \cdot 2}{\mathsf{hypot}\left(x, y \cdot 2\right)}\right) \cdot \left(\frac{x}{\mathsf{hypot}\left(x, y \cdot 2\right)} + \frac{y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)}\right) \]

Alternatives

Alternative 1
Error0.2
Cost20992
\[\begin{array}{l} t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\ \left(\frac{x}{t_0} + \frac{y \cdot 2}{t_0}\right) \cdot \left(\frac{1}{t_0} \cdot \left(x - y \cdot 2\right)\right) \end{array} \]
Alternative 2
Error0.2
Cost20864
\[\begin{array}{l} t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\ \frac{1}{t_0} \cdot \left(\frac{x}{\frac{t_0}{x}} - \frac{y}{\frac{t_0}{y \cdot 4}}\right) \end{array} \]
Alternative 3
Error0.2
Cost14272
\[\begin{array}{l} t_0 := \mathsf{hypot}\left(x, y \cdot 2\right)\\ \frac{\left(x - y \cdot 2\right) \cdot \left(\frac{1}{t_0} \cdot \left(x + y \cdot 2\right)\right)}{t_0} \end{array} \]
Alternative 4
Error12.1
Cost8008
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-241}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+271}:\\ \;\;\;\;\frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{\mathsf{fma}\left(x, x, y \cdot \left(y \cdot 4\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\ \end{array} \]
Alternative 5
Error12.1
Cost7496
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 10^{-241}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 4 \cdot 10^{+271}:\\ \;\;\;\;\frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{x} \cdot \frac{y}{x}, -8, 1\right)\\ \end{array} \]
Alternative 6
Error12.7
Cost7372
\[\begin{array}{l} t_0 := \frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ t_1 := 1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \mathbf{if}\;x \leq -7.8 \cdot 10^{+135}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{-121}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x}{y} \cdot \frac{x}{y}, -1\right)\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{+102}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error12.7
Cost1744
\[\begin{array}{l} t_0 := \frac{x \cdot x + y \cdot \left(y \cdot -4\right)}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ t_1 := 1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \mathbf{if}\;x \leq -2.65 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-54}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-121}:\\ \;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y \cdot 4}\\ \mathbf{elif}\;x \leq 1.12 \cdot 10^{+103}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error16.3
Cost969
\[\begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+42} \lor \neg \left(x \leq 1.65 \cdot 10^{-12}\right):\\ \;\;\;\;1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 9
Error16.0
Cost969
\[\begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{+42} \lor \neg \left(x \leq 31000\right):\\ \;\;\;\;1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \mathbf{else}:\\ \;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y \cdot 4}\\ \end{array} \]
Alternative 10
Error16.6
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -8.8 \cdot 10^{+43}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-12}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error31.7
Cost64
\[-1 \]

Error

Reproduce

herbie shell --seed 2022343 
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))

  (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))