Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 87.9% → 99.9%
Time: 10.5s
Alternatives: 14
Speedup: 1.0×

Specification

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

\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 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: 87.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

\\
\frac{x}{\frac{x + 1}{1 + \frac{x}{y}}}
\end{array}
Derivation
  1. Initial program 87.7%

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

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

    \[\leadsto \color{blue}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
  4. Final simplification99.9%

    \[\leadsto \frac{x}{\frac{x + 1}{1 + \frac{x}{y}}} \]

Alternative 2: 72.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{\frac{y}{x}}\\ t_1 := \frac{x + -1}{y}\\ \mathbf{if}\;x \leq -1 \cdot 10^{+56}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.52 \cdot 10^{+32}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-47}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.45:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (/ y x))) (t_1 (/ (+ x -1.0) y)))
   (if (<= x -1e+56)
     (/ x y)
     (if (<= x -1.52e+32)
       1.0
       (if (<= x -1.0)
         t_1
         (if (<= x -2.5e-47)
           t_0
           (if (<= x 5.2e-127) x (if (<= x 1.45) t_0 t_1))))))))
double code(double x, double y) {
	double t_0 = x / (y / x);
	double t_1 = (x + -1.0) / y;
	double tmp;
	if (x <= -1e+56) {
		tmp = x / y;
	} else if (x <= -1.52e+32) {
		tmp = 1.0;
	} else if (x <= -1.0) {
		tmp = t_1;
	} else if (x <= -2.5e-47) {
		tmp = t_0;
	} else if (x <= 5.2e-127) {
		tmp = x;
	} else if (x <= 1.45) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x / (y / x)
    t_1 = (x + (-1.0d0)) / y
    if (x <= (-1d+56)) then
        tmp = x / y
    else if (x <= (-1.52d+32)) then
        tmp = 1.0d0
    else if (x <= (-1.0d0)) then
        tmp = t_1
    else if (x <= (-2.5d-47)) then
        tmp = t_0
    else if (x <= 5.2d-127) then
        tmp = x
    else if (x <= 1.45d0) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x / (y / x);
	double t_1 = (x + -1.0) / y;
	double tmp;
	if (x <= -1e+56) {
		tmp = x / y;
	} else if (x <= -1.52e+32) {
		tmp = 1.0;
	} else if (x <= -1.0) {
		tmp = t_1;
	} else if (x <= -2.5e-47) {
		tmp = t_0;
	} else if (x <= 5.2e-127) {
		tmp = x;
	} else if (x <= 1.45) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (y / x)
	t_1 = (x + -1.0) / y
	tmp = 0
	if x <= -1e+56:
		tmp = x / y
	elif x <= -1.52e+32:
		tmp = 1.0
	elif x <= -1.0:
		tmp = t_1
	elif x <= -2.5e-47:
		tmp = t_0
	elif x <= 5.2e-127:
		tmp = x
	elif x <= 1.45:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(y / x))
	t_1 = Float64(Float64(x + -1.0) / y)
	tmp = 0.0
	if (x <= -1e+56)
		tmp = Float64(x / y);
	elseif (x <= -1.52e+32)
		tmp = 1.0;
	elseif (x <= -1.0)
		tmp = t_1;
	elseif (x <= -2.5e-47)
		tmp = t_0;
	elseif (x <= 5.2e-127)
		tmp = x;
	elseif (x <= 1.45)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (y / x);
	t_1 = (x + -1.0) / y;
	tmp = 0.0;
	if (x <= -1e+56)
		tmp = x / y;
	elseif (x <= -1.52e+32)
		tmp = 1.0;
	elseif (x <= -1.0)
		tmp = t_1;
	elseif (x <= -2.5e-47)
		tmp = t_0;
	elseif (x <= 5.2e-127)
		tmp = x;
	elseif (x <= 1.45)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -1e+56], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.52e+32], 1.0, If[LessEqual[x, -1.0], t$95$1, If[LessEqual[x, -2.5e-47], t$95$0, If[LessEqual[x, 5.2e-127], x, If[LessEqual[x, 1.45], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{\frac{y}{x}}\\
t_1 := \frac{x + -1}{y}\\
\mathbf{if}\;x \leq -1 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;x \leq -1.52 \cdot 10^{+32}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -1:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -2.5 \cdot 10^{-47}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 1.45:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -1.00000000000000009e56

    1. Initial program 74.7%

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

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

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

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

    if -1.00000000000000009e56 < x < -1.5200000000000001e32

    1. Initial program 100.0%

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y} + x \cdot 1}}{x + 1} \]
      2. *-rgt-identity100.0%

        \[\leadsto \frac{x \cdot \frac{x}{y} + \color{blue}{x}}{x + 1} \]
    3. Applied egg-rr100.0%

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

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    6. Simplified86.4%

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]
    7. Taylor expanded in x around inf 86.4%

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

    if -1.5200000000000001e32 < x < -1 or 1.44999999999999996 < x

    1. Initial program 78.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1 < x < -2.50000000000000006e-47 or 5.19999999999999982e-127 < x < 1.44999999999999996

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

    if -2.50000000000000006e-47 < x < 5.19999999999999982e-127

    1. Initial program 99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+56}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.52 \cdot 10^{+32}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x + -1}{y}\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-47}:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.45:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + -1}{y}\\ \end{array} \]

Alternative 3: 72.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x + -1}{y}\\ \mathbf{if}\;x \leq -1.9 \cdot 10^{+57}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{+32}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-46}:\\ \;\;\;\;\frac{1}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.3:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (+ x -1.0) y)))
   (if (<= x -1.9e+57)
     (/ x y)
     (if (<= x -1.45e+32)
       1.0
       (if (<= x -1.0)
         t_0
         (if (<= x -5.2e-46)
           (* (/ 1.0 y) (* x x))
           (if (<= x 5.2e-127) x (if (<= x 1.3) (/ x (/ y x)) t_0))))))))
double code(double x, double y) {
	double t_0 = (x + -1.0) / y;
	double tmp;
	if (x <= -1.9e+57) {
		tmp = x / y;
	} else if (x <= -1.45e+32) {
		tmp = 1.0;
	} else if (x <= -1.0) {
		tmp = t_0;
	} else if (x <= -5.2e-46) {
		tmp = (1.0 / y) * (x * x);
	} else if (x <= 5.2e-127) {
		tmp = x;
	} else if (x <= 1.3) {
		tmp = x / (y / x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x + (-1.0d0)) / y
    if (x <= (-1.9d+57)) then
        tmp = x / y
    else if (x <= (-1.45d+32)) then
        tmp = 1.0d0
    else if (x <= (-1.0d0)) then
        tmp = t_0
    else if (x <= (-5.2d-46)) then
        tmp = (1.0d0 / y) * (x * x)
    else if (x <= 5.2d-127) then
        tmp = x
    else if (x <= 1.3d0) then
        tmp = x / (y / x)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (x + -1.0) / y;
	double tmp;
	if (x <= -1.9e+57) {
		tmp = x / y;
	} else if (x <= -1.45e+32) {
		tmp = 1.0;
	} else if (x <= -1.0) {
		tmp = t_0;
	} else if (x <= -5.2e-46) {
		tmp = (1.0 / y) * (x * x);
	} else if (x <= 5.2e-127) {
		tmp = x;
	} else if (x <= 1.3) {
		tmp = x / (y / x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (x + -1.0) / y
	tmp = 0
	if x <= -1.9e+57:
		tmp = x / y
	elif x <= -1.45e+32:
		tmp = 1.0
	elif x <= -1.0:
		tmp = t_0
	elif x <= -5.2e-46:
		tmp = (1.0 / y) * (x * x)
	elif x <= 5.2e-127:
		tmp = x
	elif x <= 1.3:
		tmp = x / (y / x)
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x + -1.0) / y)
	tmp = 0.0
	if (x <= -1.9e+57)
		tmp = Float64(x / y);
	elseif (x <= -1.45e+32)
		tmp = 1.0;
	elseif (x <= -1.0)
		tmp = t_0;
	elseif (x <= -5.2e-46)
		tmp = Float64(Float64(1.0 / y) * Float64(x * x));
	elseif (x <= 5.2e-127)
		tmp = x;
	elseif (x <= 1.3)
		tmp = Float64(x / Float64(y / x));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x + -1.0) / y;
	tmp = 0.0;
	if (x <= -1.9e+57)
		tmp = x / y;
	elseif (x <= -1.45e+32)
		tmp = 1.0;
	elseif (x <= -1.0)
		tmp = t_0;
	elseif (x <= -5.2e-46)
		tmp = (1.0 / y) * (x * x);
	elseif (x <= 5.2e-127)
		tmp = x;
	elseif (x <= 1.3)
		tmp = x / (y / x);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -1.9e+57], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.45e+32], 1.0, If[LessEqual[x, -1.0], t$95$0, If[LessEqual[x, -5.2e-46], N[(N[(1.0 / y), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.2e-127], x, If[LessEqual[x, 1.3], N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x + -1}{y}\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+57}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;x \leq -1.45 \cdot 10^{+32}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -1:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 1.3:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < -1.8999999999999999e57

    1. Initial program 74.7%

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

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

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

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

    if -1.8999999999999999e57 < x < -1.45000000000000001e32

    1. Initial program 100.0%

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y} + x \cdot 1}}{x + 1} \]
      2. *-rgt-identity100.0%

        \[\leadsto \frac{x \cdot \frac{x}{y} + \color{blue}{x}}{x + 1} \]
    3. Applied egg-rr100.0%

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

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    6. Simplified86.4%

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]
    7. Taylor expanded in x around inf 86.4%

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

    if -1.45000000000000001e32 < x < -1 or 1.30000000000000004 < x

    1. Initial program 78.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1 < x < -5.2000000000000004e-46

    1. Initial program 99.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{\color{blue}{\frac{1 + x}{\frac{x}{y}}}} \]
    6. Simplified81.9%

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{x}}} \]
    8. Step-by-step derivation
      1. clear-num62.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y}{x}}{x}}} \]
      2. inv-pow62.3%

        \[\leadsto \color{blue}{{\left(\frac{\frac{y}{x}}{x}\right)}^{-1}} \]
    9. Applied egg-rr62.3%

      \[\leadsto \color{blue}{{\left(\frac{\frac{y}{x}}{x}\right)}^{-1}} \]
    10. Step-by-step derivation
      1. unpow-162.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y}{x}}{x}}} \]
      2. associate-/l/62.3%

        \[\leadsto \frac{1}{\color{blue}{\frac{y}{x \cdot x}}} \]
      3. unpow262.3%

        \[\leadsto \frac{1}{\frac{y}{\color{blue}{{x}^{2}}}} \]
      4. associate-/r/62.7%

        \[\leadsto \color{blue}{\frac{1}{y} \cdot {x}^{2}} \]
      5. unpow262.7%

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

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

    if -5.2000000000000004e-46 < x < 5.19999999999999982e-127

    1. Initial program 99.9%

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

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

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

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

    if 5.19999999999999982e-127 < x < 1.30000000000000004

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{+57}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{+32}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x + -1}{y}\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-46}:\\ \;\;\;\;\frac{1}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.3:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + -1}{y}\\ \end{array} \]

Alternative 4: 73.5% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;x \leq -1.4 \cdot 10^{+32}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 2.35 \cdot 10^{-51}:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.00000000000000009e56 or -1.4e32 < x < -1 or 1 < x

    1. Initial program 76.9%

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

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

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

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

    if -1.00000000000000009e56 < x < -1.4e32

    1. Initial program 100.0%

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y} + x \cdot 1}}{x + 1} \]
      2. *-rgt-identity100.0%

        \[\leadsto \frac{x \cdot \frac{x}{y} + \color{blue}{x}}{x + 1} \]
    3. Applied egg-rr100.0%

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

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    6. Simplified86.4%

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]
    7. Taylor expanded in x around inf 86.4%

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

    if -1 < x < 2.3499999999999999e-51

    1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.8%

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

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

    if 2.3499999999999999e-51 < x < 1

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{x}}} \]
    8. Step-by-step derivation
      1. associate-/r/68.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot x} \]
    9. Applied egg-rr68.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+56}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{+32}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 5: 73.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;x \leq -1.25 \cdot 10^{+32}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-50}:\\
\;\;\;\;x - x \cdot x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.35000000000000005e56 or -1.2499999999999999e32 < x < -1 or 1 < x

    1. Initial program 76.9%

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

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

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

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

    if -1.35000000000000005e56 < x < -1.2499999999999999e32

    1. Initial program 100.0%

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y} + x \cdot 1}}{x + 1} \]
      2. *-rgt-identity100.0%

        \[\leadsto \frac{x \cdot \frac{x}{y} + \color{blue}{x}}{x + 1} \]
    3. Applied egg-rr100.0%

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

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    6. Simplified86.4%

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]
    7. Taylor expanded in x around inf 86.4%

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

    if -1 < x < 1.24999999999999992e-50

    1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.8%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{y} - 1, {x}^{2}, x\right)} \]
      2. sub-neg91.9%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{y} + -1, x \cdot x, x\right)} \]
    7. Step-by-step derivation
      1. fma-udef91.9%

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

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

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

      \[\leadsto \color{blue}{-1 \cdot {x}^{2} + x} \]
    10. Step-by-step derivation
      1. +-commutative79.1%

        \[\leadsto \color{blue}{x + -1 \cdot {x}^{2}} \]
      2. mul-1-neg79.1%

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

        \[\leadsto \color{blue}{x - {x}^{2}} \]
      4. unpow279.1%

        \[\leadsto x - \color{blue}{x \cdot x} \]
    11. Simplified79.1%

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

    if 1.24999999999999992e-50 < x < 1

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{x}}} \]
    8. Step-by-step derivation
      1. associate-/r/68.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot x} \]
    9. Applied egg-rr68.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{+56}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{+32}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-50}:\\ \;\;\;\;x - x \cdot x\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 6: 95.5% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 78.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < x < 1

    1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.8%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{y} - 1, {x}^{2}, x\right)} \]
      2. sub-neg91.9%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{y} + -1, x \cdot x, x\right)} \]
    7. Step-by-step derivation
      1. fma-udef91.9%

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

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

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

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

Alternative 7: 84.3% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{x}{x + 1}\\

\mathbf{elif}\;x \leq 0.42:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.9e8 or 0.419999999999999984 < x

    1. Initial program 77.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.9e8 < x < 5.19999999999999982e-127

    1. Initial program 99.9%

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

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

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

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

    if 5.19999999999999982e-127 < x < 0.419999999999999984

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -290000000:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 0.42:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \end{array} \]

Alternative 8: 84.6% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{x}{x + 1}\\

\mathbf{elif}\;x \leq 18000:\\
\;\;\;\;\frac{x}{y + \frac{y}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.9e8 or 18000 < x

    1. Initial program 77.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.9e8 < x < 5.19999999999999982e-127

    1. Initial program 99.9%

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

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

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

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

    if 5.19999999999999982e-127 < x < 18000

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -290000000:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 18000:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \end{array} \]

Alternative 9: 95.2% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 78.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < x < 1.25

    1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.8%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{y} - 1, {x}^{2}, x\right)} \]
      2. sub-neg91.9%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{y} + -1, x \cdot x, x\right)} \]
    7. Step-by-step derivation
      1. fma-udef91.9%

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

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

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

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

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

Alternative 10: 73.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;x \leq -1.52 \cdot 10^{+32}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 6.5 \cdot 10^{-13}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -9.0000000000000006e56 or -1.5200000000000001e32 < x < -1 or 6.49999999999999957e-13 < x

    1. Initial program 77.3%

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

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

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

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

    if -9.0000000000000006e56 < x < -1.5200000000000001e32

    1. Initial program 100.0%

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

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y} + x \cdot 1}}{x + 1} \]
      2. *-rgt-identity100.0%

        \[\leadsto \frac{x \cdot \frac{x}{y} + \color{blue}{x}}{x + 1} \]
    3. Applied egg-rr100.0%

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

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    6. Simplified86.4%

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]
    7. Taylor expanded in x around inf 86.4%

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

    if -1 < x < 6.49999999999999957e-13

    1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+56}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.52 \cdot 10^{+32}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 11: 73.7% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq 1.06 \cdot 10^{-50}:\\
\;\;\;\;\frac{x}{x + 1}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.00000000000000009e56 or 1 < x

    1. Initial program 75.7%

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

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

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

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

    if -1.00000000000000009e56 < x < 1.05999999999999995e-50

    1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.8%

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

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

    if 1.05999999999999995e-50 < x < 1

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{x}}} \]
    8. Step-by-step derivation
      1. associate-/r/68.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot x} \]
    9. Applied egg-rr68.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+56}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.06 \cdot 10^{-50}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 12: 71.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{x}{x + 1}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.40000000000000004e56 or 1 < x

    1. Initial program 75.7%

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

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

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

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

    if -1.40000000000000004e56 < x < 5.19999999999999982e-127

    1. Initial program 99.9%

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

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

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

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

    if 5.19999999999999982e-127 < x < 1

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{+56}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-127}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 13: 48.6% accurate, 2.1× speedup?

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

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

\mathbf{elif}\;x \leq 0.00345:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.11999999999999998e-4 or 0.0034499999999999999 < x

    1. Initial program 78.5%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Step-by-step derivation
      1. distribute-lft-in78.5%

        \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y} + x \cdot 1}}{x + 1} \]
      2. *-rgt-identity78.5%

        \[\leadsto \frac{x \cdot \frac{x}{y} + \color{blue}{x}}{x + 1} \]
    3. Applied egg-rr78.5%

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

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    6. Simplified20.2%

      \[\leadsto \color{blue}{\frac{x}{x + 1}} \]
    7. Taylor expanded in x around inf 19.7%

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

    if -1.11999999999999998e-4 < x < 0.0034499999999999999

    1. Initial program 99.8%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.8%

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

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

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

Alternative 14: 14.2% 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 87.7%

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

      \[\leadsto \frac{\color{blue}{x \cdot \frac{x}{y} + x \cdot 1}}{x + 1} \]
    2. *-rgt-identity87.7%

      \[\leadsto \frac{x \cdot \frac{x}{y} + \color{blue}{x}}{x + 1} \]
  3. Applied egg-rr87.7%

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

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

      \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
  6. Simplified44.2%

    \[\leadsto \color{blue}{\frac{x}{x + 1}} \]
  7. Taylor expanded in x around inf 12.7%

    \[\leadsto \color{blue}{1} \]
  8. Final simplification12.7%

    \[\leadsto 1 \]

Developer target: 99.8% accurate, 0.8× speedup?

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

\\
\frac{x}{1} \cdot \frac{\frac{x}{y} + 1}{x + 1}
\end{array}

Reproduce

?
herbie shell --seed 2023279 
(FPCore (x y)
  :name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
  :precision binary64

  :herbie-target
  (* (/ x 1.0) (/ (+ (/ x y) 1.0) (+ x 1.0)))

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