?

Average Accuracy: 50.2% → 99.9%
Time: 12.6s
Precision: binary64
Cost: 20864

?

\[\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, 2 \cdot y\right)\\ \frac{x + 2 \cdot y}{t_0} \cdot \left(\frac{x}{t_0} + \frac{y}{t_0} \cdot -2\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 (* 2.0 y))))
   (* (/ (+ x (* 2.0 y)) t_0) (+ (/ x t_0) (* (/ y t_0) -2.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, (2.0 * y));
	return ((x + (2.0 * y)) / t_0) * ((x / t_0) + ((y / t_0) * -2.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, (2.0 * y));
	return ((x + (2.0 * y)) / t_0) * ((x / t_0) + ((y / t_0) * -2.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, (2.0 * y))
	return ((x + (2.0 * y)) / t_0) * ((x / t_0) + ((y / t_0) * -2.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(2.0 * y))
	return Float64(Float64(Float64(x + Float64(2.0 * y)) / t_0) * Float64(Float64(x / t_0) + Float64(Float64(y / t_0) * -2.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, (2.0 * y));
	tmp = ((x + (2.0 * y)) / t_0) * ((x / t_0) + ((y / t_0) * -2.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[(2.0 * y), $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(N[(x + N[(2.0 * y), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] * N[(N[(x / t$95$0), $MachinePrecision] + N[(N[(y / t$95$0), $MachinePrecision] * -2.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, 2 \cdot y\right)\\
\frac{x + 2 \cdot y}{t_0} \cdot \left(\frac{x}{t_0} + \frac{y}{t_0} \cdot -2\right)
\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original50.2%
Target50.7%
Herbie99.9%
\[\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 50.2%

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

    \[\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-rr99.9%

    \[\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. Applied egg-rr99.6%

    \[\leadsto \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \left(x + y \cdot 2\right)\right) \cdot \frac{x}{\mathsf{hypot}\left(x, y \cdot 2\right)} + \left(\frac{1}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \left(x + y \cdot 2\right)\right) \cdot \frac{y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)}} \]
  5. Simplified99.9%

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

    [Start]99.6

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

    distribute-lft-out [=>]99.6

    \[ \color{blue}{\left(\frac{1}{\mathsf{hypot}\left(x, y \cdot 2\right)} \cdot \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)} \]

    *-rgt-identity [<=]99.6

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

    associate-*l/ [=>]99.9

    \[ \color{blue}{\frac{1 \cdot \left(x + y \cdot 2\right)}{\mathsf{hypot}\left(x, y \cdot 2\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)} \cdot 1\right) \]

    +-commutative [=>]99.9

    \[ \frac{1 \cdot \color{blue}{\left(y \cdot 2 + x\right)}}{\mathsf{hypot}\left(x, y \cdot 2\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)} \cdot 1\right) \]

    distribute-lft-in [=>]99.9

    \[ \frac{\color{blue}{1 \cdot \left(y \cdot 2\right) + 1 \cdot x}}{\mathsf{hypot}\left(x, y \cdot 2\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)} \cdot 1\right) \]

    *-commutative [=>]99.9

    \[ \frac{1 \cdot \color{blue}{\left(2 \cdot y\right)} + 1 \cdot x}{\mathsf{hypot}\left(x, y \cdot 2\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)} \cdot 1\right) \]

    associate-*r* [=>]99.9

    \[ \frac{\color{blue}{\left(1 \cdot 2\right) \cdot y} + 1 \cdot x}{\mathsf{hypot}\left(x, y \cdot 2\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)} \cdot 1\right) \]

    metadata-eval [=>]99.9

    \[ \frac{\color{blue}{2} \cdot y + 1 \cdot x}{\mathsf{hypot}\left(x, y \cdot 2\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)} \cdot 1\right) \]

    *-commutative [<=]99.9

    \[ \frac{2 \cdot y + \color{blue}{x \cdot 1}}{\mathsf{hypot}\left(x, y \cdot 2\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)} \cdot 1\right) \]

    *-commutative [=>]99.9

    \[ \frac{2 \cdot y + x \cdot 1}{\mathsf{hypot}\left(x, \color{blue}{2 \cdot y}\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)} \cdot 1\right) \]

    *-commutative [=>]99.9

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

    *-rgt-identity [=>]99.9

    \[ \frac{2 \cdot y + x \cdot 1}{\mathsf{hypot}\left(x, 2 \cdot y\right)} \cdot \left(\frac{x}{\mathsf{hypot}\left(x, 2 \cdot y\right)} + \color{blue}{\frac{y \cdot -2}{\mathsf{hypot}\left(x, y \cdot 2\right)}}\right) \]
  6. Final simplification99.9%

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

Alternatives

Alternative 1
Accuracy99.9%
Cost20544
\[\begin{array}{l} t_0 := \mathsf{hypot}\left(x, 2 \cdot y\right)\\ \frac{\left(x + y \cdot -2\right) \cdot \frac{1}{\frac{t_0}{\mathsf{fma}\left(y, 2, x\right)}}}{t_0} \end{array} \]
Alternative 2
Accuracy99.6%
Cost14272
\[\begin{array}{l} t_0 := \mathsf{hypot}\left(x, 2 \cdot y\right)\\ \frac{\left(x + y \cdot -2\right) \cdot \left(\frac{1}{t_0} \cdot \left(x + 2 \cdot y\right)\right)}{t_0} \end{array} \]
Alternative 3
Accuracy79.4%
Cost9048
\[\begin{array}{l} t_0 := x \cdot x + y \cdot \left(y \cdot -4\right)\\ t_1 := \frac{t_0}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-303}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x \cdot \frac{x}{y}}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-249}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-157}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot x \leq 10000000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+252}:\\ \;\;\;\;\frac{t_0}{\mathsf{fma}\left(y \cdot 4, y, x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-8, \frac{y}{x} \cdot \frac{y}{x}, 1\right)\\ \end{array} \]
Alternative 4
Accuracy79.3%
Cost8536
\[\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)}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-303}:\\ \;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y \cdot 4}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-249}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-157}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10000000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+252}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-8, \frac{y}{x} \cdot \frac{y}{x}, 1\right)\\ \end{array} \]
Alternative 5
Accuracy79.4%
Cost8536
\[\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)}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-303}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{x \cdot \frac{x}{y}}{y}, -1\right)\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-249}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-157}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10000000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+252}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-8, \frac{y}{x} \cdot \frac{y}{x}, 1\right)\\ \end{array} \]
Alternative 6
Accuracy79.3%
Cost3288
\[\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 := \frac{y}{\frac{x}{\frac{y}{x}}} \cdot -4\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-303}:\\ \;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y \cdot 4}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-249}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-157}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10000000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+252}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\frac{y}{x} \cdot 0 + \left(t_1 + t_1\right)\right)\\ \end{array} \]
Alternative 7
Accuracy79.2%
Cost2776
\[\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)}\\ \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-303}:\\ \;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y \cdot 4}\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-249}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{-157}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \cdot x \leq 10000000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 2 \cdot 10^{+252}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \end{array} \]
Alternative 8
Accuracy74.8%
Cost1485
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-87}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-42} \lor \neg \left(x \cdot x \leq 10^{+16}\right):\\ \;\;\;\;1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 9
Accuracy75.2%
Cost1485
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-87}:\\ \;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y \cdot 4}\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-42} \lor \neg \left(x \cdot x \leq 10^{+16}\right):\\ \;\;\;\;1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 10
Accuracy74.9%
Cost1484
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 5 \cdot 10^{-87}:\\ \;\;\;\;-1 + \frac{x}{y} \cdot \frac{x}{y \cdot 4}\\ \mathbf{elif}\;x \cdot x \leq 5 \cdot 10^{-13}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + y \cdot \left(y \cdot 4\right)}\\ \mathbf{elif}\;x \cdot x \leq 10^{+16}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{y}{x} \cdot \frac{y \cdot -4}{x}\\ \end{array} \]
Alternative 11
Accuracy74.3%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-41}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 100000000:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 12
Accuracy50.1%
Cost64
\[-1 \]

Error

Reproduce?

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