Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.6% → 99.9%
Time: 8.8s
Alternatives: 13
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 13 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: 69.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7.4 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1 \cdot 10^{+48}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-66}:\\ \;\;\;\;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 -7.4e+101)
   (/ x y)
   (if (<= x -1e+48)
     1.0
     (if (<= x -1.0)
       (/ x y)
       (if (<= x 1.3e-66)
         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 <= -7.4e+101) {
		tmp = x / y;
	} else if (x <= -1e+48) {
		tmp = 1.0;
	} else if (x <= -1.0) {
		tmp = x / y;
	} else if (x <= 1.3e-66) {
		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 <= (-7.4d+101)) then
        tmp = x / y
    else if (x <= (-1d+48)) then
        tmp = 1.0d0
    else if (x <= (-1.0d0)) then
        tmp = x / y
    else if (x <= 1.3d-66) 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 <= -7.4e+101) {
		tmp = x / y;
	} else if (x <= -1e+48) {
		tmp = 1.0;
	} else if (x <= -1.0) {
		tmp = x / y;
	} else if (x <= 1.3e-66) {
		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 <= -7.4e+101:
		tmp = x / y
	elif x <= -1e+48:
		tmp = 1.0
	elif x <= -1.0:
		tmp = x / y
	elif x <= 1.3e-66:
		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 <= -7.4e+101)
		tmp = Float64(x / y);
	elseif (x <= -1e+48)
		tmp = 1.0;
	elseif (x <= -1.0)
		tmp = Float64(x / y);
	elseif (x <= 1.3e-66)
		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 <= -7.4e+101)
		tmp = x / y;
	elseif (x <= -1e+48)
		tmp = 1.0;
	elseif (x <= -1.0)
		tmp = x / y;
	elseif (x <= 1.3e-66)
		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, -7.4e+101], N[(x / y), $MachinePrecision], If[LessEqual[x, -1e+48], 1.0, If[LessEqual[x, -1.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.3e-66], 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 -7.4 \cdot 10^{+101}:\\
\;\;\;\;\frac{x}{y}\\

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

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

\mathbf{elif}\;x \leq 1.3 \cdot 10^{-66}:\\
\;\;\;\;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 < -7.3999999999999995e101 or -1.00000000000000004e48 < 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 -7.3999999999999995e101 < x < -1.00000000000000004e48 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. clear-num92.5%

        \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} + 1\right)}{x + 1} \]
      2. associate-/r/92.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 < 1.2999999999999999e-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 x around 0 75.4%

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

    if 1.2999999999999999e-66 < 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 -7.4 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1 \cdot 10^{+48}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-66}:\\ \;\;\;\;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 3: 85.9% accurate, 0.7× speedup?

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

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

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

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

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


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

    1. Initial program 77.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 99.9%

      \[\leadsto \color{blue}{\left(1 + \frac{x}{y}\right) - \frac{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 < 21000

    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 -15200:\\ \;\;\;\;\left(1 + \frac{x}{y}\right) + \frac{-1}{y}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-69}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 21000:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{x}{y}\right) + \frac{-1}{y}\\ \end{array} \]

Alternative 4: 85.9% accurate, 0.7× speedup?

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

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

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

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

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


\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. 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 99.9%

      \[\leadsto \color{blue}{\left(1 + \frac{x}{y}\right) - \frac{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.4%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{x + 1}} \]
      4. +-commutative74.0%

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

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

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

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

        \[\leadsto \frac{\frac{x}{\color{blue}{x + 1}} \cdot x}{y} \]
    8. Applied egg-rr74.4%

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

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

Alternative 5: 95.3% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1 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. 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 99.9%

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

    if -1 < x < 1

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

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

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

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

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

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

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

Alternative 6: 70.9% accurate, 0.8× speedup?

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

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.89999999999999983e101 or -2.0500000000000001e48 < 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.89999999999999983e101 < x < -2.0500000000000001e48 or 0.00125000000000000003 < x < 1.6499999999999999e121

    1. Initial program 92.9%

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

        \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} + 1\right)}{x + 1} \]
      2. associate-/r/92.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 -4.9 \cdot 10^{+101}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{+48}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 0.00125:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+121}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 7: 85.4% accurate, 0.8× speedup?

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

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

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

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

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


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

    1. Initial program 77.0%

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

        \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} + 1\right)}{x + 1} \]
      2. associate-/r/77.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. Step-by-step derivation
      1. *-un-lft-identity76.9%

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{y}, x, 1\right)}{\color{blue}{1 \cdot \left(x + 1\right)}} \]
      2. associate-/r*76.9%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\frac{1 \cdot x}{y}} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      6. *-un-lft-identity77.0%

        \[\leadsto \frac{\frac{\frac{\color{blue}{x}}{y} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      7. distribute-rgt-in77.0%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}}}}{x + 1} \]
      11. div-inv76.8%

        \[\leadsto \color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}} \cdot \frac{1}{x + 1}} \]
      12. *-commutative76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot 1 + \frac{x}{y} \cdot \color{blue}{1} \]
      7. distribute-rgt-in99.5%

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

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

        \[\leadsto \color{blue}{\frac{x}{y} + 1} \]
    8. Applied egg-rr99.5%

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

    if -3.8e5 < x < 1.2999999999999999e-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.2999999999999999e-66 < x < 0.059999999999999998

    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}}} \]
    6. Step-by-step derivation
      1. clear-num73.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{y + \frac{y}{x}}{x}}} \]
      2. inv-pow73.8%

        \[\leadsto \color{blue}{{\left(\frac{y + \frac{y}{x}}{x}\right)}^{-1}} \]
    7. Applied egg-rr73.8%

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

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

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

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

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

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

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

Alternative 8: 85.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \frac{x}{y}\\ \mathbf{if}\;x \leq -7600000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-67}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+15}:\\ \;\;\;\;\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 y))))
   (if (<= x -7600000.0)
     t_0
     (if (<= x 9e-67)
       (/ x (+ x 1.0))
       (if (<= x 5.6e+15) (/ x (+ y (/ y x))) t_0)))))
double code(double x, double y) {
	double t_0 = 1.0 + (x / y);
	double tmp;
	if (x <= -7600000.0) {
		tmp = t_0;
	} else if (x <= 9e-67) {
		tmp = x / (x + 1.0);
	} else if (x <= 5.6e+15) {
		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 / y)
    if (x <= (-7600000.0d0)) then
        tmp = t_0
    else if (x <= 9d-67) then
        tmp = x / (x + 1.0d0)
    else if (x <= 5.6d+15) 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 / y);
	double tmp;
	if (x <= -7600000.0) {
		tmp = t_0;
	} else if (x <= 9e-67) {
		tmp = x / (x + 1.0);
	} else if (x <= 5.6e+15) {
		tmp = x / (y + (y / x));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 1.0 + (x / y)
	tmp = 0
	if x <= -7600000.0:
		tmp = t_0
	elif x <= 9e-67:
		tmp = x / (x + 1.0)
	elif x <= 5.6e+15:
		tmp = x / (y + (y / x))
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(1.0 + Float64(x / y))
	tmp = 0.0
	if (x <= -7600000.0)
		tmp = t_0;
	elseif (x <= 9e-67)
		tmp = Float64(x / Float64(x + 1.0));
	elseif (x <= 5.6e+15)
		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 / y);
	tmp = 0.0;
	if (x <= -7600000.0)
		tmp = t_0;
	elseif (x <= 9e-67)
		tmp = x / (x + 1.0);
	elseif (x <= 5.6e+15)
		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[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -7600000.0], t$95$0, If[LessEqual[x, 9e-67], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.6e+15], N[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.6e6 or 5.6e15 < x

    1. Initial program 76.8%

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

        \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} + 1\right)}{x + 1} \]
      2. associate-/r/76.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. Step-by-step derivation
      1. *-un-lft-identity76.8%

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{y}, x, 1\right)}{\color{blue}{1 \cdot \left(x + 1\right)}} \]
      2. associate-/r*76.8%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\frac{1 \cdot x}{y}} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      6. *-un-lft-identity76.8%

        \[\leadsto \frac{\frac{\frac{\color{blue}{x}}{y} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      7. distribute-rgt-in76.8%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}}}}{x + 1} \]
      11. div-inv76.7%

        \[\leadsto \color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}} \cdot \frac{1}{x + 1}} \]
      12. *-commutative76.7%

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

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

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

        \[\leadsto \frac{1}{x + 1} \cdot \left(\left(x \cdot \color{blue}{1}\right) \cdot \left(1 + \frac{x}{y}\right)\right) \]
      16. *-rgt-identity76.7%

        \[\leadsto \frac{1}{x + 1} \cdot \left(\color{blue}{x} \cdot \left(1 + \frac{x}{y}\right)\right) \]
      17. distribute-lft-in76.7%

        \[\leadsto \frac{1}{x + 1} \cdot \color{blue}{\left(x \cdot 1 + x \cdot \frac{x}{y}\right)} \]
      18. *-rgt-identity76.7%

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot 1 + \frac{x}{y} \cdot \color{blue}{1} \]
      7. distribute-rgt-in99.5%

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

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

        \[\leadsto \color{blue}{\frac{x}{y} + 1} \]
    8. Applied egg-rr99.5%

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

    if -7.6e6 < x < 9.00000000000000031e-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 y around inf 77.0%

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

    if 9.00000000000000031e-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 76.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7600000:\\ \;\;\;\;1 + \frac{x}{y}\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-67}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+15}:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{y}\\ \end{array} \]

Alternative 9: 85.0% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 77.0%

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

        \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} + 1\right)}{x + 1} \]
      2. associate-/r/77.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. Step-by-step derivation
      1. *-un-lft-identity76.9%

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{y}, x, 1\right)}{\color{blue}{1 \cdot \left(x + 1\right)}} \]
      2. associate-/r*76.9%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\frac{1 \cdot x}{y}} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      6. *-un-lft-identity77.0%

        \[\leadsto \frac{\frac{\frac{\color{blue}{x}}{y} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      7. distribute-rgt-in77.0%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}}}}{x + 1} \]
      11. div-inv76.8%

        \[\leadsto \color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}} \cdot \frac{1}{x + 1}} \]
      12. *-commutative76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot 1 + \frac{x}{y} \cdot \color{blue}{1} \]
      7. distribute-rgt-in99.5%

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

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

        \[\leadsto \color{blue}{\frac{x}{y} + 1} \]
    8. Applied egg-rr99.5%

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

    if -1 < x < 1.2999999999999999e-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 x around 0 75.4%

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

    if 1.2999999999999999e-66 < x < 0.14000000000000001

    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-/r/68.1%

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

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

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

Alternative 10: 85.4% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 77.0%

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

        \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} + 1\right)}{x + 1} \]
      2. associate-/r/77.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. Step-by-step derivation
      1. *-un-lft-identity76.9%

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{y}, x, 1\right)}{\color{blue}{1 \cdot \left(x + 1\right)}} \]
      2. associate-/r*76.9%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\frac{1 \cdot x}{y}} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      6. *-un-lft-identity77.0%

        \[\leadsto \frac{\frac{\frac{\color{blue}{x}}{y} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      7. distribute-rgt-in77.0%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}}}}{x + 1} \]
      11. div-inv76.8%

        \[\leadsto \color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}} \cdot \frac{1}{x + 1}} \]
      12. *-commutative76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot 1 + \frac{x}{y} \cdot \color{blue}{1} \]
      7. distribute-rgt-in99.5%

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

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

        \[\leadsto \color{blue}{\frac{x}{y} + 1} \]
    8. Applied egg-rr99.5%

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

    if -3.9e5 < x < 2.95e-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 y around inf 77.0%

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

    if 2.95e-67 < x < 0.0140000000000000003

    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-/r/68.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -390000:\\ \;\;\;\;1 + \frac{x}{y}\\ \mathbf{elif}\;x \leq 2.95 \cdot 10^{-67}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 0.014:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{y}\\ \end{array} \]

Alternative 11: 85.4% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 77.0%

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

        \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} + 1\right)}{x + 1} \]
      2. associate-/r/77.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. Step-by-step derivation
      1. *-un-lft-identity76.9%

        \[\leadsto \frac{x \cdot \mathsf{fma}\left(\frac{1}{y}, x, 1\right)}{\color{blue}{1 \cdot \left(x + 1\right)}} \]
      2. associate-/r*76.9%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{\frac{1 \cdot x}{y}} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      6. *-un-lft-identity77.0%

        \[\leadsto \frac{\frac{\frac{\color{blue}{x}}{y} \cdot x + 1 \cdot x}{1}}{x + 1} \]
      7. distribute-rgt-in77.0%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}}}}{x + 1} \]
      11. div-inv76.8%

        \[\leadsto \color{blue}{\frac{x}{\frac{1}{1 + \frac{x}{y}}} \cdot \frac{1}{x + 1}} \]
      12. *-commutative76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot 1 + \frac{x}{y} \cdot \color{blue}{1} \]
      7. distribute-rgt-in99.5%

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

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

        \[\leadsto \color{blue}{\frac{x}{y} + 1} \]
    8. Applied egg-rr99.5%

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

    if -2.1e6 < x < 1.2999999999999999e-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.2999999999999999e-66 < x < 0.0359999999999999973

    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}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.3%

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

Alternative 12: 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. clear-num76.8%

        \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} + 1\right)}{x + 1} \]
      2. associate-/r/76.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 13: 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. clear-num87.9%

      \[\leadsto \frac{x \cdot \left(\color{blue}{\frac{1}{\frac{y}{x}}} + 1\right)}{x + 1} \]
    2. associate-/r/87.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)))