?

Average Error: 14.9 → 0.2
Time: 9.0s
Precision: binary64
Cost: 841

?

\[\left(-1.79 \cdot 10^{+308} \leq x \land x \leq 1.79 \cdot 10^{+308}\right) \land \left(-1.79 \cdot 10^{+308} \leq y \land y \leq 1.79 \cdot 10^{+308}\right)\]
\[\frac{-\left(2 \cdot x\right) \cdot y}{x - y} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+41} \lor \neg \left(y \leq 10^{-61}\right):\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{y - x}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x \cdot -2}{x - y}\\ \end{array} \]
(FPCore (x y) :precision binary64 (/ (- (* (* 2.0 x) y)) (- x y)))
(FPCore (x y)
 :precision binary64
 (if (or (<= y -1.75e+41) (not (<= y 1e-61)))
   (* x (* 2.0 (/ y (- y x))))
   (* y (/ (* x -2.0) (- x y)))))
double code(double x, double y) {
	return -((2.0 * x) * y) / (x - y);
}
double code(double x, double y) {
	double tmp;
	if ((y <= -1.75e+41) || !(y <= 1e-61)) {
		tmp = x * (2.0 * (y / (y - x)));
	} else {
		tmp = y * ((x * -2.0) / (x - y));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = -((2.0d0 * x) * y) / (x - y)
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-1.75d+41)) .or. (.not. (y <= 1d-61))) then
        tmp = x * (2.0d0 * (y / (y - x)))
    else
        tmp = y * ((x * (-2.0d0)) / (x - y))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return -((2.0 * x) * y) / (x - y);
}
public static double code(double x, double y) {
	double tmp;
	if ((y <= -1.75e+41) || !(y <= 1e-61)) {
		tmp = x * (2.0 * (y / (y - x)));
	} else {
		tmp = y * ((x * -2.0) / (x - y));
	}
	return tmp;
}
def code(x, y):
	return -((2.0 * x) * y) / (x - y)
def code(x, y):
	tmp = 0
	if (y <= -1.75e+41) or not (y <= 1e-61):
		tmp = x * (2.0 * (y / (y - x)))
	else:
		tmp = y * ((x * -2.0) / (x - y))
	return tmp
function code(x, y)
	return Float64(Float64(-Float64(Float64(2.0 * x) * y)) / Float64(x - y))
end
function code(x, y)
	tmp = 0.0
	if ((y <= -1.75e+41) || !(y <= 1e-61))
		tmp = Float64(x * Float64(2.0 * Float64(y / Float64(y - x))));
	else
		tmp = Float64(y * Float64(Float64(x * -2.0) / Float64(x - y)));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = -((2.0 * x) * y) / (x - y);
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -1.75e+41) || ~((y <= 1e-61)))
		tmp = x * (2.0 * (y / (y - x)));
	else
		tmp = y * ((x * -2.0) / (x - y));
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[((-N[(N[(2.0 * x), $MachinePrecision] * y), $MachinePrecision]) / N[(x - y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[Or[LessEqual[y, -1.75e+41], N[Not[LessEqual[y, 1e-61]], $MachinePrecision]], N[(x * N[(2.0 * N[(y / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(x * -2.0), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{-\left(2 \cdot x\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+41} \lor \neg \left(y \leq 10^{-61}\right):\\
\;\;\;\;x \cdot \left(2 \cdot \frac{y}{y - x}\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x \cdot -2}{x - y}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if y < -1.75e41 or 1e-61 < y

    1. Initial program 15.6

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

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

      [Start]15.6

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

      distribute-rgt-neg-in [=>]15.6

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

      associate-*r/ [<=]0.2

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

      *-commutative [=>]0.2

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

      neg-mul-1 [=>]0.2

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

      sub-neg [=>]0.2

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

      +-commutative [=>]0.2

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

      neg-sub0 [=>]0.2

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

      associate-+l- [=>]0.2

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

      sub0-neg [=>]0.2

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

      neg-mul-1 [=>]0.2

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

      times-frac [=>]0.2

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

      metadata-eval [=>]0.2

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

      *-lft-identity [=>]0.2

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

      associate-*r* [<=]0.2

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

    if -1.75e41 < y < 1e-61

    1. Initial program 14.0

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

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

      [Start]14.0

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

      distribute-lft-neg-in [=>]14.0

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

      associate-*l/ [<=]0.2

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

      *-commutative [=>]0.2

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

      *-commutative [=>]0.2

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

      distribute-lft-neg-in [=>]0.2

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

      sub-neg [=>]0.2

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

      +-commutative [=>]0.2

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

      neg-sub0 [=>]0.2

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

      associate-+l- [=>]0.2

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

      sub0-neg [=>]0.2

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

      neg-mul-1 [=>]0.2

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

      times-frac [=>]0.3

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

      metadata-eval [<=]0.3

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

      metadata-eval [<=]0.3

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

      associate-/r* [<=]0.3

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

      neg-mul-1 [<=]0.3

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

      sub0-neg [<=]0.3

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

      associate-+l- [<=]0.3

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

      neg-sub0 [<=]0.3

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

      +-commutative [<=]0.3

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

      sub-neg [<=]0.3

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

      associate-*r/ [=>]0.2

      \[ y \cdot \color{blue}{\frac{\frac{-x}{-1} \cdot \left(-1 \cdot 2\right)}{x - y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+41} \lor \neg \left(y \leq 10^{-61}\right):\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{y - x}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x \cdot -2}{x - y}\\ \end{array} \]

Alternatives

Alternative 1
Error3.5
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -1.16 \cdot 10^{-183} \lor \neg \left(y \leq 1.52 \cdot 10^{-190}\right):\\ \;\;\;\;x \cdot \left(2 \cdot \frac{y}{y - x}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot -2\\ \end{array} \]
Alternative 2
Error16.8
Cost721
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{+60}:\\ \;\;\;\;y \cdot -2\\ \mathbf{elif}\;x \leq -1.65 \cdot 10^{-43} \lor \neg \left(x \leq -4.3 \cdot 10^{-69}\right) \land x \leq 1.5 \cdot 10^{-40}:\\ \;\;\;\;x \cdot 2\\ \mathbf{else}:\\ \;\;\;\;y \cdot -2\\ \end{array} \]
Alternative 3
Error31.5
Cost192
\[x \cdot 2 \]

Error

Reproduce?

herbie shell --seed 1 
(FPCore (x y)
  :name "-(2 * x* y) / (x- y)"
  :precision binary64
  :pre (and (and (<= -1.79e+308 x) (<= x 1.79e+308)) (and (<= -1.79e+308 y) (<= y 1.79e+308)))
  (/ (- (* (* 2.0 x) y)) (- x y)))