Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D

Percentage Accurate: 64.4% → 99.9%
Time: 9.5s
Alternatives: 9
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
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
public static double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y):
	return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y)
	return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
end
function tmp = code(x, y)
	tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 64.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
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
public static double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y):
	return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y)
	return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
end
function tmp = code(x, y)
	tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\end{array}

Alternative 1: 99.9% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -12000 \lor \neg \left(y \leq 14500\right):\\
\;\;\;\;x + \frac{\left(\frac{\frac{1 - x}{y} + \left(x + -1\right)}{y} - -1\right) - x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -12000 or 14500 < y

    1. Initial program 27.4%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*48.5%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg48.5%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg48.5%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative48.5%

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified48.5%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around -inf 100.0%

      \[\leadsto \color{blue}{x + -1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{x - 1}{y} - -1 \cdot \left(x - 1\right)}{y} - -1 \cdot \left(x - 1\right)}{y}} \]
    6. Simplified100.0%

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

    if -12000 < y < 14500

    1. Initial program 99.9%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg99.9%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg99.9%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative99.9%

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

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -12000 \lor \neg \left(y \leq 14500\right):\\ \;\;\;\;x + \frac{\left(\frac{\frac{1 - x}{y} + \left(x + -1\right)}{y} - -1\right) - x}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{+24}:\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{elif}\;y \leq 390000:\\ \;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(1 - x\right) + \frac{x + -1}{y}}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -8.2e+24)
   (+ x (/ (- 1.0 x) y))
   (if (<= y 390000.0)
     (+ 1.0 (* (- 1.0 x) (/ y (- -1.0 y))))
     (+ x (/ (+ (- 1.0 x) (/ (+ x -1.0) y)) y)))))
double code(double x, double y) {
	double tmp;
	if (y <= -8.2e+24) {
		tmp = x + ((1.0 - x) / y);
	} else if (y <= 390000.0) {
		tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
	} else {
		tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-8.2d+24)) then
        tmp = x + ((1.0d0 - x) / y)
    else if (y <= 390000.0d0) then
        tmp = 1.0d0 + ((1.0d0 - x) * (y / ((-1.0d0) - y)))
    else
        tmp = x + (((1.0d0 - x) + ((x + (-1.0d0)) / y)) / y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -8.2e+24) {
		tmp = x + ((1.0 - x) / y);
	} else if (y <= 390000.0) {
		tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
	} else {
		tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -8.2e+24:
		tmp = x + ((1.0 - x) / y)
	elif y <= 390000.0:
		tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)))
	else:
		tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -8.2e+24)
		tmp = Float64(x + Float64(Float64(1.0 - x) / y));
	elseif (y <= 390000.0)
		tmp = Float64(1.0 + Float64(Float64(1.0 - x) * Float64(y / Float64(-1.0 - y))));
	else
		tmp = Float64(x + Float64(Float64(Float64(1.0 - x) + Float64(Float64(x + -1.0) / y)) / y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -8.2e+24)
		tmp = x + ((1.0 - x) / y);
	elseif (y <= 390000.0)
		tmp = 1.0 + ((1.0 - x) * (y / (-1.0 - y)));
	else
		tmp = x + (((1.0 - x) + ((x + -1.0) / y)) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -8.2e+24], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 390000.0], N[(1.0 + N[(N[(1.0 - x), $MachinePrecision] * N[(y / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+24}:\\
\;\;\;\;x + \frac{1 - x}{y}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -8.2000000000000002e24

    1. Initial program 29.3%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*52.1%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg52.1%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg52.1%

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

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

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 100.0%

      \[\leadsto \color{blue}{\left(x + \frac{1}{y}\right) - \frac{x}{y}} \]
    6. Step-by-step derivation
      1. associate--l+100.0%

        \[\leadsto \color{blue}{x + \left(\frac{1}{y} - \frac{x}{y}\right)} \]
      2. div-sub100.0%

        \[\leadsto x + \color{blue}{\frac{1 - x}{y}} \]
    7. Simplified100.0%

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

    if -8.2000000000000002e24 < y < 3.9e5

    1. Initial program 99.9%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg99.9%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg99.9%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative99.9%

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

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

    if 3.9e5 < y

    1. Initial program 21.7%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*42.2%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg42.2%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg42.2%

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

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

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 99.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{+24}:\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{elif}\;y \leq 390000:\\ \;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\left(1 - x\right) + \frac{x + -1}{y}}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.4% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+24} \lor \neg \left(y \leq 135000000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.2000000000000002e24 or 1.35e8 < y

    1. Initial program 25.2%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*47.0%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg47.0%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg47.0%

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

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified47.0%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 99.9%

      \[\leadsto \color{blue}{\left(x + \frac{1}{y}\right) - \frac{x}{y}} \]
    6. Step-by-step derivation
      1. associate--l+99.9%

        \[\leadsto \color{blue}{x + \left(\frac{1}{y} - \frac{x}{y}\right)} \]
      2. div-sub99.9%

        \[\leadsto x + \color{blue}{\frac{1 - x}{y}} \]
    7. Simplified99.9%

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

    if -8.2000000000000002e24 < y < 1.35e8

    1. Initial program 99.7%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*99.7%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg99.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg99.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative99.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification99.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{+24} \lor \neg \left(y \leq 135000000\right):\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(1 - x\right) \cdot \frac{y}{-1 - y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 87.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -9200 \lor \neg \left(y \leq 1750000\right):\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{-1 - y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -9200.0) (not (<= y 1750000.0)))
   (+ x (/ (- 1.0 x) y))
   (/ -1.0 (- -1.0 y))))
double code(double x, double y) {
	double tmp;
	if ((y <= -9200.0) || !(y <= 1750000.0)) {
		tmp = x + ((1.0 - x) / y);
	} else {
		tmp = -1.0 / (-1.0 - y);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-9200.0d0)) .or. (.not. (y <= 1750000.0d0))) then
        tmp = x + ((1.0d0 - x) / y)
    else
        tmp = (-1.0d0) / ((-1.0d0) - y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -9200.0) || !(y <= 1750000.0)) {
		tmp = x + ((1.0 - x) / y);
	} else {
		tmp = -1.0 / (-1.0 - y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -9200.0) or not (y <= 1750000.0):
		tmp = x + ((1.0 - x) / y)
	else:
		tmp = -1.0 / (-1.0 - y)
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -9200.0) || !(y <= 1750000.0))
		tmp = Float64(x + Float64(Float64(1.0 - x) / y));
	else
		tmp = Float64(-1.0 / Float64(-1.0 - y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -9200.0) || ~((y <= 1750000.0)))
		tmp = x + ((1.0 - x) / y);
	else
		tmp = -1.0 / (-1.0 - y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -9200.0], N[Not[LessEqual[y, 1750000.0]], $MachinePrecision]], N[(x + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9200 \lor \neg \left(y \leq 1750000\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{-1 - y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9200 or 1.75e6 < y

    1. Initial program 27.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*48.3%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg48.3%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg48.3%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative48.3%

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

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 99.6%

      \[\leadsto \color{blue}{\left(x + \frac{1}{y}\right) - \frac{x}{y}} \]
    6. Step-by-step derivation
      1. associate--l+99.6%

        \[\leadsto \color{blue}{x + \left(\frac{1}{y} - \frac{x}{y}\right)} \]
      2. div-sub99.6%

        \[\leadsto x + \color{blue}{\frac{1 - x}{y}} \]
    7. Simplified99.6%

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

    if -9200 < y < 1.75e6

    1. Initial program 99.7%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*99.7%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg99.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg99.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative99.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 99.5%

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{x} - \left(-1 \cdot \frac{y}{1 + y} + \frac{y}{x \cdot \left(1 + y\right)}\right)\right)} \]
    6. Taylor expanded in x around inf 99.5%

      \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{y}{1 + y}\right) - \frac{y}{x \cdot \left(1 + y\right)}\right)} \]
    7. Step-by-step derivation
      1. frac-add99.5%

        \[\leadsto x \cdot \left(\color{blue}{\frac{1 \cdot \left(1 + y\right) + x \cdot y}{x \cdot \left(1 + y\right)}} - \frac{y}{x \cdot \left(1 + y\right)}\right) \]
      2. sub-div99.8%

        \[\leadsto x \cdot \color{blue}{\frac{\left(1 \cdot \left(1 + y\right) + x \cdot y\right) - y}{x \cdot \left(1 + y\right)}} \]
      3. *-un-lft-identity99.8%

        \[\leadsto x \cdot \frac{\left(\color{blue}{\left(1 + y\right)} + x \cdot y\right) - y}{x \cdot \left(1 + y\right)} \]
      4. +-commutative99.8%

        \[\leadsto x \cdot \frac{\left(\color{blue}{\left(y + 1\right)} + x \cdot y\right) - y}{x \cdot \left(1 + y\right)} \]
      5. associate-+l+99.8%

        \[\leadsto x \cdot \frac{\color{blue}{\left(y + \left(1 + x \cdot y\right)\right)} - y}{x \cdot \left(1 + y\right)} \]
      6. +-commutative99.8%

        \[\leadsto x \cdot \frac{\left(y + \color{blue}{\left(x \cdot y + 1\right)}\right) - y}{x \cdot \left(1 + y\right)} \]
      7. fma-define99.8%

        \[\leadsto x \cdot \frac{\left(y + \color{blue}{\mathsf{fma}\left(x, y, 1\right)}\right) - y}{x \cdot \left(1 + y\right)} \]
    8. Applied egg-rr99.8%

      \[\leadsto x \cdot \color{blue}{\frac{\left(y + \mathsf{fma}\left(x, y, 1\right)\right) - y}{x \cdot \left(1 + y\right)}} \]
    9. Taylor expanded in x around 0 84.3%

      \[\leadsto \color{blue}{\frac{1}{1 + y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9200 \lor \neg \left(y \leq 1750000\right):\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{-1 - y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x + \frac{1 - x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1 or 1 < y

    1. Initial program 29.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*49.7%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg49.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg49.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative49.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified49.7%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 97.5%

      \[\leadsto \color{blue}{\left(x + \frac{1}{y}\right) - \frac{x}{y}} \]
    6. Step-by-step derivation
      1. associate--l+97.5%

        \[\leadsto \color{blue}{x + \left(\frac{1}{y} - \frac{x}{y}\right)} \]
      2. div-sub97.5%

        \[\leadsto x + \color{blue}{\frac{1 - x}{y}} \]
    7. Simplified97.5%

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

    if -1 < y < 1

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*100.0%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg100.0%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg100.0%

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

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 99.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + y \cdot \left(x + -1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 73.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 9.8\right):\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -1.0) (not (<= y 9.8))) (- x (/ x y)) 1.0))
double code(double x, double y) {
	double tmp;
	if ((y <= -1.0) || !(y <= 9.8)) {
		tmp = x - (x / y);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-1.0d0)) .or. (.not. (y <= 9.8d0))) then
        tmp = x - (x / y)
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -1.0) || !(y <= 9.8)) {
		tmp = x - (x / y);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -1.0) or not (y <= 9.8):
		tmp = x - (x / y)
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -1.0) || !(y <= 9.8))
		tmp = Float64(x - Float64(x / y));
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -1.0) || ~((y <= 9.8)))
		tmp = x - (x / y);
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 9.8]], $MachinePrecision]], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 9.8\right):\\
\;\;\;\;x - \frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1 or 9.8000000000000007 < y

    1. Initial program 29.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*49.7%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg49.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg49.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative49.7%

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified49.7%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 51.3%

      \[\leadsto \color{blue}{\frac{x \cdot y}{1 + y}} \]
    6. Taylor expanded in y around inf 71.2%

      \[\leadsto \color{blue}{x + -1 \cdot \frac{x}{y}} \]
    7. Step-by-step derivation
      1. neg-mul-171.2%

        \[\leadsto x + \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. unsub-neg71.2%

        \[\leadsto \color{blue}{x - \frac{x}{y}} \]
    8. Simplified71.2%

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

    if -1 < y < 9.8000000000000007

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*100.0%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg100.0%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg100.0%

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

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 84.0%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 9.8\right):\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 73.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -18000:\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{+95}:\\ \;\;\;\;\frac{-1}{-1 - y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -18000.0) (- x (/ x y)) (if (<= y 7.8e+95) (/ -1.0 (- -1.0 y)) x)))
double code(double x, double y) {
	double tmp;
	if (y <= -18000.0) {
		tmp = x - (x / y);
	} else if (y <= 7.8e+95) {
		tmp = -1.0 / (-1.0 - y);
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-18000.0d0)) then
        tmp = x - (x / y)
    else if (y <= 7.8d+95) then
        tmp = (-1.0d0) / ((-1.0d0) - y)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -18000.0) {
		tmp = x - (x / y);
	} else if (y <= 7.8e+95) {
		tmp = -1.0 / (-1.0 - y);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -18000.0:
		tmp = x - (x / y)
	elif y <= 7.8e+95:
		tmp = -1.0 / (-1.0 - y)
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -18000.0)
		tmp = Float64(x - Float64(x / y));
	elseif (y <= 7.8e+95)
		tmp = Float64(-1.0 / Float64(-1.0 - y));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -18000.0)
		tmp = x - (x / y);
	elseif (y <= 7.8e+95)
		tmp = -1.0 / (-1.0 - y);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -18000.0], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.8e+95], N[(-1.0 / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -18000:\\
\;\;\;\;x - \frac{x}{y}\\

\mathbf{elif}\;y \leq 7.8 \cdot 10^{+95}:\\
\;\;\;\;\frac{-1}{-1 - y}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -18000

    1. Initial program 32.6%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*54.3%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg54.3%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg54.3%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative54.3%

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

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 54.9%

      \[\leadsto \color{blue}{\frac{x \cdot y}{1 + y}} \]
    6. Taylor expanded in y around inf 76.1%

      \[\leadsto \color{blue}{x + -1 \cdot \frac{x}{y}} \]
    7. Step-by-step derivation
      1. neg-mul-176.1%

        \[\leadsto x + \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. unsub-neg76.1%

        \[\leadsto \color{blue}{x - \frac{x}{y}} \]
    8. Simplified76.1%

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

    if -18000 < y < 7.7999999999999994e95

    1. Initial program 91.6%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*91.6%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg91.6%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg91.6%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative91.6%

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified91.6%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 91.5%

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{x} - \left(-1 \cdot \frac{y}{1 + y} + \frac{y}{x \cdot \left(1 + y\right)}\right)\right)} \]
    6. Taylor expanded in x around inf 91.5%

      \[\leadsto \color{blue}{x \cdot \left(\left(\frac{1}{x} + \frac{y}{1 + y}\right) - \frac{y}{x \cdot \left(1 + y\right)}\right)} \]
    7. Step-by-step derivation
      1. frac-add91.3%

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

        \[\leadsto x \cdot \color{blue}{\frac{\left(1 \cdot \left(1 + y\right) + x \cdot y\right) - y}{x \cdot \left(1 + y\right)}} \]
      3. *-un-lft-identity92.0%

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

        \[\leadsto x \cdot \frac{\left(\color{blue}{\left(y + 1\right)} + x \cdot y\right) - y}{x \cdot \left(1 + y\right)} \]
      5. associate-+l+92.0%

        \[\leadsto x \cdot \frac{\color{blue}{\left(y + \left(1 + x \cdot y\right)\right)} - y}{x \cdot \left(1 + y\right)} \]
      6. +-commutative92.0%

        \[\leadsto x \cdot \frac{\left(y + \color{blue}{\left(x \cdot y + 1\right)}\right) - y}{x \cdot \left(1 + y\right)} \]
      7. fma-define92.0%

        \[\leadsto x \cdot \frac{\left(y + \color{blue}{\mathsf{fma}\left(x, y, 1\right)}\right) - y}{x \cdot \left(1 + y\right)} \]
    8. Applied egg-rr92.0%

      \[\leadsto x \cdot \color{blue}{\frac{\left(y + \mathsf{fma}\left(x, y, 1\right)\right) - y}{x \cdot \left(1 + y\right)}} \]
    9. Taylor expanded in x around 0 82.9%

      \[\leadsto \color{blue}{\frac{1}{1 + y}} \]

    if 7.7999999999999994e95 < y

    1. Initial program 17.9%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*47.3%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg47.3%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg47.3%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\frac{y}{y + 1}} \]
      4. +-commutative47.3%

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

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 85.6%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -18000:\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{+95}:\\ \;\;\;\;\frac{-1}{-1 - y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 73.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 0.00033:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= y -1.0) x (if (<= y 0.00033) 1.0 x)))
double code(double x, double y) {
	double tmp;
	if (y <= -1.0) {
		tmp = x;
	} else if (y <= 0.00033) {
		tmp = 1.0;
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-1.0d0)) then
        tmp = x
    else if (y <= 0.00033d0) then
        tmp = 1.0d0
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -1.0) {
		tmp = x;
	} else if (y <= 0.00033) {
		tmp = 1.0;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.0:
		tmp = x
	elif y <= 0.00033:
		tmp = 1.0
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.0)
		tmp = x;
	elseif (y <= 0.00033)
		tmp = 1.0;
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.0)
		tmp = x;
	elseif (y <= 0.00033)
		tmp = 1.0;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 0.00033], 1.0, x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 0.00033:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1 or 3.3e-4 < y

    1. Initial program 29.6%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*50.0%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg50.0%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg50.0%

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

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified50.0%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 70.2%

      \[\leadsto \color{blue}{x} \]

    if -1 < y < 3.3e-4

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. associate-/l*100.0%

        \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
      2. remove-double-neg100.0%

        \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
      3. remove-double-neg100.0%

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

        \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 84.7%

      \[\leadsto \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification77.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 0.00033:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 38.0% accurate, 11.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
	return 1.0;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0
end function
public static double code(double x, double y) {
	return 1.0;
}
def code(x, y):
	return 1.0
function code(x, y)
	return 1.0
end
function tmp = code(x, y)
	tmp = 1.0;
end
code[x_, y_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 64.8%

    \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
  2. Step-by-step derivation
    1. associate-/l*75.0%

      \[\leadsto 1 - \color{blue}{\left(1 - x\right) \cdot \frac{y}{y + 1}} \]
    2. remove-double-neg75.0%

      \[\leadsto 1 - \left(1 - x\right) \cdot \color{blue}{\left(-\left(-\frac{y}{y + 1}\right)\right)} \]
    3. remove-double-neg75.0%

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

      \[\leadsto 1 - \left(1 - x\right) \cdot \frac{y}{\color{blue}{1 + y}} \]
  3. Simplified75.0%

    \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
  4. Add Preprocessing
  5. Taylor expanded in y around 0 44.2%

    \[\leadsto \color{blue}{1} \]
  6. Final simplification44.2%

    \[\leadsto 1 \]
  7. Add Preprocessing

Developer target: 99.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{if}\;y < -3693.8482788297247:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y < 6799310503.41891:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- (/ 1.0 y) (- (/ x y) x))))
   (if (< y -3693.8482788297247)
     t_0
     (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) t_0))))
double code(double x, double y) {
	double t_0 = (1.0 / y) - ((x / y) - x);
	double tmp;
	if (y < -3693.8482788297247) {
		tmp = t_0;
	} else if (y < 6799310503.41891) {
		tmp = 1.0 - (((1.0 - x) * y) / (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
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (1.0d0 / y) - ((x / y) - x)
    if (y < (-3693.8482788297247d0)) then
        tmp = t_0
    else if (y < 6799310503.41891d0) then
        tmp = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (1.0 / y) - ((x / y) - x);
	double tmp;
	if (y < -3693.8482788297247) {
		tmp = t_0;
	} else if (y < 6799310503.41891) {
		tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (1.0 / y) - ((x / y) - x)
	tmp = 0
	if y < -3693.8482788297247:
		tmp = t_0
	elif y < 6799310503.41891:
		tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0))
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(1.0 / y) - Float64(Float64(x / y) - x))
	tmp = 0.0
	if (y < -3693.8482788297247)
		tmp = t_0;
	elseif (y < 6799310503.41891)
		tmp = Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (1.0 / y) - ((x / y) - x);
	tmp = 0.0;
	if (y < -3693.8482788297247)
		tmp = t_0;
	elseif (y < 6799310503.41891)
		tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -3693.8482788297247], t$95$0, If[Less[y, 6799310503.41891], N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{y} - \left(\frac{x}{y} - x\right)\\
\mathbf{if}\;y < -3693.8482788297247:\\
\;\;\;\;t\_0\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}

Reproduce

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

  :alt
  (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))))