?

Average Error: 22.6 → 0.1
Time: 7.5s
Precision: binary64
Cost: 7492

?

\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -1150000:\\ \;\;\;\;\frac{1}{y} + \left(\left(x + \left(-\frac{1}{{y}^{2}}\right)\right) - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq 125000000:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{y} + x\right) - \frac{x}{y}\\ \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(FPCore (x y)
 :precision binary64
 (if (<= y -1150000.0)
   (+ (/ 1.0 y) (- (+ x (- (/ 1.0 (pow y 2.0)))) (/ x y)))
   (if (<= y 125000000.0)
     (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0)))
     (- (+ (/ 1.0 y) x) (/ x y)))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
double code(double x, double y) {
	double tmp;
	if (y <= -1150000.0) {
		tmp = (1.0 / y) + ((x + -(1.0 / pow(y, 2.0))) - (x / y));
	} else if (y <= 125000000.0) {
		tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
	} else {
		tmp = ((1.0 / y) + x) - (x / y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-1150000.0d0)) then
        tmp = (1.0d0 / y) + ((x + -(1.0d0 / (y ** 2.0d0))) - (x / y))
    else if (y <= 125000000.0d0) then
        tmp = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
    else
        tmp = ((1.0d0 / y) + x) - (x / y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
public static double code(double x, double y) {
	double tmp;
	if (y <= -1150000.0) {
		tmp = (1.0 / y) + ((x + -(1.0 / Math.pow(y, 2.0))) - (x / y));
	} else if (y <= 125000000.0) {
		tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
	} else {
		tmp = ((1.0 / y) + x) - (x / y);
	}
	return tmp;
}
def code(x, y):
	return 1.0 - (((1.0 - x) * y) / (y + 1.0))
def code(x, y):
	tmp = 0
	if y <= -1150000.0:
		tmp = (1.0 / y) + ((x + -(1.0 / math.pow(y, 2.0))) - (x / y))
	elif y <= 125000000.0:
		tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0))
	else:
		tmp = ((1.0 / y) + x) - (x / y)
	return tmp
function code(x, y)
	return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
end
function code(x, y)
	tmp = 0.0
	if (y <= -1150000.0)
		tmp = Float64(Float64(1.0 / y) + Float64(Float64(x + Float64(-Float64(1.0 / (y ^ 2.0)))) - Float64(x / y)));
	elseif (y <= 125000000.0)
		tmp = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)));
	else
		tmp = Float64(Float64(Float64(1.0 / y) + x) - Float64(x / y));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1150000.0)
		tmp = (1.0 / y) + ((x + -(1.0 / (y ^ 2.0))) - (x / y));
	elseif (y <= 125000000.0)
		tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
	else
		tmp = ((1.0 / y) + x) - (x / y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[LessEqual[y, -1150000.0], N[(N[(1.0 / y), $MachinePrecision] + N[(N[(x + (-N[(1.0 / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 125000000.0], N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] + x), $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
\mathbf{if}\;y \leq -1150000:\\
\;\;\;\;\frac{1}{y} + \left(\left(x + \left(-\frac{1}{{y}^{2}}\right)\right) - \frac{x}{y}\right)\\

\mathbf{elif}\;y \leq 125000000:\\
\;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{y} + x\right) - \frac{x}{y}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original22.6
Target0.2
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;y < -3693.8482788297247:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y < 6799310503.41891:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if y < -1.15e6

    1. Initial program 45.6

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

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

      [Start]45.6

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]45.6

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

      rational_best_oopsla_all_46_json_45_simplify-13 [=>]45.6

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]45.6

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

      rational_best_oopsla_all_46_json_45_simplify-52 [=>]45.6

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]45.6

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]45.6

      \[ 1 - \frac{y - x \cdot y}{\color{blue}{1 + y}} \]
    3. Taylor expanded in y around inf 0.0

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

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

      [Start]0.0

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.0

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

      rational_best_oopsla_all_46_json_45_simplify-107 [=>]0.0

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]0.0

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0

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

      rational_best_oopsla_all_46_json_45_simplify-92 [=>]0.0

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.0

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

      rational_best_oopsla_all_46_json_45_simplify-94 [<=]0.0

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

      rational_best_oopsla_all_46_json_45_simplify-97 [=>]0.0

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

      rational_best_oopsla_all_46_json_45_simplify-108 [=>]0.0

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

      metadata-eval [=>]0.0

      \[ \frac{1}{y} + \left(\left(x + \left(-\frac{\color{blue}{1} - x}{{y}^{2}}\right)\right) - \frac{x}{y}\right) \]
    5. Taylor expanded in x around 0 0.0

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

    if -1.15e6 < y < 1.25e8

    1. Initial program 0.1

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

    if 1.25e8 < y

    1. Initial program 46.5

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

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

      [Start]46.5

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]46.5

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

      rational_best_oopsla_all_46_json_45_simplify-13 [=>]46.5

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]46.5

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

      rational_best_oopsla_all_46_json_45_simplify-52 [=>]46.5

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]46.5

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

      rational_best_oopsla_all_46_json_45_simplify-35 [=>]46.5

      \[ 1 - \frac{y - x \cdot y}{\color{blue}{1 + y}} \]
    3. Taylor expanded in y around inf 0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1150000:\\ \;\;\;\;\frac{1}{y} + \left(\left(x + \left(-\frac{1}{{y}^{2}}\right)\right) - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq 125000000:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{y} + x\right) - \frac{x}{y}\\ \end{array} \]

Alternatives

Alternative 1
Error0.2
Cost968
\[\begin{array}{l} t_0 := \left(\frac{1}{y} + x\right) - \frac{x}{y}\\ \mathbf{if}\;y \leq -114000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 140000000:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error1.0
Cost840
\[\begin{array}{l} t_0 := \left(\frac{1}{y} + x\right) - \frac{x}{y}\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;\left(y \cdot x + 1\right) - y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error8.6
Cost712
\[\begin{array}{l} t_0 := \frac{1}{y} + x\\ \mathbf{if}\;y \leq -3950:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 260:\\ \;\;\;\;1 - \frac{y}{y - -1}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.1
Cost712
\[\begin{array}{l} t_0 := \frac{1}{y} + x\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.82:\\ \;\;\;\;\left(y \cdot x + 1\right) - y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error9.0
Cost584
\[\begin{array}{l} t_0 := \frac{1}{y} + x\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.0145:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error17.0
Cost460
\[\begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+69}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.7 \cdot 10^{-14}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 0.058:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error16.5
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 0.31:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error39.2
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, D"
  :precision binary64

  :herbie-target
  (if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))

  (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))