?

Average Error: 0.03% → 0.04%
Time: 8.2s
Precision: binary64
Cost: 2112

?

\[\frac{x - y}{2 - \left(x + y\right)} \]
\[\begin{array}{l} t_0 := \frac{x - y}{\left(2 - y\right) - x}\\ t_1 := 2 + t_0\\ \frac{t_0 \cdot t_1}{t_1} \end{array} \]
(FPCore (x y) :precision binary64 (/ (- x y) (- 2.0 (+ x y))))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (- x y) (- (- 2.0 y) x))) (t_1 (+ 2.0 t_0)))
   (/ (* t_0 t_1) t_1)))
double code(double x, double y) {
	return (x - y) / (2.0 - (x + y));
}
double code(double x, double y) {
	double t_0 = (x - y) / ((2.0 - y) - x);
	double t_1 = 2.0 + t_0;
	return (t_0 * t_1) / t_1;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x - y) / (2.0d0 - (x + y))
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    t_0 = (x - y) / ((2.0d0 - y) - x)
    t_1 = 2.0d0 + t_0
    code = (t_0 * t_1) / t_1
end function
public static double code(double x, double y) {
	return (x - y) / (2.0 - (x + y));
}
public static double code(double x, double y) {
	double t_0 = (x - y) / ((2.0 - y) - x);
	double t_1 = 2.0 + t_0;
	return (t_0 * t_1) / t_1;
}
def code(x, y):
	return (x - y) / (2.0 - (x + y))
def code(x, y):
	t_0 = (x - y) / ((2.0 - y) - x)
	t_1 = 2.0 + t_0
	return (t_0 * t_1) / t_1
function code(x, y)
	return Float64(Float64(x - y) / Float64(2.0 - Float64(x + y)))
end
function code(x, y)
	t_0 = Float64(Float64(x - y) / Float64(Float64(2.0 - y) - x))
	t_1 = Float64(2.0 + t_0)
	return Float64(Float64(t_0 * t_1) / t_1)
end
function tmp = code(x, y)
	tmp = (x - y) / (2.0 - (x + y));
end
function tmp = code(x, y)
	t_0 = (x - y) / ((2.0 - y) - x);
	t_1 = 2.0 + t_0;
	tmp = (t_0 * t_1) / t_1;
end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(2.0 - N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / N[(N[(2.0 - y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 + t$95$0), $MachinePrecision]}, N[(N[(t$95$0 * t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision]]]
\frac{x - y}{2 - \left(x + y\right)}
\begin{array}{l}
t_0 := \frac{x - y}{\left(2 - y\right) - x}\\
t_1 := 2 + t_0\\
\frac{t_0 \cdot t_1}{t_1}
\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.03%
Target0.03%
Herbie0.04%
\[\frac{x}{2 - \left(x + y\right)} - \frac{y}{2 - \left(x + y\right)} \]

Derivation?

  1. Initial program 0.03

    \[\frac{x - y}{2 - \left(x + y\right)} \]
  2. Simplified0.03

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

    [Start]0.03

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

    associate--r+ [=>]0.03

    \[ \frac{x - y}{\color{blue}{\left(2 - x\right) - y}} \]
  3. Applied egg-rr1.34

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x - y}{2 - \left(x + y\right)}\right)\right)} \]
  4. Applied egg-rr21.74

    \[\leadsto \color{blue}{\frac{\left(\frac{x - y}{\left(2 - y\right) - x} + 1\right) \cdot \left(\frac{x - y}{\left(2 - y\right) - x} + 1\right) - 1}{2 + \frac{x - y}{\left(2 - y\right) - x}}} \]
  5. Simplified0.04

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

    [Start]21.74

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

    difference-of-sqr-1 [=>]21.74

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

    associate--l+ [=>]0.05

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

    metadata-eval [=>]0.05

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

    +-rgt-identity [=>]0.05

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

    *-commutative [=>]0.05

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

    associate-+l+ [=>]0.04

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

    metadata-eval [=>]0.04

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

    +-commutative [<=]0.04

    \[ \frac{\frac{x - y}{\left(2 - y\right) - x} \cdot \color{blue}{\left(2 + \frac{x - y}{\left(2 - y\right) - x}\right)}}{2 + \frac{x - y}{\left(2 - y\right) - x}} \]
  6. Final simplification0.04

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

Alternatives

Alternative 1
Error26.46%
Cost976
\[\begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -3.4 \cdot 10^{-86}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{-71}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{\frac{y}{x}} + 1\\ \end{array} \]
Alternative 2
Error25.49%
Cost848
\[\begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -3.9 \cdot 10^{+14}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-71}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{+61}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error26.61%
Cost848
\[\begin{array}{l} t_0 := \frac{x}{2 - x}\\ \mathbf{if}\;y \leq -3.8 \cdot 10^{-86}:\\ \;\;\;\;\frac{y}{y + -2}\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-71}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 7.4 \cdot 10^{+59}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 4
Error38.23%
Cost724
\[\begin{array}{l} \mathbf{if}\;y \leq -2:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-118}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-89}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-71}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+60}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error0.03%
Cost576
\[\frac{x - y}{2 - \left(x + y\right)} \]
Alternative 6
Error36.84%
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq -11500000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 10^{+60}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error62.54%
Cost64
\[-1 \]

Error

Reproduce?

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

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

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