?

Average Accuracy: 77.2% → 99.7%
Time: 5.1s
Precision: binary64
Cost: 841

?

\[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{-51} \lor \neg \left(x \leq 10^{-39}\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 -3.6e-51) (not (<= x 1e-39)))
   (* 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 <= -3.6e-51) || !(x <= 1e-39)) {
		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 <= (-3.6d-51)) .or. (.not. (x <= 1d-39))) 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 <= -3.6e-51) || !(x <= 1e-39)) {
		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 <= -3.6e-51) or not (x <= 1e-39):
		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 <= -3.6e-51) || !(x <= 1e-39))
		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 <= -3.6e-51) || ~((x <= 1e-39)))
		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, -3.6e-51], N[Not[LessEqual[x, 1e-39]], $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 -3.6 \cdot 10^{-51} \lor \neg \left(x \leq 10^{-39}\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

Original77.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 < -3.6e-51 or 9.99999999999999929e-40 < x

    1. Initial program 81.0%

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      Step-by-step derivation

      [Start]81.0

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

      associate-*l/ [<=]100.0

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

    if -3.6e-51 < x < 9.99999999999999929e-40

    1. Initial program 62.1%

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      Step-by-step derivation

      [Start]62.1

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

      associate-*l/ [<=]79.8

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

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

      [Start]79.8

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

      add-log-exp [=>]6.5

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

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

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

      log-prod [=>]6.5

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

      metadata-eval [=>]6.5

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

      add-log-exp [<=]79.8

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

      *-commutative [=>]79.8

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

      *-commutative [=>]79.8

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

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

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

      times-frac [=>]79.6

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

      metadata-eval [=>]79.6

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

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{x}{y} + -1}}{0.5}} \]
      Step-by-step derivation

      [Start]79.6

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

      +-lft-identity [=>]79.6

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

      *-commutative [=>]79.6

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

      *-commutative [<=]79.6

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

      metadata-eval [<=]79.6

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

      times-frac [<=]79.8

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

      *-rgt-identity [=>]79.8

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

      associate-/r/ [<=]99.9

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

      associate-/l* [<=]62.0

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

      associate-/r* [=>]62.0

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

      associate-/l* [=>]99.9

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

      div-sub [=>]99.9

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

      sub-neg [=>]99.9

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

      *-inverses [=>]99.9

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

      metadata-eval [=>]99.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{-51} \lor \neg \left(x \leq 10^{-39}\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
Accuracy92.9%
Cost973
\[\begin{array}{l} \mathbf{if}\;y \leq -6.6 \cdot 10^{+192} \lor \neg \left(y \leq 1.52 \cdot 10^{+206}\right) \land y \leq 10^{+266}:\\ \;\;\;\;x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\ \end{array} \]
Alternative 2
Accuracy99.7%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-50} \lor \neg \left(x \leq 2 \cdot 10^{-43}\right):\\ \;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array} \]
Alternative 3
Accuracy75.0%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{-34}:\\ \;\;\;\;2 \cdot y\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-26}:\\ \;\;\;\;x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;2 \cdot y\\ \end{array} \]
Alternative 4
Accuracy50.8%
Cost192
\[2 \cdot y \]

Error

Reproduce?

herbie shell --seed 2023160 
(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)))