Average Error: 22.7 → 0.5
Time: 5.9s
Precision: binary64
Cost: 1096
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
\[\begin{array}{l} t_0 := x + \frac{x + -1}{y} \cdot \left(-1 + \frac{1}{y}\right)\\ \mathbf{if}\;y \leq -963087761.6241825:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.66641545913458 \cdot 10^{-7}:\\ \;\;\;\;1 - \frac{y \cdot \left(1 - x\right)}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ x (* (/ (+ x -1.0) y) (+ -1.0 (/ 1.0 y))))))
   (if (<= y -963087761.6241825)
     t_0
     (if (<= y 4.66641545913458e-7)
       (- 1.0 (/ (* y (- 1.0 x)) (+ y 1.0)))
       t_0))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
double code(double x, double y) {
	double t_0 = x + (((x + -1.0) / y) * (-1.0 + (1.0 / y)));
	double tmp;
	if (y <= -963087761.6241825) {
		tmp = t_0;
	} else if (y <= 4.66641545913458e-7) {
		tmp = 1.0 - ((y * (1.0 - x)) / (y + 1.0));
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = x + (((x + (-1.0d0)) / y) * ((-1.0d0) + (1.0d0 / y)))
    if (y <= (-963087761.6241825d0)) then
        tmp = t_0
    else if (y <= 4.66641545913458d-7) then
        tmp = 1.0d0 - ((y * (1.0d0 - x)) / (y + 1.0d0))
    else
        tmp = t_0
    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 t_0 = x + (((x + -1.0) / y) * (-1.0 + (1.0 / y)));
	double tmp;
	if (y <= -963087761.6241825) {
		tmp = t_0;
	} else if (y <= 4.66641545913458e-7) {
		tmp = 1.0 - ((y * (1.0 - x)) / (y + 1.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	return 1.0 - (((1.0 - x) * y) / (y + 1.0))
def code(x, y):
	t_0 = x + (((x + -1.0) / y) * (-1.0 + (1.0 / y)))
	tmp = 0
	if y <= -963087761.6241825:
		tmp = t_0
	elif y <= 4.66641545913458e-7:
		tmp = 1.0 - ((y * (1.0 - x)) / (y + 1.0))
	else:
		tmp = t_0
	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)
	t_0 = Float64(x + Float64(Float64(Float64(x + -1.0) / y) * Float64(-1.0 + Float64(1.0 / y))))
	tmp = 0.0
	if (y <= -963087761.6241825)
		tmp = t_0;
	elseif (y <= 4.66641545913458e-7)
		tmp = Float64(1.0 - Float64(Float64(y * Float64(1.0 - x)) / Float64(y + 1.0)));
	else
		tmp = t_0;
	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)
	t_0 = x + (((x + -1.0) / y) * (-1.0 + (1.0 / y)));
	tmp = 0.0;
	if (y <= -963087761.6241825)
		tmp = t_0;
	elseif (y <= 4.66641545913458e-7)
		tmp = 1.0 - ((y * (1.0 - x)) / (y + 1.0));
	else
		tmp = t_0;
	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_] := Block[{t$95$0 = N[(x + N[(N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision] * N[(-1.0 + N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -963087761.6241825], t$95$0, If[LessEqual[y, 4.66641545913458e-7], N[(1.0 - N[(N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
t_0 := x + \frac{x + -1}{y} \cdot \left(-1 + \frac{1}{y}\right)\\
\mathbf{if}\;y \leq -963087761.6241825:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 4.66641545913458 \cdot 10^{-7}:\\
\;\;\;\;1 - \frac{y \cdot \left(1 - x\right)}{y + 1}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original22.7
Target0.2
Herbie0.5
\[\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 2 regimes
  2. if y < -963087761.62418246 or 4.66641545913458007e-7 < y

    1. Initial program 45.7

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Taylor expanded in y around inf 0.9

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

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

    if -963087761.62418246 < y < 4.66641545913458007e-7

    1. Initial program 0.1

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

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

Alternatives

Alternative 1
Error0.7
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -963087761.6241825:\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{elif}\;y \leq 4.66641545913458 \cdot 10^{-7}:\\ \;\;\;\;1 - \frac{y \cdot \left(1 - x\right)}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{y}\\ \end{array} \]
Alternative 2
Error17.3
Cost852
\[\begin{array}{l} \mathbf{if}\;y \leq -27608137.613368303:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.66641545913458 \cdot 10^{-7}:\\ \;\;\;\;1 - y\\ \mathbf{elif}\;y \leq 3.293318986381971 \cdot 10^{+34}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 5.656917655078891 \cdot 10^{+152}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.3467400113506932 \cdot 10^{+163}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error1.2
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -27608137.613368303:\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{elif}\;y \leq 4.66641545913458 \cdot 10^{-7}:\\ \;\;\;\;1 + y \cdot \left(x + -1\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{y}\\ \end{array} \]
Alternative 4
Error9.1
Cost584
\[\begin{array}{l} t_0 := x + \frac{1}{y}\\ \mathbf{if}\;y \leq -27608137.613368303:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.66641545913458 \cdot 10^{-7}:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.4
Cost584
\[\begin{array}{l} t_0 := x + \frac{1}{y}\\ \mathbf{if}\;y \leq -27608137.613368303:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.66641545913458 \cdot 10^{-7}:\\ \;\;\;\;1 + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error1.4
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -27608137.613368303:\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{elif}\;y \leq 4.66641545913458 \cdot 10^{-7}:\\ \;\;\;\;1 + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{y}\\ \end{array} \]
Alternative 7
Error16.8
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -27608137.613368303:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.66641545913458 \cdot 10^{-7}:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error17.4
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq -27608137.613368303:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.2224068405376165 \cdot 10^{+28}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error39.2
Cost64
\[1 \]

Error

Reproduce

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