Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.6% → 99.9%
Time: 8.6s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 88.6% 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 88.0%

    \[\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: 71.0% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;x \leq -1.32 \cdot 10^{+48}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 1.3 \cdot 10^{-66}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.7 \cdot 10^{+121}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.89999999999999983e101 or -1.32e48 < x < -8.5e26 or 1.70000000000000005e121 < x

    1. Initial program 69.0%

      \[\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.2%

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

    if -4.89999999999999983e101 < x < -1.32e48

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -8.5e26 < x < 1.2999999999999999e-66 or 3.6e-12 < x < 1.70000000000000005e121

    1. Initial program 98.1%

      \[\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 73.4%

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

    if 1.2999999999999999e-66 < x < 3.6e-12

    1. Initial program 99.4%

      \[\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 78.7%

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot x} \]
    7. Applied egg-rr78.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.9 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.32 \cdot 10^{+48}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{+26}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-66}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-12}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+121}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 3: 71.1% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;x \leq -1.2 \cdot 10^{+47}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 1.3 \cdot 10^{-66}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 9.5 \cdot 10^{-16}:\\
\;\;\;\;\frac{x}{\frac{y}{x}}\\

\mathbf{elif}\;x \leq 1.65 \cdot 10^{+121}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.99999999999999989e101 or -1.20000000000000009e47 < x < -3.0000000000000001e28 or 1.6499999999999999e121 < x

    1. Initial program 69.0%

      \[\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.2%

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

    if -4.99999999999999989e101 < x < -1.20000000000000009e47

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -3.0000000000000001e28 < x < 1.2999999999999999e-66 or 9.5000000000000005e-16 < x < 1.6499999999999999e121

    1. Initial program 98.1%

      \[\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 73.4%

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

    if 1.2999999999999999e-66 < x < 9.5000000000000005e-16

    1. Initial program 99.4%

      \[\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 78.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.2 \cdot 10^{+47}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3 \cdot 10^{+28}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-66}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-16}:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+121}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 4: 71.0% accurate, 0.6× speedup?

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

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

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

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

\mathbf{elif}\;x \leq 1.3 \cdot 10^{-66}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7 \cdot 10^{-16}:\\
\;\;\;\;\frac{x \cdot x}{y}\\

\mathbf{elif}\;x \leq 6.5 \cdot 10^{+121}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.79999999999999977e101 or -1.25000000000000005e47 < x < -3.5999999999999999e28 or 6.50000000000000019e121 < x

    1. Initial program 69.0%

      \[\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.2%

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

    if -4.79999999999999977e101 < x < -1.25000000000000005e47

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -3.5999999999999999e28 < x < 1.2999999999999999e-66 or 7.00000000000000035e-16 < x < 6.50000000000000019e121

    1. Initial program 98.1%

      \[\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 73.4%

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

    if 1.2999999999999999e-66 < x < 7.00000000000000035e-16

    1. Initial program 99.4%

      \[\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 78.7%

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

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

      \[\leadsto \color{blue}{\frac{{x}^{2}}{y}} \]
    7. Step-by-step derivation
      1. unpow278.7%

        \[\leadsto \frac{\color{blue}{x \cdot x}}{y} \]
    8. Simplified78.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{+47}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3.6 \cdot 10^{+28}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-66}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-16}:\\ \;\;\;\;\frac{x \cdot x}{y}\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+121}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 5: 71.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -4.9 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -8.4 \cdot 10^{+47}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -8 \cdot 10^{+26}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-13}:\\ \;\;\;\;\frac{1}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+121}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (+ x 1.0))))
   (if (<= x -4.9e+101)
     (/ x y)
     (if (<= x -8.4e+47)
       1.0
       (if (<= x -8e+26)
         (/ x y)
         (if (<= x 1.25e-66)
           t_0
           (if (<= x 1.7e-13)
             (* (/ 1.0 y) (* x x))
             (if (<= x 1.65e+121) t_0 (/ x y)))))))))
double code(double x, double y) {
	double t_0 = x / (x + 1.0);
	double tmp;
	if (x <= -4.9e+101) {
		tmp = x / y;
	} else if (x <= -8.4e+47) {
		tmp = 1.0;
	} else if (x <= -8e+26) {
		tmp = x / y;
	} else if (x <= 1.25e-66) {
		tmp = t_0;
	} else if (x <= 1.7e-13) {
		tmp = (1.0 / y) * (x * x);
	} else if (x <= 1.65e+121) {
		tmp = t_0;
	} else {
		tmp = x / y;
	}
	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 / (x + 1.0d0)
    if (x <= (-4.9d+101)) then
        tmp = x / y
    else if (x <= (-8.4d+47)) then
        tmp = 1.0d0
    else if (x <= (-8d+26)) then
        tmp = x / y
    else if (x <= 1.25d-66) then
        tmp = t_0
    else if (x <= 1.7d-13) then
        tmp = (1.0d0 / y) * (x * x)
    else if (x <= 1.65d+121) then
        tmp = t_0
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x / (x + 1.0);
	double tmp;
	if (x <= -4.9e+101) {
		tmp = x / y;
	} else if (x <= -8.4e+47) {
		tmp = 1.0;
	} else if (x <= -8e+26) {
		tmp = x / y;
	} else if (x <= 1.25e-66) {
		tmp = t_0;
	} else if (x <= 1.7e-13) {
		tmp = (1.0 / y) * (x * x);
	} else if (x <= 1.65e+121) {
		tmp = t_0;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (x + 1.0)
	tmp = 0
	if x <= -4.9e+101:
		tmp = x / y
	elif x <= -8.4e+47:
		tmp = 1.0
	elif x <= -8e+26:
		tmp = x / y
	elif x <= 1.25e-66:
		tmp = t_0
	elif x <= 1.7e-13:
		tmp = (1.0 / y) * (x * x)
	elif x <= 1.65e+121:
		tmp = t_0
	else:
		tmp = x / y
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(x + 1.0))
	tmp = 0.0
	if (x <= -4.9e+101)
		tmp = Float64(x / y);
	elseif (x <= -8.4e+47)
		tmp = 1.0;
	elseif (x <= -8e+26)
		tmp = Float64(x / y);
	elseif (x <= 1.25e-66)
		tmp = t_0;
	elseif (x <= 1.7e-13)
		tmp = Float64(Float64(1.0 / y) * Float64(x * x));
	elseif (x <= 1.65e+121)
		tmp = t_0;
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (x + 1.0);
	tmp = 0.0;
	if (x <= -4.9e+101)
		tmp = x / y;
	elseif (x <= -8.4e+47)
		tmp = 1.0;
	elseif (x <= -8e+26)
		tmp = x / y;
	elseif (x <= 1.25e-66)
		tmp = t_0;
	elseif (x <= 1.7e-13)
		tmp = (1.0 / y) * (x * x);
	elseif (x <= 1.65e+121)
		tmp = t_0;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.9e+101], N[(x / y), $MachinePrecision], If[LessEqual[x, -8.4e+47], 1.0, If[LessEqual[x, -8e+26], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.25e-66], t$95$0, If[LessEqual[x, 1.7e-13], N[(N[(1.0 / y), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.65e+121], t$95$0, N[(x / y), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -8.4 \cdot 10^{+47}:\\
\;\;\;\;1\\

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

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

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

\mathbf{elif}\;x \leq 1.65 \cdot 10^{+121}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.89999999999999983e101 or -8.4e47 < x < -8.00000000000000038e26 or 1.6499999999999999e121 < x

    1. Initial program 69.0%

      \[\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.2%

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

    if -4.89999999999999983e101 < x < -8.4e47

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -8.00000000000000038e26 < x < 1.2499999999999999e-66 or 1.70000000000000008e-13 < x < 1.6499999999999999e121

    1. Initial program 98.1%

      \[\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 73.4%

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

    if 1.2499999999999999e-66 < x < 1.70000000000000008e-13

    1. Initial program 99.4%

      \[\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 78.7%

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{x}}} \]
    6. Step-by-step derivation
      1. associate-/l*78.7%

        \[\leadsto \color{blue}{\frac{x \cdot x}{y}} \]
      2. div-inv78.7%

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(x \cdot x\right)} \]
    7. Applied egg-rr78.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.9 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -8.4 \cdot 10^{+47}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -8 \cdot 10^{+26}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-66}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-13}:\\ \;\;\;\;\frac{1}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+121}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 6: 69.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{+47}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-67}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+15}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+121}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -4.8e+101)
   (/ x y)
   (if (<= x -1.05e+47)
     1.0
     (if (<= x -1.0)
       (/ x y)
       (if (<= x 4.5e-67)
         x
         (if (<= x 5.6e+15)
           (* x (/ x y))
           (if (<= x 1.65e+121) 1.0 (/ x y))))))))
double code(double x, double y) {
	double tmp;
	if (x <= -4.8e+101) {
		tmp = x / y;
	} else if (x <= -1.05e+47) {
		tmp = 1.0;
	} else if (x <= -1.0) {
		tmp = x / y;
	} else if (x <= 4.5e-67) {
		tmp = x;
	} else if (x <= 5.6e+15) {
		tmp = x * (x / y);
	} else if (x <= 1.65e+121) {
		tmp = 1.0;
	} 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 <= (-4.8d+101)) then
        tmp = x / y
    else if (x <= (-1.05d+47)) then
        tmp = 1.0d0
    else if (x <= (-1.0d0)) then
        tmp = x / y
    else if (x <= 4.5d-67) then
        tmp = x
    else if (x <= 5.6d+15) then
        tmp = x * (x / y)
    else if (x <= 1.65d+121) then
        tmp = 1.0d0
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -4.8e+101) {
		tmp = x / y;
	} else if (x <= -1.05e+47) {
		tmp = 1.0;
	} else if (x <= -1.0) {
		tmp = x / y;
	} else if (x <= 4.5e-67) {
		tmp = x;
	} else if (x <= 5.6e+15) {
		tmp = x * (x / y);
	} else if (x <= 1.65e+121) {
		tmp = 1.0;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -4.8e+101:
		tmp = x / y
	elif x <= -1.05e+47:
		tmp = 1.0
	elif x <= -1.0:
		tmp = x / y
	elif x <= 4.5e-67:
		tmp = x
	elif x <= 5.6e+15:
		tmp = x * (x / y)
	elif x <= 1.65e+121:
		tmp = 1.0
	else:
		tmp = x / y
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -4.8e+101)
		tmp = Float64(x / y);
	elseif (x <= -1.05e+47)
		tmp = 1.0;
	elseif (x <= -1.0)
		tmp = Float64(x / y);
	elseif (x <= 4.5e-67)
		tmp = x;
	elseif (x <= 5.6e+15)
		tmp = Float64(x * Float64(x / y));
	elseif (x <= 1.65e+121)
		tmp = 1.0;
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -4.8e+101)
		tmp = x / y;
	elseif (x <= -1.05e+47)
		tmp = 1.0;
	elseif (x <= -1.0)
		tmp = x / y;
	elseif (x <= 4.5e-67)
		tmp = x;
	elseif (x <= 5.6e+15)
		tmp = x * (x / y);
	elseif (x <= 1.65e+121)
		tmp = 1.0;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -4.8e+101], N[(x / y), $MachinePrecision], If[LessEqual[x, -1.05e+47], 1.0, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 4.5e-67], x, If[LessEqual[x, 5.6e+15], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.65e+121], 1.0, N[(x / y), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.05 \cdot 10^{+47}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 4.5 \cdot 10^{-67}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 5.6 \cdot 10^{+15}:\\
\;\;\;\;x \cdot \frac{x}{y}\\

\mathbf{elif}\;x \leq 1.65 \cdot 10^{+121}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.79999999999999977e101 or -1.05e47 < x < -1 or 1.6499999999999999e121 < x

    1. Initial program 70.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.4%

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

    if -4.79999999999999977e101 < x < -1.05e47 or 5.6e15 < x < 1.6499999999999999e121

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

    if -1 < x < 4.50000000000000015e-67

    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.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.4%

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

    if 4.50000000000000015e-67 < x < 5.6e15

    1. Initial program 99.4%

      \[\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 76.1%

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot x} \]
    7. Applied egg-rr63.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{+47}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-67}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+15}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+121}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 7: 70.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq -4.15 \cdot 10^{+46}:\\
\;\;\;\;1\\

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

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

\mathbf{elif}\;x \leq 3.3 \cdot 10^{+121}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.99999999999999989e101 or -4.14999999999999976e46 < x < -1 or 3.29999999999999979e121 < x

    1. Initial program 70.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.4%

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

    if -4.99999999999999989e101 < x < -4.14999999999999976e46 or 0.00125000000000000003 < x < 3.29999999999999979e121

    1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

    if -1 < x < 0.00125000000000000003

    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.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 70.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -4.15 \cdot 10^{+46}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 0.00125:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{+121}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 8: 85.7% accurate, 0.8× speedup?

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

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

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

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

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


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

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

    if -15200 < x < 3.9999999999999999e-69

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

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

    if 3.9999999999999999e-69 < x < 1

    1. Initial program 99.3%

      \[\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 74.1%

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y}{x}}} \]
    6. Step-by-step derivation
      1. associate-/l*68.5%

        \[\leadsto \color{blue}{\frac{x \cdot x}{y}} \]
      2. div-inv68.5%

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(x \cdot x\right)} \]
    7. Applied egg-rr68.5%

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

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

Alternative 9: 85.9% accurate, 0.8× speedup?

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

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

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

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

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


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

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

    if -1650 < x < 1.01999999999999996e-66

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

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

    if 1.01999999999999996e-66 < x < 1100

    1. Initial program 99.3%

      \[\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 74.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1650:\\ \;\;\;\;\frac{x + -1}{y} + 1\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-66}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1100:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + -1}{y} + 1\\ \end{array} \]

Alternative 10: 98.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

    if -1 < x < 1.19999999999999996

    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.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. Step-by-step derivation
      1. associate-/l*99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 49.3% accurate, 2.1× speedup?

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

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

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

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


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

    1. Initial program 76.8%

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

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

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

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

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

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

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

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

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

    if -1e11 < x < 0.00125000000000000003

    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 69.8%

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

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

Alternative 12: 14.5% 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 88.0%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{1} \]
  8. Final simplification17.2%

    \[\leadsto 1 \]

Developer target: 99.9% 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 2023297 
(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)))