?

Average Accuracy: 76.2% → 99.7%
Time: 4.1s
Precision: binary64
Cost: 841

?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\frac{x}{y} + -1}}{0.5}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original76.2%
Target99.4%
Herbie99.7%
\[\begin{array}{l} \mathbf{if}\;x < -1.7210442634149447 \cdot 10^{+81}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x < 83645045635564430:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if x < -7.2000000000000001e34 or 2.6500000000000001e-20 < x

    1. Initial program 73.9%

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

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

      [Start]73.9

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

      associate-*l/ [<=]99.7

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

    if -7.2000000000000001e34 < x < 2.6500000000000001e-20

    1. Initial program 78.6%

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

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

      [Start]78.6

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

      associate-*l/ [<=]78.0

      \[ \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
    3. Applied egg-rr77.9%

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

      [Start]78.0

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

      add-log-exp [=>]6.9

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

      *-un-lft-identity [=>]6.9

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

      log-prod [=>]6.9

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

      metadata-eval [=>]6.9

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

      add-log-exp [<=]78.0

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

      *-commutative [=>]78.0

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

      *-commutative [=>]78.0

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

      *-un-lft-identity [=>]78.0

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

      times-frac [=>]77.9

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

      metadata-eval [=>]77.9

      \[ 0 + y \cdot \left(\color{blue}{2} \cdot \frac{x}{x - y}\right) \]
    4. Simplified99.7%

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

      [Start]77.9

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

      +-lft-identity [=>]77.9

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

      *-commutative [=>]77.9

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

      *-commutative [<=]77.9

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

      metadata-eval [<=]77.9

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

      times-frac [<=]78.0

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

      *-rgt-identity [=>]78.0

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

      associate-/r/ [<=]99.7

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

      associate-/l* [<=]78.6

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

      associate-/r* [=>]78.6

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

      associate-/l* [=>]99.7

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

      div-sub [=>]99.7

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

      sub-neg [=>]99.7

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

      *-inverses [=>]99.7

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

      metadata-eval [=>]99.7

      \[ \frac{\frac{x}{\frac{x}{y} + \color{blue}{-1}}}{0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{+34} \lor \neg \left(x \leq 2.65 \cdot 10^{-20}\right):\\ \;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{x}{y} + -1}}{0.5}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy71.4%
Cost986
\[\begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{+163}:\\ \;\;\;\;2 \cdot y\\ \mathbf{elif}\;x \leq -2.75 \cdot 10^{+132} \lor \neg \left(x \leq -9 \cdot 10^{+28}\right) \land \left(x \leq -1.85 \cdot 10^{-19} \lor \neg \left(x \leq -1.65 \cdot 10^{-118}\right) \land x \leq 1.38 \cdot 10^{+57}\right):\\ \;\;\;\;x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;2 \cdot y\\ \end{array} \]
Alternative 2
Accuracy94.1%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{-171} \lor \neg \left(x \leq 1.7 \cdot 10^{-153}\right):\\ \;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot -2\\ \end{array} \]
Alternative 3
Accuracy99.7%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{+38} \lor \neg \left(x \leq 10^{-20}\right):\\ \;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array} \]
Alternative 4
Accuracy50.6%
Cost192
\[x \cdot -2 \]

Error

Reproduce?

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

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 83645045635564430.0) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))