?

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

?

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

Error?

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Initial program 100.0%

    \[\frac{x - y}{x + y} \]
  2. Applied egg-rr63.0%

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

    [Start]100.0

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

    div-sub [=>]100.0

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

    div-inv [=>]99.9

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

    flip-+ [=>]63.2

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

    associate-/r/ [=>]63.1

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

    prod-diff [=>]63.0

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

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

    [Start]63.0

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

    +-commutative [=>]63.0

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

    fma-udef [=>]63.0

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

    associate-+r+ [=>]63.0

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

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

Alternatives

Alternative 1
Accuracy69.3%
Cost1507
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{+57}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-55} \lor \neg \left(x \leq -1.7 \cdot 10^{-70}\right) \land \left(x \leq 3.3 \cdot 10^{-109} \lor \neg \left(x \leq 2.2 \cdot 10^{-37}\right) \land \left(x \leq 1.5 \cdot 10^{+48} \lor \neg \left(x \leq 3.8 \cdot 10^{+73}\right) \land x \leq 7.6 \cdot 10^{+164}\right)\right):\\ \;\;\;\;2 \cdot \frac{x}{y} + -1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Accuracy72.8%
Cost592
\[\begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{-85}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-62}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2000000000000:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+42}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 3
Accuracy100.0%
Cost448
\[\frac{x - y}{x + y} \]
Alternative 4
Accuracy50.0%
Cost64
\[-1 \]

Error

Reproduce?

herbie shell --seed 2023160 
(FPCore (x y)
  :name "Data.Colour.RGB:hslsv from colour-2.3.3, D"
  :precision binary64

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

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