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

Percentage Accurate: 65.5% → 99.1%
Time: 7.7s
Alternatives: 12
Speedup: 2.1×

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 12 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: 65.5% 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.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\ \mathbf{if}\;t_0 \leq 10^{-10} \lor \neg \left(t_0 \leq 2\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \left(\frac{1 - x}{{y}^{3}} + \frac{1 - x}{y}\right)\right) + \frac{-1}{y \cdot y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (* (- 1.0 x) y) (+ 1.0 y))))
   (if (or (<= t_0 1e-10) (not (<= t_0 2.0)))
     (fma (/ y (+ 1.0 y)) (+ x -1.0) 1.0)
     (+
      (+ x (+ (/ (- 1.0 x) (pow y 3.0)) (/ (- 1.0 x) y)))
      (/ -1.0 (* y y))))))
double code(double x, double y) {
	double t_0 = ((1.0 - x) * y) / (1.0 + y);
	double tmp;
	if ((t_0 <= 1e-10) || !(t_0 <= 2.0)) {
		tmp = fma((y / (1.0 + y)), (x + -1.0), 1.0);
	} else {
		tmp = (x + (((1.0 - x) / pow(y, 3.0)) + ((1.0 - x) / y))) + (-1.0 / (y * y));
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(1.0 + y))
	tmp = 0.0
	if ((t_0 <= 1e-10) || !(t_0 <= 2.0))
		tmp = fma(Float64(y / Float64(1.0 + y)), Float64(x + -1.0), 1.0);
	else
		tmp = Float64(Float64(x + Float64(Float64(Float64(1.0 - x) / (y ^ 3.0)) + Float64(Float64(1.0 - x) / y))) + Float64(-1.0 / Float64(y * y)));
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 1e-10], N[Not[LessEqual[t$95$0, 2.0]], $MachinePrecision]], N[(N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] * N[(x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\
\mathbf{if}\;t_0 \leq 10^{-10} \lor \neg \left(t_0 \leq 2\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 1.00000000000000004e-10 or 2 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1))

    1. Initial program 85.3%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg85.3%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*99.9%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity99.9%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/99.9%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*100.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity100.0%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub0100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative100.0%

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

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

    if 1.00000000000000004e-10 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 2

    1. Initial program 12.8%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg12.8%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*12.7%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity12.7%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/12.7%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*12.8%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity12.8%

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

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub012.8%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-12.8%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval12.8%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 100.0%

      \[\leadsto \color{blue}{\left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{x - 1}{y} + \left(-1 \cdot \frac{x - 1}{{y}^{3}} + x\right)\right)\right) - \frac{1}{{y}^{2}}} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

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

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

      \[\leadsto \color{blue}{\left(x + \left(\frac{1 - x}{{y}^{3}} + \frac{1 - x}{y}\right)\right) + \frac{x + -1}{y \cdot y}} \]
    7. Taylor expanded in x around 0 100.0%

      \[\leadsto \left(x + \left(\frac{1 - x}{{y}^{3}} + \frac{1 - x}{y}\right)\right) + \color{blue}{\frac{-1}{{y}^{2}}} \]
    8. Step-by-step derivation
      1. unpow2100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(1 - x\right) \cdot y}{1 + y} \leq 10^{-10} \lor \neg \left(\frac{\left(1 - x\right) \cdot y}{1 + y} \leq 2\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \left(\frac{1 - x}{{y}^{3}} + \frac{1 - x}{y}\right)\right) + \frac{-1}{y \cdot y}\\ \end{array} \]

Alternative 2: 99.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\ \mathbf{if}\;t_0 \leq 10^{-10} \lor \neg \left(t_0 \leq 2\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{y} + \left(x + \frac{-1}{y \cdot y}\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (* (- 1.0 x) y) (+ 1.0 y))))
   (if (or (<= t_0 1e-10) (not (<= t_0 2.0)))
     (fma (/ y (+ 1.0 y)) (+ x -1.0) 1.0)
     (+ (/ (- 1.0 x) y) (+ x (/ -1.0 (* y y)))))))
double code(double x, double y) {
	double t_0 = ((1.0 - x) * y) / (1.0 + y);
	double tmp;
	if ((t_0 <= 1e-10) || !(t_0 <= 2.0)) {
		tmp = fma((y / (1.0 + y)), (x + -1.0), 1.0);
	} else {
		tmp = ((1.0 - x) / y) + (x + (-1.0 / (y * y)));
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(Float64(Float64(1.0 - x) * y) / Float64(1.0 + y))
	tmp = 0.0
	if ((t_0 <= 1e-10) || !(t_0 <= 2.0))
		tmp = fma(Float64(y / Float64(1.0 + y)), Float64(x + -1.0), 1.0);
	else
		tmp = Float64(Float64(Float64(1.0 - x) / y) + Float64(x + Float64(-1.0 / Float64(y * y))));
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 1e-10], N[Not[LessEqual[t$95$0, 2.0]], $MachinePrecision]], N[(N[(y / N[(1.0 + y), $MachinePrecision]), $MachinePrecision] * N[(x + -1.0), $MachinePrecision] + 1.0), $MachinePrecision], N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] + N[(x + N[(-1.0 / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\left(1 - x\right) \cdot y}{1 + y}\\
\mathbf{if}\;t_0 \leq 10^{-10} \lor \neg \left(t_0 \leq 2\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 1.00000000000000004e-10 or 2 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1))

    1. Initial program 85.3%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg85.3%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*99.9%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity99.9%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/99.9%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*100.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity100.0%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub0100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative100.0%

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

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

    if 1.00000000000000004e-10 < (/.f64 (*.f64 (-.f64 1 x) y) (+.f64 y 1)) < 2

    1. Initial program 12.8%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg12.8%

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

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

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}{y + 1} \]
      4. associate-*l/12.5%

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

        \[\leadsto 1 + \frac{\color{blue}{1 \cdot -1}}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      6. associate-*l/12.5%

        \[\leadsto 1 + \color{blue}{\left(\frac{1}{y + 1} \cdot -1\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      7. associate-/r/12.5%

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

        \[\leadsto 1 + \frac{\color{blue}{--1}}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      9. distribute-neg-frac12.5%

        \[\leadsto 1 + \color{blue}{\left(-\frac{-1}{\frac{y + 1}{-1}}\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      10. cancel-sign-sub-inv12.5%

        \[\leadsto \color{blue}{1 - \frac{-1}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right)} \]
      11. associate-/r/12.4%

        \[\leadsto 1 - \color{blue}{\frac{-1}{\frac{\frac{y + 1}{-1}}{\left(1 - x\right) \cdot y}}} \]
      12. associate-/r*12.4%

        \[\leadsto 1 - \frac{-1}{\color{blue}{\frac{y + 1}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}} \]
      13. neg-mul-112.4%

        \[\leadsto 1 - \frac{-1}{\frac{y + 1}{\color{blue}{-\left(1 - x\right) \cdot y}}} \]
      14. associate-/r/12.5%

        \[\leadsto 1 - \color{blue}{\frac{-1}{y + 1} \cdot \left(-\left(1 - x\right) \cdot y\right)} \]
      15. distribute-rgt-neg-in12.5%

        \[\leadsto 1 - \color{blue}{\left(-\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)\right)} \]
      16. associate-/r/12.4%

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

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

        \[\leadsto 1 - \frac{\color{blue}{1}}{\frac{y + 1}{\left(1 - x\right) \cdot y}} \]
      19. associate-/r/12.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x - \color{blue}{\frac{1}{{y}^{2}}}\right) + \frac{1 - x}{y} \]
    8. Step-by-step derivation
      1. unpow299.5%

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

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

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

Alternative 3: 99.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -200000000000:\\ \;\;\;\;x - \frac{-1}{y}\\ \mathbf{elif}\;y \leq 1450000:\\ \;\;\;\;1 + \frac{y \cdot \left(x + -1\right)}{1 + y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{y} + \left(x + \frac{-1}{y \cdot y}\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -200000000000.0)
   (- x (/ -1.0 y))
   (if (<= y 1450000.0)
     (+ 1.0 (/ (* y (+ x -1.0)) (+ 1.0 y)))
     (+ (/ (- 1.0 x) y) (+ x (/ -1.0 (* y y)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -200000000000.0) {
		tmp = x - (-1.0 / y);
	} else if (y <= 1450000.0) {
		tmp = 1.0 + ((y * (x + -1.0)) / (1.0 + y));
	} else {
		tmp = ((1.0 - x) / y) + (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 <= (-200000000000.0d0)) then
        tmp = x - ((-1.0d0) / y)
    else if (y <= 1450000.0d0) then
        tmp = 1.0d0 + ((y * (x + (-1.0d0))) / (1.0d0 + y))
    else
        tmp = ((1.0d0 - x) / y) + (x + ((-1.0d0) / (y * y)))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -200000000000.0) {
		tmp = x - (-1.0 / y);
	} else if (y <= 1450000.0) {
		tmp = 1.0 + ((y * (x + -1.0)) / (1.0 + y));
	} else {
		tmp = ((1.0 - x) / y) + (x + (-1.0 / (y * y)));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -200000000000.0:
		tmp = x - (-1.0 / y)
	elif y <= 1450000.0:
		tmp = 1.0 + ((y * (x + -1.0)) / (1.0 + y))
	else:
		tmp = ((1.0 - x) / y) + (x + (-1.0 / (y * y)))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -200000000000.0)
		tmp = Float64(x - Float64(-1.0 / y));
	elseif (y <= 1450000.0)
		tmp = Float64(1.0 + Float64(Float64(y * Float64(x + -1.0)) / Float64(1.0 + y)));
	else
		tmp = Float64(Float64(Float64(1.0 - x) / y) + Float64(x + Float64(-1.0 / Float64(y * y))));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -200000000000.0)
		tmp = x - (-1.0 / y);
	elseif (y <= 1450000.0)
		tmp = 1.0 + ((y * (x + -1.0)) / (1.0 + y));
	else
		tmp = ((1.0 - x) / y) + (x + (-1.0 / (y * y)));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -200000000000.0], N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1450000.0], N[(1.0 + N[(N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision] / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] + N[(x + N[(-1.0 / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 36.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg36.0%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*58.6%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity58.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/58.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*58.6%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity58.6%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub058.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified58.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 100.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 1}{y} + x} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{x + -1 \cdot \frac{x - 1}{y}} \]
      2. mul-1-neg100.0%

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      4. sub-neg100.0%

        \[\leadsto x - \frac{\color{blue}{x + \left(-1\right)}}{y} \]
      5. metadata-eval100.0%

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

      \[\leadsto \color{blue}{x - \frac{x + -1}{y}} \]
    7. Taylor expanded in x around 0 100.0%

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

    if -2e11 < y < 1.45e6

    1. Initial program 100.0%

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

    if 1.45e6 < y

    1. Initial program 38.7%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg38.7%

        \[\leadsto \color{blue}{1 + \left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right)} \]
      2. distribute-neg-frac38.7%

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

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}{y + 1} \]
      4. associate-*l/38.4%

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

        \[\leadsto 1 + \frac{\color{blue}{1 \cdot -1}}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      6. associate-*l/38.4%

        \[\leadsto 1 + \color{blue}{\left(\frac{1}{y + 1} \cdot -1\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      7. associate-/r/38.4%

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

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

        \[\leadsto 1 + \color{blue}{\left(-\frac{-1}{\frac{y + 1}{-1}}\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      10. cancel-sign-sub-inv38.4%

        \[\leadsto \color{blue}{1 - \frac{-1}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right)} \]
      11. associate-/r/38.2%

        \[\leadsto 1 - \color{blue}{\frac{-1}{\frac{\frac{y + 1}{-1}}{\left(1 - x\right) \cdot y}}} \]
      12. associate-/r*38.2%

        \[\leadsto 1 - \frac{-1}{\color{blue}{\frac{y + 1}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}} \]
      13. neg-mul-138.2%

        \[\leadsto 1 - \frac{-1}{\frac{y + 1}{\color{blue}{-\left(1 - x\right) \cdot y}}} \]
      14. associate-/r/38.4%

        \[\leadsto 1 - \color{blue}{\frac{-1}{y + 1} \cdot \left(-\left(1 - x\right) \cdot y\right)} \]
      15. distribute-rgt-neg-in38.4%

        \[\leadsto 1 - \color{blue}{\left(-\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)\right)} \]
      16. associate-/r/38.2%

        \[\leadsto 1 - \left(-\color{blue}{\frac{-1}{\frac{y + 1}{\left(1 - x\right) \cdot y}}}\right) \]
      17. distribute-neg-frac38.2%

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

        \[\leadsto 1 - \frac{\color{blue}{1}}{\frac{y + 1}{\left(1 - x\right) \cdot y}} \]
      19. associate-/r/38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x - \color{blue}{\frac{1}{{y}^{2}}}\right) + \frac{1 - x}{y} \]
    8. Step-by-step derivation
      1. unpow299.6%

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

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

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

Alternative 4: 99.7% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;y \leq 220000000:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{1 + y}\\

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


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

    1. Initial program 36.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg36.0%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*58.6%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity58.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/58.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*58.6%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity58.6%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub058.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified58.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 100.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 1}{y} + x} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{x + -1 \cdot \frac{x - 1}{y}} \]
      2. mul-1-neg100.0%

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      4. sub-neg100.0%

        \[\leadsto x - \frac{\color{blue}{x + \left(-1\right)}}{y} \]
      5. metadata-eval100.0%

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

      \[\leadsto \color{blue}{x - \frac{x + -1}{y}} \]
    7. Taylor expanded in x around 0 100.0%

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

    if -4.8e10 < y < 2.2e8

    1. Initial program 99.6%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg99.6%

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

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

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}{y + 1} \]
      4. associate-*l/99.6%

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

        \[\leadsto 1 + \frac{\color{blue}{1 \cdot -1}}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      6. associate-*l/99.6%

        \[\leadsto 1 + \color{blue}{\left(\frac{1}{y + 1} \cdot -1\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      7. associate-/r/99.6%

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

        \[\leadsto 1 + \frac{\color{blue}{--1}}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      9. distribute-neg-frac99.6%

        \[\leadsto 1 + \color{blue}{\left(-\frac{-1}{\frac{y + 1}{-1}}\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      10. cancel-sign-sub-inv99.6%

        \[\leadsto \color{blue}{1 - \frac{-1}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right)} \]
      11. associate-/r/99.4%

        \[\leadsto 1 - \color{blue}{\frac{-1}{\frac{\frac{y + 1}{-1}}{\left(1 - x\right) \cdot y}}} \]
      12. associate-/r*99.4%

        \[\leadsto 1 - \frac{-1}{\color{blue}{\frac{y + 1}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}} \]
      13. neg-mul-199.4%

        \[\leadsto 1 - \frac{-1}{\frac{y + 1}{\color{blue}{-\left(1 - x\right) \cdot y}}} \]
      14. associate-/r/99.6%

        \[\leadsto 1 - \color{blue}{\frac{-1}{y + 1} \cdot \left(-\left(1 - x\right) \cdot y\right)} \]
      15. distribute-rgt-neg-in99.6%

        \[\leadsto 1 - \color{blue}{\left(-\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)\right)} \]
      16. associate-/r/99.4%

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

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

        \[\leadsto 1 - \frac{\color{blue}{1}}{\frac{y + 1}{\left(1 - x\right) \cdot y}} \]
      19. associate-/r/99.6%

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

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

    if 2.2e8 < y

    1. Initial program 37.8%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg37.8%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*60.1%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity60.1%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/60.1%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*60.2%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity60.2%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative60.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub060.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-60.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval60.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative60.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified60.2%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 1}{y} + x} \]
    5. Step-by-step derivation
      1. +-commutative99.5%

        \[\leadsto \color{blue}{x + -1 \cdot \frac{x - 1}{y}} \]
      2. mul-1-neg99.5%

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      4. sub-neg99.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -48000000000:\\ \;\;\;\;x - \frac{-1}{y}\\ \mathbf{elif}\;y \leq 220000000:\\ \;\;\;\;1 + y \cdot \frac{x + -1}{1 + y}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1 - x}{y}\\ \end{array} \]

Alternative 5: 99.7% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 36.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg36.0%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*58.6%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity58.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/58.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*58.6%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity58.6%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub058.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified58.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 100.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 1}{y} + x} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{x + -1 \cdot \frac{x - 1}{y}} \]
      2. mul-1-neg100.0%

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      4. sub-neg100.0%

        \[\leadsto x - \frac{\color{blue}{x + \left(-1\right)}}{y} \]
      5. metadata-eval100.0%

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

      \[\leadsto \color{blue}{x - \frac{x + -1}{y}} \]
    7. Taylor expanded in x around 0 100.0%

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

    if -3.6e11 < y < 1.7e7

    1. Initial program 99.6%

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

    if 1.7e7 < y

    1. Initial program 37.8%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg37.8%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*60.1%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity60.1%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/60.1%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*60.2%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity60.2%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative60.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub060.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-60.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval60.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative60.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified60.2%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 1}{y} + x} \]
    5. Step-by-step derivation
      1. +-commutative99.5%

        \[\leadsto \color{blue}{x + -1 \cdot \frac{x - 1}{y}} \]
      2. mul-1-neg99.5%

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      4. sub-neg99.5%

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

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

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

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

Alternative 6: 85.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x - \frac{-1}{y}\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-77}:\\ \;\;\;\;1 - y\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-30}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 0.21:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (- x (/ -1.0 y))))
   (if (<= y -1.0)
     t_0
     (if (<= y 8e-77)
       (- 1.0 y)
       (if (<= y 3.2e-30) (* x y) (if (<= y 0.21) (- 1.0 y) t_0))))))
double code(double x, double y) {
	double t_0 = x - (-1.0 / y);
	double tmp;
	if (y <= -1.0) {
		tmp = t_0;
	} else if (y <= 8e-77) {
		tmp = 1.0 - y;
	} else if (y <= 3.2e-30) {
		tmp = x * y;
	} else if (y <= 0.21) {
		tmp = 1.0 - y;
	} 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 = x - ((-1.0d0) / y)
    if (y <= (-1.0d0)) then
        tmp = t_0
    else if (y <= 8d-77) then
        tmp = 1.0d0 - y
    else if (y <= 3.2d-30) then
        tmp = x * y
    else if (y <= 0.21d0) then
        tmp = 1.0d0 - y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x - (-1.0 / y);
	double tmp;
	if (y <= -1.0) {
		tmp = t_0;
	} else if (y <= 8e-77) {
		tmp = 1.0 - y;
	} else if (y <= 3.2e-30) {
		tmp = x * y;
	} else if (y <= 0.21) {
		tmp = 1.0 - y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x - (-1.0 / y)
	tmp = 0
	if y <= -1.0:
		tmp = t_0
	elif y <= 8e-77:
		tmp = 1.0 - y
	elif y <= 3.2e-30:
		tmp = x * y
	elif y <= 0.21:
		tmp = 1.0 - y
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(x - Float64(-1.0 / y))
	tmp = 0.0
	if (y <= -1.0)
		tmp = t_0;
	elseif (y <= 8e-77)
		tmp = Float64(1.0 - y);
	elseif (y <= 3.2e-30)
		tmp = Float64(x * y);
	elseif (y <= 0.21)
		tmp = Float64(1.0 - y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x - (-1.0 / y);
	tmp = 0.0;
	if (y <= -1.0)
		tmp = t_0;
	elseif (y <= 8e-77)
		tmp = 1.0 - y;
	elseif (y <= 3.2e-30)
		tmp = x * y;
	elseif (y <= 0.21)
		tmp = 1.0 - y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x - N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 8e-77], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 3.2e-30], N[(x * y), $MachinePrecision], If[LessEqual[y, 0.21], N[(1.0 - y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 8 \cdot 10^{-77}:\\
\;\;\;\;1 - y\\

\mathbf{elif}\;y \leq 3.2 \cdot 10^{-30}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq 0.21:\\
\;\;\;\;1 - y\\

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


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

    1. Initial program 37.6%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg37.6%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*59.7%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity59.7%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/59.7%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*59.8%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity59.8%

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

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub059.8%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-59.8%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval59.8%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 99.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 1}{y} + x} \]
    5. Step-by-step derivation
      1. +-commutative99.0%

        \[\leadsto \color{blue}{x + -1 \cdot \frac{x - 1}{y}} \]
      2. mul-1-neg99.0%

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      4. sub-neg99.0%

        \[\leadsto x - \frac{\color{blue}{x + \left(-1\right)}}{y} \]
      5. metadata-eval99.0%

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

      \[\leadsto \color{blue}{x - \frac{x + -1}{y}} \]
    7. Taylor expanded in x around 0 98.8%

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

    if -1 < y < 7.9999999999999994e-77 or 3.2e-30 < y < 0.209999999999999992

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*99.9%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity99.9%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/99.9%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*100.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity100.0%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub0100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative100.0%

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{y}{1 + y}} \]
    5. Step-by-step derivation
      1. mul-1-neg77.8%

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

        \[\leadsto \color{blue}{1 - \frac{y}{1 + y}} \]
    6. Simplified77.8%

      \[\leadsto \color{blue}{1 - \frac{y}{1 + y}} \]
    7. Taylor expanded in y around 0 77.8%

      \[\leadsto \color{blue}{1 + -1 \cdot y} \]
    8. Step-by-step derivation
      1. neg-mul-177.8%

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

        \[\leadsto \color{blue}{1 - y} \]
    9. Simplified77.8%

      \[\leadsto \color{blue}{1 - y} \]

    if 7.9999999999999994e-77 < y < 3.2e-30

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/99.7%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*100.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity100.0%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub0100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative100.0%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in x around inf 79.1%

      \[\leadsto \color{blue}{\frac{y \cdot x}{1 + y}} \]
    5. Taylor expanded in y around 0 79.1%

      \[\leadsto \color{blue}{y \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x - \frac{-1}{y}\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-77}:\\ \;\;\;\;1 - y\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-30}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 0.21:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;x - \frac{-1}{y}\\ \end{array} \]

Alternative 7: 73.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-77}:\\ \;\;\;\;1 - y\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-30}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 0.43:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.0)
   x
   (if (<= y 8e-77)
     (- 1.0 y)
     (if (<= y 3.6e-30) (* x y) (if (<= y 0.43) (- 1.0 y) x)))))
double code(double x, double y) {
	double tmp;
	if (y <= -1.0) {
		tmp = x;
	} else if (y <= 8e-77) {
		tmp = 1.0 - y;
	} else if (y <= 3.6e-30) {
		tmp = x * y;
	} else if (y <= 0.43) {
		tmp = 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 <= (-1.0d0)) then
        tmp = x
    else if (y <= 8d-77) then
        tmp = 1.0d0 - y
    else if (y <= 3.6d-30) then
        tmp = x * y
    else if (y <= 0.43d0) then
        tmp = 1.0d0 - y
    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 <= 8e-77) {
		tmp = 1.0 - y;
	} else if (y <= 3.6e-30) {
		tmp = x * y;
	} else if (y <= 0.43) {
		tmp = 1.0 - y;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.0:
		tmp = x
	elif y <= 8e-77:
		tmp = 1.0 - y
	elif y <= 3.6e-30:
		tmp = x * y
	elif y <= 0.43:
		tmp = 1.0 - y
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.0)
		tmp = x;
	elseif (y <= 8e-77)
		tmp = Float64(1.0 - y);
	elseif (y <= 3.6e-30)
		tmp = Float64(x * y);
	elseif (y <= 0.43)
		tmp = Float64(1.0 - y);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.0)
		tmp = x;
	elseif (y <= 8e-77)
		tmp = 1.0 - y;
	elseif (y <= 3.6e-30)
		tmp = x * y;
	elseif (y <= 0.43)
		tmp = 1.0 - y;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 8e-77], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 3.6e-30], N[(x * y), $MachinePrecision], If[LessEqual[y, 0.43], N[(1.0 - y), $MachinePrecision], x]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 8 \cdot 10^{-77}:\\
\;\;\;\;1 - y\\

\mathbf{elif}\;y \leq 3.6 \cdot 10^{-30}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq 0.43:\\
\;\;\;\;1 - y\\

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


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

    1. Initial program 37.6%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg37.6%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*59.7%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity59.7%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/59.7%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*59.8%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity59.8%

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

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub059.8%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-59.8%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval59.8%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 74.7%

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

    if -1 < y < 7.9999999999999994e-77 or 3.6000000000000003e-30 < y < 0.429999999999999993

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*99.9%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity99.9%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/99.9%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*100.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity100.0%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub0100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative100.0%

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

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

      \[\leadsto \color{blue}{1 + -1 \cdot \frac{y}{1 + y}} \]
    5. Step-by-step derivation
      1. mul-1-neg77.8%

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

        \[\leadsto \color{blue}{1 - \frac{y}{1 + y}} \]
    6. Simplified77.8%

      \[\leadsto \color{blue}{1 - \frac{y}{1 + y}} \]
    7. Taylor expanded in y around 0 77.8%

      \[\leadsto \color{blue}{1 + -1 \cdot y} \]
    8. Step-by-step derivation
      1. neg-mul-177.8%

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

        \[\leadsto \color{blue}{1 - y} \]
    9. Simplified77.8%

      \[\leadsto \color{blue}{1 - y} \]

    if 7.9999999999999994e-77 < y < 3.6000000000000003e-30

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/99.7%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*100.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity100.0%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub0100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative100.0%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in x around inf 79.1%

      \[\leadsto \color{blue}{\frac{y \cdot x}{1 + y}} \]
    5. Taylor expanded in y around 0 79.1%

      \[\leadsto \color{blue}{y \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-77}:\\ \;\;\;\;1 - y\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-30}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 0.43:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 8: 98.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.78\right):\\ \;\;\;\;x - \frac{-1}{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 0.78)))
   (- x (/ -1.0 y))
   (+ 1.0 (* y (+ x -1.0)))))
double code(double x, double y) {
	double tmp;
	if ((y <= -1.0) || !(y <= 0.78)) {
		tmp = x - (-1.0 / 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 <= 0.78d0))) then
        tmp = x - ((-1.0d0) / 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 <= 0.78)) {
		tmp = x - (-1.0 / y);
	} else {
		tmp = 1.0 + (y * (x + -1.0));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -1.0) or not (y <= 0.78):
		tmp = x - (-1.0 / y)
	else:
		tmp = 1.0 + (y * (x + -1.0))
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -1.0) || !(y <= 0.78))
		tmp = Float64(x - Float64(-1.0 / 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 <= 0.78)))
		tmp = x - (-1.0 / 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, 0.78]], $MachinePrecision]], N[(x - N[(-1.0 / 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 0.78\right):\\
\;\;\;\;x - \frac{-1}{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 0.78000000000000003 < y

    1. Initial program 37.6%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg37.6%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*59.7%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity59.7%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/59.7%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*59.8%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity59.8%

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

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub059.8%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-59.8%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval59.8%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 99.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 1}{y} + x} \]
    5. Step-by-step derivation
      1. +-commutative99.0%

        \[\leadsto \color{blue}{x + -1 \cdot \frac{x - 1}{y}} \]
      2. mul-1-neg99.0%

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      4. sub-neg99.0%

        \[\leadsto x - \frac{\color{blue}{x + \left(-1\right)}}{y} \]
      5. metadata-eval99.0%

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

      \[\leadsto \color{blue}{x - \frac{x + -1}{y}} \]
    7. Taylor expanded in x around 0 98.8%

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

    if -1 < y < 0.78000000000000003

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}{y + 1} \]
      4. associate-*l/100.0%

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

        \[\leadsto 1 + \frac{\color{blue}{1 \cdot -1}}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      6. associate-*l/100.0%

        \[\leadsto 1 + \color{blue}{\left(\frac{1}{y + 1} \cdot -1\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      7. associate-/r/100.0%

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

        \[\leadsto 1 + \frac{\color{blue}{--1}}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      9. distribute-neg-frac100.0%

        \[\leadsto 1 + \color{blue}{\left(-\frac{-1}{\frac{y + 1}{-1}}\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      10. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{1 - \frac{-1}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right)} \]
      11. associate-/r/99.9%

        \[\leadsto 1 - \color{blue}{\frac{-1}{\frac{\frac{y + 1}{-1}}{\left(1 - x\right) \cdot y}}} \]
      12. associate-/r*99.9%

        \[\leadsto 1 - \frac{-1}{\color{blue}{\frac{y + 1}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}} \]
      13. neg-mul-199.9%

        \[\leadsto 1 - \frac{-1}{\frac{y + 1}{\color{blue}{-\left(1 - x\right) \cdot y}}} \]
      14. associate-/r/100.0%

        \[\leadsto 1 - \color{blue}{\frac{-1}{y + 1} \cdot \left(-\left(1 - x\right) \cdot y\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 - \color{blue}{\left(-\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)\right)} \]
      16. associate-/r/99.9%

        \[\leadsto 1 - \left(-\color{blue}{\frac{-1}{\frac{y + 1}{\left(1 - x\right) \cdot y}}}\right) \]
      17. distribute-neg-frac99.9%

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

        \[\leadsto 1 - \frac{\color{blue}{1}}{\frac{y + 1}{\left(1 - x\right) \cdot y}} \]
      19. associate-/r/100.0%

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

      \[\leadsto \color{blue}{1 - \frac{1 - x}{1 + y} \cdot y} \]
    4. Taylor expanded in y around 0 99.2%

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

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

Alternative 9: 98.4% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 36.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg36.0%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*58.6%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity58.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/58.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*58.6%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity58.6%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub058.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative58.6%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified58.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 100.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 1}{y} + x} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{x + -1 \cdot \frac{x - 1}{y}} \]
      2. mul-1-neg100.0%

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      4. sub-neg100.0%

        \[\leadsto x - \frac{\color{blue}{x + \left(-1\right)}}{y} \]
      5. metadata-eval100.0%

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

      \[\leadsto \color{blue}{x - \frac{x + -1}{y}} \]
    7. Taylor expanded in x around 0 100.0%

      \[\leadsto x - \color{blue}{\frac{-1}{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. sub-neg100.0%

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

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

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}{y + 1} \]
      4. associate-*l/100.0%

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

        \[\leadsto 1 + \frac{\color{blue}{1 \cdot -1}}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      6. associate-*l/100.0%

        \[\leadsto 1 + \color{blue}{\left(\frac{1}{y + 1} \cdot -1\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      7. associate-/r/100.0%

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

        \[\leadsto 1 + \frac{\color{blue}{--1}}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      9. distribute-neg-frac100.0%

        \[\leadsto 1 + \color{blue}{\left(-\frac{-1}{\frac{y + 1}{-1}}\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]
      10. cancel-sign-sub-inv100.0%

        \[\leadsto \color{blue}{1 - \frac{-1}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right)} \]
      11. associate-/r/99.9%

        \[\leadsto 1 - \color{blue}{\frac{-1}{\frac{\frac{y + 1}{-1}}{\left(1 - x\right) \cdot y}}} \]
      12. associate-/r*99.9%

        \[\leadsto 1 - \frac{-1}{\color{blue}{\frac{y + 1}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}} \]
      13. neg-mul-199.9%

        \[\leadsto 1 - \frac{-1}{\frac{y + 1}{\color{blue}{-\left(1 - x\right) \cdot y}}} \]
      14. associate-/r/100.0%

        \[\leadsto 1 - \color{blue}{\frac{-1}{y + 1} \cdot \left(-\left(1 - x\right) \cdot y\right)} \]
      15. distribute-rgt-neg-in100.0%

        \[\leadsto 1 - \color{blue}{\left(-\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)\right)} \]
      16. associate-/r/99.9%

        \[\leadsto 1 - \left(-\color{blue}{\frac{-1}{\frac{y + 1}{\left(1 - x\right) \cdot y}}}\right) \]
      17. distribute-neg-frac99.9%

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

        \[\leadsto 1 - \frac{\color{blue}{1}}{\frac{y + 1}{\left(1 - x\right) \cdot y}} \]
      19. associate-/r/100.0%

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

      \[\leadsto \color{blue}{1 - \frac{1 - x}{1 + y} \cdot y} \]
    4. Taylor expanded in y around 0 99.2%

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

    if 1 < y

    1. Initial program 38.7%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg38.7%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*60.4%

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/60.4%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*60.5%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity60.5%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative60.5%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub060.5%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-60.5%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval60.5%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative60.5%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified60.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 98.3%

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 1}{y} + x} \]
    5. Step-by-step derivation
      1. +-commutative98.3%

        \[\leadsto \color{blue}{x + -1 \cdot \frac{x - 1}{y}} \]
      2. mul-1-neg98.3%

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      4. sub-neg98.3%

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

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

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

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

Alternative 10: 73.3% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.62 \cdot 10^{-77}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{-30}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 86000000000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.0)
   x
   (if (<= y 1.62e-77)
     1.0
     (if (<= y 5.1e-30) (* x y) (if (<= y 86000000000.0) 1.0 x)))))
double code(double x, double y) {
	double tmp;
	if (y <= -1.0) {
		tmp = x;
	} else if (y <= 1.62e-77) {
		tmp = 1.0;
	} else if (y <= 5.1e-30) {
		tmp = x * y;
	} else if (y <= 86000000000.0) {
		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 <= 1.62d-77) then
        tmp = 1.0d0
    else if (y <= 5.1d-30) then
        tmp = x * y
    else if (y <= 86000000000.0d0) 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 <= 1.62e-77) {
		tmp = 1.0;
	} else if (y <= 5.1e-30) {
		tmp = x * y;
	} else if (y <= 86000000000.0) {
		tmp = 1.0;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.0:
		tmp = x
	elif y <= 1.62e-77:
		tmp = 1.0
	elif y <= 5.1e-30:
		tmp = x * y
	elif y <= 86000000000.0:
		tmp = 1.0
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.0)
		tmp = x;
	elseif (y <= 1.62e-77)
		tmp = 1.0;
	elseif (y <= 5.1e-30)
		tmp = Float64(x * y);
	elseif (y <= 86000000000.0)
		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 <= 1.62e-77)
		tmp = 1.0;
	elseif (y <= 5.1e-30)
		tmp = x * y;
	elseif (y <= 86000000000.0)
		tmp = 1.0;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 1.62e-77], 1.0, If[LessEqual[y, 5.1e-30], N[(x * y), $MachinePrecision], If[LessEqual[y, 86000000000.0], 1.0, x]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 1.62 \cdot 10^{-77}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 5.1 \cdot 10^{-30}:\\
\;\;\;\;x \cdot y\\

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

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


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

    1. Initial program 37.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg37.0%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*59.6%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity59.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/59.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*59.7%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity59.7%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative59.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub059.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-59.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval59.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative59.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified59.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 76.3%

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

    if -1 < y < 1.62000000000000006e-77 or 5.09999999999999972e-30 < y < 8.6e10

    1. Initial program 99.1%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg99.1%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*98.9%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity98.9%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/99.0%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*99.1%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity99.1%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative99.1%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub099.1%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-99.1%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval99.1%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative99.1%

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

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

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

    if 1.62000000000000006e-77 < y < 5.09999999999999972e-30

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/99.7%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*100.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity100.0%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub0100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative100.0%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in x around inf 79.1%

      \[\leadsto \color{blue}{\frac{y \cdot x}{1 + y}} \]
    5. Taylor expanded in y around 0 79.1%

      \[\leadsto \color{blue}{y \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification76.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.62 \cdot 10^{-77}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{-30}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 86000000000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 11: 74.0% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 86000000000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.0) x (if (<= y 86000000000.0) 1.0 x)))
double code(double x, double y) {
	double tmp;
	if (y <= -1.0) {
		tmp = x;
	} else if (y <= 86000000000.0) {
		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 <= 86000000000.0d0) 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 <= 86000000000.0) {
		tmp = 1.0;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.0:
		tmp = x
	elif y <= 86000000000.0:
		tmp = 1.0
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.0)
		tmp = x;
	elseif (y <= 86000000000.0)
		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 <= 86000000000.0)
		tmp = 1.0;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.0], x, If[LessEqual[y, 86000000000.0], 1.0, x]]
\begin{array}{l}

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

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

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


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

    1. Initial program 37.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg37.0%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*59.6%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity59.6%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/59.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*59.7%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity59.7%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative59.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub059.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-59.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval59.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative59.7%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified59.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{1 + y}, x + -1, 1\right)} \]
    4. Taylor expanded in y around inf 76.3%

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

    if -1 < y < 8.6e10

    1. Initial program 99.2%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Step-by-step derivation
      1. sub-neg99.2%

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

        \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
      3. associate-/l*99.0%

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

        \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
      5. *-lft-identity99.0%

        \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
      6. associate-*l/99.0%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
      8. associate-/l*99.2%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
      9. *-lft-identity99.2%

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
      10. +-commutative99.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
      11. neg-sub099.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
      12. associate--r-99.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
      13. metadata-eval99.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
      14. +-commutative99.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
    3. Simplified99.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 86000000000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 12: 38.6% 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 68.3%

    \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
  2. Step-by-step derivation
    1. sub-neg68.3%

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

      \[\leadsto \color{blue}{\left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1} \]
    3. associate-/l*79.5%

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

      \[\leadsto \color{blue}{\frac{-\left(1 - x\right)}{\frac{y + 1}{y}}} + 1 \]
    5. *-lft-identity79.5%

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-\left(1 - x\right)\right)}}{\frac{y + 1}{y}} + 1 \]
    6. associate-*l/79.5%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\frac{y + 1}{y}}, -\left(1 - x\right), 1\right)} \]
    8. associate-/l*79.6%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1 \cdot y}{y + 1}}, -\left(1 - x\right), 1\right) \]
    9. *-lft-identity79.6%

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{y}}{y + 1}, -\left(1 - x\right), 1\right) \]
    10. +-commutative79.6%

      \[\leadsto \mathsf{fma}\left(\frac{y}{\color{blue}{1 + y}}, -\left(1 - x\right), 1\right) \]
    11. neg-sub079.6%

      \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{0 - \left(1 - x\right)}, 1\right) \]
    12. associate--r-79.6%

      \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{\left(0 - 1\right) + x}, 1\right) \]
    13. metadata-eval79.6%

      \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{-1} + x, 1\right) \]
    14. +-commutative79.6%

      \[\leadsto \mathsf{fma}\left(\frac{y}{1 + y}, \color{blue}{x + -1}, 1\right) \]
  3. Simplified79.6%

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

    \[\leadsto \color{blue}{1} \]
  5. Final simplification38.1%

    \[\leadsto 1 \]

Developer target: 99.7% accurate, 0.7× 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 2023213 
(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))))