?

Average Accuracy: 100.0% → 100.0%
Time: 10.0s
Precision: binary64
Cost: 704

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original100.0%
Target100.0%
Herbie100.0%
\[\frac{1}{\frac{x}{x + y} - \frac{y}{x + y}} \]

Derivation?

  1. Initial program 100.0%

    \[\frac{x + y}{x - y} \]
  2. Applied egg-rr99.9%

    \[\leadsto \color{blue}{\log \left(e^{\frac{x + y}{x - y}}\right)} \]
    Proof

    [Start]100.0

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

    add-log-exp [=>]99.9

    \[ \color{blue}{\log \left(e^{\frac{x + y}{x - y}}\right)} \]
  3. Applied egg-rr34.1%

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

    [Start]99.9

    \[ \log \left(e^{\frac{x + y}{x - y}}\right) \]

    add-log-exp [<=]100.0

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

    flip3-+ [=>]33.8

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

    associate-/r* [<=]33.8

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

    sum-cubes [=>]33.9

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

    associate-/l* [=>]34.1

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

    fma-def [=>]34.1

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

    distribute-rgt-out-- [=>]34.1

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

    *-commutative [=>]34.1

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

    fma-def [=>]34.1

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

    distribute-rgt-out-- [=>]34.1

    \[ \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\frac{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, \color{blue}{y \cdot \left(y - x\right)}\right)}{x + y}} \]
  4. Simplified34.0%

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

    [Start]34.1

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

    associate-/r/ [=>]34.0

    \[ \color{blue}{\frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)} \cdot \left(x + y\right)} \]
  5. Applied egg-rr100.0%

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

    [Start]34.0

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

    +-commutative [=>]34.0

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

    distribute-rgt-in [=>]34.0

    \[ \color{blue}{y \cdot \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)} + x \cdot \frac{\mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}{\left(x - y\right) \cdot \mathsf{fma}\left(x, x, y \cdot \left(y - x\right)\right)}} \]
  6. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy73.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{+70} \lor \neg \left(x \leq 100000000\right):\\ \;\;\;\;1 + 2 \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 2
Accuracy74.5%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{+69} \lor \neg \left(x \leq 2600000000000\right):\\ \;\;\;\;1 + 2 \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{x}{y} + -1\\ \end{array} \]
Alternative 3
Accuracy100.0%
Cost448
\[\frac{y + x}{x - y} \]
Alternative 4
Accuracy72.9%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+85}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 450000000:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Accuracy49.3%
Cost64
\[-1 \]

Error

Reproduce?

herbie shell --seed 2023137 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (/ 1.0 (- (/ x (+ x y)) (/ y (+ x y))))

  (/ (+ x y) (- x y)))