?

Average Accuracy: 100.0% → 100.0%
Time: 5.1s
Precision: binary64
Cost: 832

?

\[\frac{x}{y + x} \]
\[\frac{y - x}{y + x} \cdot \frac{x}{y - x} \]
(FPCore (x y) :precision binary64 (/ x (+ y x)))
(FPCore (x y) :precision binary64 (* (/ (- y x) (+ y x)) (/ x (- y x))))
double code(double x, double y) {
	return x / (y + x);
}
double code(double x, double y) {
	return ((y - x) / (y + x)) * (x / (y - x));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x / (y + x)
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((y - x) / (y + x)) * (x / (y - x))
end function
public static double code(double x, double y) {
	return x / (y + x);
}
public static double code(double x, double y) {
	return ((y - x) / (y + x)) * (x / (y - x));
}
def code(x, y):
	return x / (y + x)
def code(x, y):
	return ((y - x) / (y + x)) * (x / (y - x))
function code(x, y)
	return Float64(x / Float64(y + x))
end
function code(x, y)
	return Float64(Float64(Float64(y - x) / Float64(y + x)) * Float64(x / Float64(y - x)))
end
function tmp = code(x, y)
	tmp = x / (y + x);
end
function tmp = code(x, y)
	tmp = ((y - x) / (y + x)) * (x / (y - x));
end
code[x_, y_] := N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(N[(y - x), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x}{y + x}
\frac{y - x}{y + x} \cdot \frac{x}{y - x}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 100.0%

    \[\frac{x}{y + x} \]
  2. Applied egg-rr55.5%

    \[\leadsto \color{blue}{\frac{x}{\mathsf{fma}\left(y, y, -x \cdot x\right)} \cdot \left(y - x\right)} \]
    Step-by-step derivation

    [Start]100.0

    \[ \frac{x}{y + x} \]

    flip-+ [=>]58.5

    \[ \frac{x}{\color{blue}{\frac{y \cdot y - x \cdot x}{y - x}}} \]

    associate-/r/ [=>]55.3

    \[ \color{blue}{\frac{x}{y \cdot y - x \cdot x} \cdot \left(y - x\right)} \]

    fma-neg [=>]55.5

    \[ \frac{x}{\color{blue}{\mathsf{fma}\left(y, y, -x \cdot x\right)}} \cdot \left(y - x\right) \]
  3. Simplified54.6%

    \[\leadsto \color{blue}{\frac{x \cdot \left(y - x\right)}{y \cdot y - x \cdot x}} \]
    Step-by-step derivation

    [Start]55.5

    \[ \frac{x}{\mathsf{fma}\left(y, y, -x \cdot x\right)} \cdot \left(y - x\right) \]

    associate-*l/ [=>]54.6

    \[ \color{blue}{\frac{x \cdot \left(y - x\right)}{\mathsf{fma}\left(y, y, -x \cdot x\right)}} \]

    unpow2 [<=]54.6

    \[ \frac{x \cdot \left(y - x\right)}{\mathsf{fma}\left(y, y, -\color{blue}{{x}^{2}}\right)} \]

    fma-neg [<=]54.6

    \[ \frac{x \cdot \left(y - x\right)}{\color{blue}{y \cdot y - {x}^{2}}} \]

    unpow2 [=>]54.6

    \[ \frac{x \cdot \left(y - x\right)}{y \cdot y - \color{blue}{x \cdot x}} \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{y - x}{x + y} \cdot \frac{x}{y - x}} \]
    Step-by-step derivation

    [Start]54.6

    \[ \frac{x \cdot \left(y - x\right)}{y \cdot y - x \cdot x} \]

    *-commutative [=>]54.6

    \[ \frac{\color{blue}{\left(y - x\right) \cdot x}}{y \cdot y - x \cdot x} \]

    difference-of-squares [=>]54.6

    \[ \frac{\left(y - x\right) \cdot x}{\color{blue}{\left(y + x\right) \cdot \left(y - x\right)}} \]

    times-frac [=>]100.0

    \[ \color{blue}{\frac{y - x}{y + x} \cdot \frac{x}{y - x}} \]

    +-commutative [=>]100.0

    \[ \frac{y - x}{\color{blue}{x + y}} \cdot \frac{x}{y - x} \]
  5. Final simplification100.0%

    \[\leadsto \frac{y - x}{y + x} \cdot \frac{x}{y - x} \]

Alternatives

Alternative 1
Accuracy74.1%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{+22}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+90}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Accuracy100.0%
Cost320
\[\frac{x}{y + x} \]
Alternative 3
Accuracy50.9%
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023157 
(FPCore (x y)
  :name "AI.Clustering.Hierarchical.Internal:average from clustering-0.2.1, B"
  :precision binary64
  (/ x (+ y x)))