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

Percentage Accurate: 66.1% → 99.9%
Time: 18.3s
Alternatives: 14
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y):
	return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y)
	return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
end
function tmp = code(x, y)
	tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 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: 66.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
public static double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
def code(x, y):
	return 1.0 - (((1.0 - x) * y) / (y + 1.0))
function code(x, y)
	return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
end
function tmp = code(x, y)
	tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.9% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(y + 1\right)}^{2}\\ t_1 := \frac{{y}^{2}}{t\_0}\\ t_2 := \frac{y}{y + 1}\\ t_3 := 1 + \left(t\_1 + t\_2\right)\\ t_4 := {\left(y + 1\right)}^{3}\\ t_5 := -1 + \left(\frac{y}{-1 - y} - t\_1\right)\\ \mathbf{if}\;y \leq -19500 \lor \neg \left(y \leq 20000\right):\\ \;\;\;\;x + \left(\frac{1 - x}{{y}^{3}} - \left(\frac{x + -1}{y} - \frac{x + -1}{{y}^{2}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(3, \frac{{y}^{3}}{t\_4 \cdot t\_3}, \frac{\left(1 - \frac{{y}^{3}}{t\_4}\right) \cdot \left(t\_2 - \frac{{y}^{2} \cdot -2}{t\_0}\right)}{{t\_3}^{2}}\right), \frac{-1}{t\_5}\right) + \frac{{y}^{3}}{t\_4 \cdot t\_5}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (pow (+ y 1.0) 2.0))
        (t_1 (/ (pow y 2.0) t_0))
        (t_2 (/ y (+ y 1.0)))
        (t_3 (+ 1.0 (+ t_1 t_2)))
        (t_4 (pow (+ y 1.0) 3.0))
        (t_5 (+ -1.0 (- (/ y (- -1.0 y)) t_1))))
   (if (or (<= y -19500.0) (not (<= y 20000.0)))
     (+
      x
      (-
       (/ (- 1.0 x) (pow y 3.0))
       (- (/ (+ x -1.0) y) (/ (+ x -1.0) (pow y 2.0)))))
     (+
      (fma
       x
       (fma
        3.0
        (/ (pow y 3.0) (* t_4 t_3))
        (/
         (* (- 1.0 (/ (pow y 3.0) t_4)) (- t_2 (/ (* (pow y 2.0) -2.0) t_0)))
         (pow t_3 2.0)))
       (/ -1.0 t_5))
      (/ (pow y 3.0) (* t_4 t_5))))))
double code(double x, double y) {
	double t_0 = pow((y + 1.0), 2.0);
	double t_1 = pow(y, 2.0) / t_0;
	double t_2 = y / (y + 1.0);
	double t_3 = 1.0 + (t_1 + t_2);
	double t_4 = pow((y + 1.0), 3.0);
	double t_5 = -1.0 + ((y / (-1.0 - y)) - t_1);
	double tmp;
	if ((y <= -19500.0) || !(y <= 20000.0)) {
		tmp = x + (((1.0 - x) / pow(y, 3.0)) - (((x + -1.0) / y) - ((x + -1.0) / pow(y, 2.0))));
	} else {
		tmp = fma(x, fma(3.0, (pow(y, 3.0) / (t_4 * t_3)), (((1.0 - (pow(y, 3.0) / t_4)) * (t_2 - ((pow(y, 2.0) * -2.0) / t_0))) / pow(t_3, 2.0))), (-1.0 / t_5)) + (pow(y, 3.0) / (t_4 * t_5));
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(y + 1.0) ^ 2.0
	t_1 = Float64((y ^ 2.0) / t_0)
	t_2 = Float64(y / Float64(y + 1.0))
	t_3 = Float64(1.0 + Float64(t_1 + t_2))
	t_4 = Float64(y + 1.0) ^ 3.0
	t_5 = Float64(-1.0 + Float64(Float64(y / Float64(-1.0 - y)) - t_1))
	tmp = 0.0
	if ((y <= -19500.0) || !(y <= 20000.0))
		tmp = Float64(x + Float64(Float64(Float64(1.0 - x) / (y ^ 3.0)) - Float64(Float64(Float64(x + -1.0) / y) - Float64(Float64(x + -1.0) / (y ^ 2.0)))));
	else
		tmp = Float64(fma(x, fma(3.0, Float64((y ^ 3.0) / Float64(t_4 * t_3)), Float64(Float64(Float64(1.0 - Float64((y ^ 3.0) / t_4)) * Float64(t_2 - Float64(Float64((y ^ 2.0) * -2.0) / t_0))) / (t_3 ^ 2.0))), Float64(-1.0 / t_5)) + Float64((y ^ 3.0) / Float64(t_4 * t_5)));
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[Power[N[(y + 1.0), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[y, 2.0], $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 + N[(t$95$1 + t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(y + 1.0), $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$5 = N[(-1.0 + N[(N[(y / N[(-1.0 - y), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[y, -19500.0], N[Not[LessEqual[y, 20000.0]], $MachinePrecision]], N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x + -1.0), $MachinePrecision] / N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(3.0 * N[(N[Power[y, 3.0], $MachinePrecision] / N[(t$95$4 * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1.0 - N[(N[Power[y, 3.0], $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 - N[(N[(N[Power[y, 2.0], $MachinePrecision] * -2.0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[t$95$3, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$5), $MachinePrecision]), $MachinePrecision] + N[(N[Power[y, 3.0], $MachinePrecision] / N[(t$95$4 * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(y + 1\right)}^{2}\\
t_1 := \frac{{y}^{2}}{t\_0}\\
t_2 := \frac{y}{y + 1}\\
t_3 := 1 + \left(t\_1 + t\_2\right)\\
t_4 := {\left(y + 1\right)}^{3}\\
t_5 := -1 + \left(\frac{y}{-1 - y} - t\_1\right)\\
\mathbf{if}\;y \leq -19500 \lor \neg \left(y \leq 20000\right):\\
\;\;\;\;x + \left(\frac{1 - x}{{y}^{3}} - \left(\frac{x + -1}{y} - \frac{x + -1}{{y}^{2}}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(3, \frac{{y}^{3}}{t\_4 \cdot t\_3}, \frac{\left(1 - \frac{{y}^{3}}{t\_4}\right) \cdot \left(t\_2 - \frac{{y}^{2} \cdot -2}{t\_0}\right)}{{t\_3}^{2}}\right), \frac{-1}{t\_5}\right) + \frac{{y}^{3}}{t\_4 \cdot t\_5}\\


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

    1. Initial program 30.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -19500 < y < 2e4

    1. Initial program 99.8%

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

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

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

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

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

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. sub-neg99.8%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \frac{1 - x}{-1 - y}} + 1 \]
      10. flip3-+93.1%

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

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

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

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

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

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

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

Alternative 2: 99.9% accurate, 0.0× speedup?

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

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

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


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

    1. Initial program 30.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -19500 < y < 14000

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.9% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 30.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x + \left(-1 \cdot \frac{1 - x}{{y}^{2}} + \frac{-1 \cdot x + \color{blue}{-1 \cdot -1}}{y}\right) \]
      10. distribute-lft-in99.9%

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

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

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

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

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

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

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

    if -2.8e5 < y < 2.5e5

    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. +-commutative99.6%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 72.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+60}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-16}:\\ \;\;\;\;1 - y\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+105}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -6e+60)
   x
   (if (<= y -1.0)
     (/ 1.0 y)
     (if (<= y 5e-16)
       (- 1.0 y)
       (if (<= y 2.9e+105) x (if (<= y 2.6e+139) (/ 1.0 y) x))))))
double code(double x, double y) {
	double tmp;
	if (y <= -6e+60) {
		tmp = x;
	} else if (y <= -1.0) {
		tmp = 1.0 / y;
	} else if (y <= 5e-16) {
		tmp = 1.0 - y;
	} else if (y <= 2.9e+105) {
		tmp = x;
	} else if (y <= 2.6e+139) {
		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 <= (-6d+60)) then
        tmp = x
    else if (y <= (-1.0d0)) then
        tmp = 1.0d0 / y
    else if (y <= 5d-16) then
        tmp = 1.0d0 - y
    else if (y <= 2.9d+105) then
        tmp = x
    else if (y <= 2.6d+139) 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 <= -6e+60) {
		tmp = x;
	} else if (y <= -1.0) {
		tmp = 1.0 / y;
	} else if (y <= 5e-16) {
		tmp = 1.0 - y;
	} else if (y <= 2.9e+105) {
		tmp = x;
	} else if (y <= 2.6e+139) {
		tmp = 1.0 / y;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -6e+60:
		tmp = x
	elif y <= -1.0:
		tmp = 1.0 / y
	elif y <= 5e-16:
		tmp = 1.0 - y
	elif y <= 2.9e+105:
		tmp = x
	elif y <= 2.6e+139:
		tmp = 1.0 / y
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -6e+60)
		tmp = x;
	elseif (y <= -1.0)
		tmp = Float64(1.0 / y);
	elseif (y <= 5e-16)
		tmp = Float64(1.0 - y);
	elseif (y <= 2.9e+105)
		tmp = x;
	elseif (y <= 2.6e+139)
		tmp = Float64(1.0 / y);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -6e+60)
		tmp = x;
	elseif (y <= -1.0)
		tmp = 1.0 / y;
	elseif (y <= 5e-16)
		tmp = 1.0 - y;
	elseif (y <= 2.9e+105)
		tmp = x;
	elseif (y <= 2.6e+139)
		tmp = 1.0 / y;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -6e+60], x, If[LessEqual[y, -1.0], N[(1.0 / y), $MachinePrecision], If[LessEqual[y, 5e-16], N[(1.0 - y), $MachinePrecision], If[LessEqual[y, 2.9e+105], x, If[LessEqual[y, 2.6e+139], N[(1.0 / y), $MachinePrecision], x]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+60}:\\
\;\;\;\;x\\

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

\mathbf{elif}\;y \leq 5 \cdot 10^{-16}:\\
\;\;\;\;1 - y\\

\mathbf{elif}\;y \leq 2.9 \cdot 10^{+105}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\
\;\;\;\;\frac{1}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.9999999999999997e60 or 5.0000000000000004e-16 < y < 2.9000000000000001e105 or 2.60000000000000022e139 < y

    1. Initial program 35.0%

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

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

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

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

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

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

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

    if -5.9999999999999997e60 < y < -1 or 2.9000000000000001e105 < y < 2.60000000000000022e139

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{-1}{1 + y}}, 1\right) \]
    6. Step-by-step derivation
      1. metadata-eval17.5%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1} + \left(-y\right)}, 1\right) \]
      6. sub-neg17.5%

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1 - y}}, 1\right) \]
    7. Simplified17.5%

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

      \[\leadsto \color{blue}{\frac{1}{y} - \frac{1}{{y}^{2}}} \]
    9. Taylor expanded in y around inf 72.4%

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

    if -1 < y < 5.0000000000000004e-16

    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. *-commutative100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{-1}{1 + y}}, 1\right) \]
    6. Step-by-step derivation
      1. metadata-eval83.9%

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-\frac{1}{1 + y}}, 1\right) \]
      3. distribute-neg-frac283.9%

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{1}{-\left(1 + y\right)}}, 1\right) \]
      4. distribute-neg-in83.9%

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

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1} + \left(-y\right)}, 1\right) \]
      6. sub-neg83.9%

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1 - y}}, 1\right) \]
    7. Simplified83.9%

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

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

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

        \[\leadsto \color{blue}{1 - y} \]
    10. Simplified83.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{+60}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-16}:\\ \;\;\;\;1 - y\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+105}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 72.9% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.65 \cdot 10^{+59}:\\
\;\;\;\;x\\

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

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

\mathbf{elif}\;y \leq 4.4 \cdot 10^{+102}:\\
\;\;\;\;x - \frac{x}{y}\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\
\;\;\;\;\frac{1}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.6499999999999998e59 or 2.60000000000000022e139 < y

    1. Initial program 26.1%

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

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

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

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

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

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

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

    if -2.6499999999999998e59 < y < -1 or 4.40000000000000015e102 < y < 2.60000000000000022e139

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{-1}{1 + y}}, 1\right) \]
    6. Step-by-step derivation
      1. metadata-eval17.5%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1} + \left(-y\right)}, 1\right) \]
      6. sub-neg17.5%

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1 - y}}, 1\right) \]
    7. Simplified17.5%

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

      \[\leadsto \color{blue}{\frac{1}{y} - \frac{1}{{y}^{2}}} \]
    9. Taylor expanded in y around inf 72.4%

      \[\leadsto \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. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{-1}{1 + y}}, 1\right) \]
    6. Step-by-step derivation
      1. metadata-eval81.8%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1} + \left(-y\right)}, 1\right) \]
      6. sub-neg81.8%

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1 - y}}, 1\right) \]
    7. Simplified81.8%

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

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

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

        \[\leadsto \color{blue}{1 - y} \]
    10. Simplified81.1%

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

    if 1 < y < 4.40000000000000015e102

    1. Initial program 56.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y \cdot x}}{1 + y} \]
      2. associate-/l*63.7%

        \[\leadsto \color{blue}{y \cdot \frac{x}{1 + y}} \]
    7. Simplified63.7%

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

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

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

        \[\leadsto \color{blue}{x - \frac{x}{y}} \]
    10. Simplified62.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.65 \cdot 10^{+59}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;1 - y\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{+102}:\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 84.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.35 \cdot 10^{+62}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 440:\\ \;\;\;\;1 + y \cdot x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -3.35e+62)
   x
   (if (<= y -1.0)
     (/ 1.0 y)
     (if (<= y 440.0)
       (+ 1.0 (* y x))
       (if (<= y 2e+104) (- x (/ x y)) (if (<= y 2.6e+139) (/ 1.0 y) x))))))
double code(double x, double y) {
	double tmp;
	if (y <= -3.35e+62) {
		tmp = x;
	} else if (y <= -1.0) {
		tmp = 1.0 / y;
	} else if (y <= 440.0) {
		tmp = 1.0 + (y * x);
	} else if (y <= 2e+104) {
		tmp = x - (x / y);
	} else if (y <= 2.6e+139) {
		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 <= (-3.35d+62)) then
        tmp = x
    else if (y <= (-1.0d0)) then
        tmp = 1.0d0 / y
    else if (y <= 440.0d0) then
        tmp = 1.0d0 + (y * x)
    else if (y <= 2d+104) then
        tmp = x - (x / y)
    else if (y <= 2.6d+139) 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 <= -3.35e+62) {
		tmp = x;
	} else if (y <= -1.0) {
		tmp = 1.0 / y;
	} else if (y <= 440.0) {
		tmp = 1.0 + (y * x);
	} else if (y <= 2e+104) {
		tmp = x - (x / y);
	} else if (y <= 2.6e+139) {
		tmp = 1.0 / y;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -3.35e+62:
		tmp = x
	elif y <= -1.0:
		tmp = 1.0 / y
	elif y <= 440.0:
		tmp = 1.0 + (y * x)
	elif y <= 2e+104:
		tmp = x - (x / y)
	elif y <= 2.6e+139:
		tmp = 1.0 / y
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -3.35e+62)
		tmp = x;
	elseif (y <= -1.0)
		tmp = Float64(1.0 / y);
	elseif (y <= 440.0)
		tmp = Float64(1.0 + Float64(y * x));
	elseif (y <= 2e+104)
		tmp = Float64(x - Float64(x / y));
	elseif (y <= 2.6e+139)
		tmp = Float64(1.0 / y);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -3.35e+62)
		tmp = x;
	elseif (y <= -1.0)
		tmp = 1.0 / y;
	elseif (y <= 440.0)
		tmp = 1.0 + (y * x);
	elseif (y <= 2e+104)
		tmp = x - (x / y);
	elseif (y <= 2.6e+139)
		tmp = 1.0 / y;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -3.35e+62], x, If[LessEqual[y, -1.0], N[(1.0 / y), $MachinePrecision], If[LessEqual[y, 440.0], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2e+104], N[(x - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+139], N[(1.0 / y), $MachinePrecision], x]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.35 \cdot 10^{+62}:\\
\;\;\;\;x\\

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

\mathbf{elif}\;y \leq 440:\\
\;\;\;\;1 + y \cdot x\\

\mathbf{elif}\;y \leq 2 \cdot 10^{+104}:\\
\;\;\;\;x - \frac{x}{y}\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\
\;\;\;\;\frac{1}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.3499999999999998e62 or 2.60000000000000022e139 < y

    1. Initial program 26.1%

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

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

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

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

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

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

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

    if -3.3499999999999998e62 < y < -1 or 2e104 < y < 2.60000000000000022e139

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{-1}{1 + y}}, 1\right) \]
    6. Step-by-step derivation
      1. metadata-eval17.5%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1} + \left(-y\right)}, 1\right) \]
      6. sub-neg17.5%

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1 - y}}, 1\right) \]
    7. Simplified17.5%

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

      \[\leadsto \color{blue}{\frac{1}{y} - \frac{1}{{y}^{2}}} \]
    9. Taylor expanded in y around inf 72.4%

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

    if -1 < y < 440

    1. Initial program 99.9%

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{-1 \cdot \left(x \cdot y\right)} \]
    7. Step-by-step derivation
      1. mul-1-neg97.2%

        \[\leadsto 1 - \color{blue}{\left(-x \cdot y\right)} \]
      2. distribute-lft-neg-out97.2%

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

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

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

    if 440 < y < 2e104

    1. Initial program 55.3%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y \cdot x}}{1 + y} \]
      2. associate-/l*66.1%

        \[\leadsto \color{blue}{y \cdot \frac{x}{1 + y}} \]
    7. Simplified66.1%

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

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

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

        \[\leadsto \color{blue}{x - \frac{x}{y}} \]
    10. Simplified64.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.35 \cdot 10^{+62}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 440:\\ \;\;\;\;1 + y \cdot x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.7 \cdot 10^{+60}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-16}:\\ \;\;\;\;1 + y \cdot x\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+103}:\\ \;\;\;\;y \cdot \frac{x}{y + 1}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -5.7e+60)
   x
   (if (<= y -1.0)
     (/ 1.0 y)
     (if (<= y 5e-16)
       (+ 1.0 (* y x))
       (if (<= y 1.3e+103)
         (* y (/ x (+ y 1.0)))
         (if (<= y 2.6e+139) (/ 1.0 y) x))))))
double code(double x, double y) {
	double tmp;
	if (y <= -5.7e+60) {
		tmp = x;
	} else if (y <= -1.0) {
		tmp = 1.0 / y;
	} else if (y <= 5e-16) {
		tmp = 1.0 + (y * x);
	} else if (y <= 1.3e+103) {
		tmp = y * (x / (y + 1.0));
	} else if (y <= 2.6e+139) {
		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 <= (-5.7d+60)) then
        tmp = x
    else if (y <= (-1.0d0)) then
        tmp = 1.0d0 / y
    else if (y <= 5d-16) then
        tmp = 1.0d0 + (y * x)
    else if (y <= 1.3d+103) then
        tmp = y * (x / (y + 1.0d0))
    else if (y <= 2.6d+139) 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 <= -5.7e+60) {
		tmp = x;
	} else if (y <= -1.0) {
		tmp = 1.0 / y;
	} else if (y <= 5e-16) {
		tmp = 1.0 + (y * x);
	} else if (y <= 1.3e+103) {
		tmp = y * (x / (y + 1.0));
	} else if (y <= 2.6e+139) {
		tmp = 1.0 / y;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -5.7e+60:
		tmp = x
	elif y <= -1.0:
		tmp = 1.0 / y
	elif y <= 5e-16:
		tmp = 1.0 + (y * x)
	elif y <= 1.3e+103:
		tmp = y * (x / (y + 1.0))
	elif y <= 2.6e+139:
		tmp = 1.0 / y
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -5.7e+60)
		tmp = x;
	elseif (y <= -1.0)
		tmp = Float64(1.0 / y);
	elseif (y <= 5e-16)
		tmp = Float64(1.0 + Float64(y * x));
	elseif (y <= 1.3e+103)
		tmp = Float64(y * Float64(x / Float64(y + 1.0)));
	elseif (y <= 2.6e+139)
		tmp = Float64(1.0 / y);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -5.7e+60)
		tmp = x;
	elseif (y <= -1.0)
		tmp = 1.0 / y;
	elseif (y <= 5e-16)
		tmp = 1.0 + (y * x);
	elseif (y <= 1.3e+103)
		tmp = y * (x / (y + 1.0));
	elseif (y <= 2.6e+139)
		tmp = 1.0 / y;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -5.7e+60], x, If[LessEqual[y, -1.0], N[(1.0 / y), $MachinePrecision], If[LessEqual[y, 5e-16], N[(1.0 + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.3e+103], N[(y * N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+139], N[(1.0 / y), $MachinePrecision], x]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.7 \cdot 10^{+60}:\\
\;\;\;\;x\\

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

\mathbf{elif}\;y \leq 5 \cdot 10^{-16}:\\
\;\;\;\;1 + y \cdot x\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{+103}:\\
\;\;\;\;y \cdot \frac{x}{y + 1}\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\
\;\;\;\;\frac{1}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -5.69999999999999978e60 or 2.60000000000000022e139 < y

    1. Initial program 26.1%

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

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

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

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

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

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

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

    if -5.69999999999999978e60 < y < -1 or 1.3000000000000001e103 < y < 2.60000000000000022e139

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{-1}{1 + y}}, 1\right) \]
    6. Step-by-step derivation
      1. metadata-eval17.5%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1} + \left(-y\right)}, 1\right) \]
      6. sub-neg17.5%

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1 - y}}, 1\right) \]
    7. Simplified17.5%

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

      \[\leadsto \color{blue}{\frac{1}{y} - \frac{1}{{y}^{2}}} \]
    9. Taylor expanded in y around inf 72.4%

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

    if -1 < y < 5.0000000000000004e-16

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{-1 \cdot \left(x \cdot y\right)} \]
    7. Step-by-step derivation
      1. mul-1-neg99.0%

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

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

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

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

    if 5.0000000000000004e-16 < y < 1.3000000000000001e103

    1. Initial program 61.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{1 + y}} \]
    6. Step-by-step derivation
      1. *-commutative61.4%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{1 + y} \]
      2. associate-/l*67.4%

        \[\leadsto \color{blue}{y \cdot \frac{x}{1 + y}} \]
    7. Simplified67.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.7 \cdot 10^{+60}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-16}:\\ \;\;\;\;1 + y \cdot x\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+103}:\\ \;\;\;\;y \cdot \frac{x}{y + 1}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 84.8% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+58}:\\
\;\;\;\;x\\

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

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

\mathbf{elif}\;y \leq 3 \cdot 10^{+105}:\\
\;\;\;\;y \cdot \frac{x}{y + 1}\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\
\;\;\;\;\frac{1}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -7.5000000000000001e58 or 2.60000000000000022e139 < y

    1. Initial program 26.1%

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

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

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

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

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

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

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

    if -7.5000000000000001e58 < y < -1 or 3.0000000000000001e105 < y < 2.60000000000000022e139

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{-1}{1 + y}}, 1\right) \]
    6. Step-by-step derivation
      1. metadata-eval17.5%

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1} + \left(-y\right)}, 1\right) \]
      6. sub-neg17.5%

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1 - y}}, 1\right) \]
    7. Simplified17.5%

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

      \[\leadsto \color{blue}{\frac{1}{y} - \frac{1}{{y}^{2}}} \]
    9. Taylor expanded in y around inf 72.4%

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

    if -1 < y < 5.0000000000000004e-16

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if 5.0000000000000004e-16 < y < 3.0000000000000001e105

    1. Initial program 61.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{1 + y}} \]
    6. Step-by-step derivation
      1. *-commutative61.4%

        \[\leadsto \frac{\color{blue}{y \cdot x}}{1 + y} \]
      2. associate-/l*67.4%

        \[\leadsto \color{blue}{y \cdot \frac{x}{1 + y}} \]
    7. Simplified67.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{+58}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-16}:\\ \;\;\;\;1 + y \cdot \left(x + -1\right)\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+105}:\\ \;\;\;\;y \cdot \frac{x}{y + 1}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+139}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 99.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 28.3%

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

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{\frac{1 - x}{y}} \]
      3. remove-double-neg99.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.35e8 < y < 1.35e8

    1. Initial program 99.4%

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

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

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

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

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

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

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

Alternative 10: 99.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 28.3%

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

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{\frac{1 - x}{y}} \]
      3. remove-double-neg99.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.2e7 < y < 1.16e8

    1. Initial program 99.4%

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

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

Alternative 11: 98.4% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 32.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x - \frac{x - 1}{y}} \]
      12. sub-neg96.6%

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

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

      \[\leadsto \color{blue}{x - \frac{x + -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. associate-/l*100.0%

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

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

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

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

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

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

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

Alternative 12: 73.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;y \leq 5 \cdot 10^{-16}:\\
\;\;\;\;1 - y\\

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


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

    1. Initial program 33.9%

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

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

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

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

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

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

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

    if -1 < y < 5.0000000000000004e-16

    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. *-commutative100.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{-1}{1 + y}}, 1\right) \]
    6. Step-by-step derivation
      1. metadata-eval83.9%

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-\frac{1}{1 + y}}, 1\right) \]
      3. distribute-neg-frac283.9%

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{1}{-\left(1 + y\right)}}, 1\right) \]
      4. distribute-neg-in83.9%

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

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1} + \left(-y\right)}, 1\right) \]
      6. sub-neg83.9%

        \[\leadsto \mathsf{fma}\left(y, \frac{1}{\color{blue}{-1 - y}}, 1\right) \]
    7. Simplified83.9%

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

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

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

        \[\leadsto \color{blue}{1 - y} \]
    10. Simplified83.3%

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

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

Alternative 13: 73.6% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;y \leq 5 \cdot 10^{-16}:\\
\;\;\;\;1\\

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


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

    1. Initial program 33.9%

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

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

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

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

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

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

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

    if -1 < y < 5.0000000000000004e-16

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

Alternative 14: 39.0% accurate, 11.0× speedup?

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

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

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

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

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

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

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

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

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

    \[\leadsto 1 \]
  7. Add Preprocessing

Developer target: 99.6% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}

Reproduce

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