Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 87.8% → 99.9%
Time: 8.4s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 87.8% 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 89.8%

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

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

    \[\leadsto \color{blue}{x \cdot \frac{\frac{x}{y} + 1}{x + 1}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. clear-num99.8%

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    2. un-div-inv99.9%

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

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

    \[\leadsto \frac{x}{\frac{x + 1}{1 + \frac{x}{y}}} \]
  8. Add Preprocessing

Alternative 2: 72.8% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;y \leq -1.3 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;y \leq -6 \cdot 10^{+22}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{y} \cdot t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.30000000000000007e79 or 3.50000000000000015e-74 < y

    1. Initial program 93.2%

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

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

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

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

    if -1.30000000000000007e79 < y < -5.0000000000000004e43

    1. Initial program 57.7%

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000000004e43 < y < -6e22

    1. Initial program 100.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}{x \cdot \frac{\frac{x}{y} + 1}{x + 1}} \]
    3. Simplified100.0%

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

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

    if -6e22 < y < 3.50000000000000015e-74

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot x}}{y \cdot \frac{x + 1}{x}} \]
      2. *-commutative80.6%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{\frac{x + 1}{x} \cdot y}} \]
      3. times-frac80.7%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+79}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;y \leq -5 \cdot 10^{+43}:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{elif}\;y \leq -6 \cdot 10^{+22}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-74}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.0% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;y \leq -3.5 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.5000000000000001e78 or 5.8e-74 < y

    1. Initial program 93.2%

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

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

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

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

    if -3.5000000000000001e78 < y < -5.5999999999999996e50

    1. Initial program 57.7%

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

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

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

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

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

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

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

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

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

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

    if -5.5999999999999996e50 < y < -3.2e22

    1. Initial program 100.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}{x \cdot \frac{\frac{x}{y} + 1}{x + 1}} \]
    3. Simplified100.0%

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

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

    if -3.2e22 < y < 5.8e-74

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

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{x}{y} + 1}{x + 1}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. clear-num99.7%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
      2. un-div-inv99.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+78}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;y \leq -5.6 \cdot 10^{+50}:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{+22}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-74}:\\ \;\;\;\;\frac{x}{\frac{\left(x + 1\right) \cdot y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.0% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\mathbf{if}\;y \leq -9.5 \cdot 10^{+77}:\\
\;\;\;\;t\_0\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -9.4999999999999998e77 or 5.70000000000000025e-74 < y

    1. Initial program 93.2%

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

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

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

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

    if -9.4999999999999998e77 < y < -5e50

    1. Initial program 57.7%

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

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

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

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

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

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

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

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

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

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

    if -5e50 < y < -3e22

    1. Initial program 100.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}{x \cdot \frac{\frac{x}{y} + 1}{x + 1}} \]
    3. Simplified100.0%

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

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

    if -3e22 < y < 5.70000000000000025e-74

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.5 \cdot 10^{+77}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;y \leq -5 \cdot 10^{+50}:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{elif}\;y \leq -3 \cdot 10^{+22}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.7 \cdot 10^{-74}:\\ \;\;\;\;\frac{x}{\frac{y + x \cdot y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 72.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{x + 1}\\ t_1 := \frac{x}{y + \frac{y}{x}}\\ \mathbf{if}\;y \leq -9.5 \cdot 10^{+77}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{+45}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{+22}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-74}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (+ x 1.0))) (t_1 (/ x (+ y (/ y x)))))
   (if (<= y -9.5e+77)
     t_0
     (if (<= y -4.5e+45)
       t_1
       (if (<= y -2.9e+22) x (if (<= y 5.8e-74) t_1 t_0))))))
double code(double x, double y) {
	double t_0 = x / (x + 1.0);
	double t_1 = x / (y + (y / x));
	double tmp;
	if (y <= -9.5e+77) {
		tmp = t_0;
	} else if (y <= -4.5e+45) {
		tmp = t_1;
	} else if (y <= -2.9e+22) {
		tmp = x;
	} else if (y <= 5.8e-74) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = x / (x + 1.0d0)
    t_1 = x / (y + (y / x))
    if (y <= (-9.5d+77)) then
        tmp = t_0
    else if (y <= (-4.5d+45)) then
        tmp = t_1
    else if (y <= (-2.9d+22)) then
        tmp = x
    else if (y <= 5.8d-74) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x / (x + 1.0);
	double t_1 = x / (y + (y / x));
	double tmp;
	if (y <= -9.5e+77) {
		tmp = t_0;
	} else if (y <= -4.5e+45) {
		tmp = t_1;
	} else if (y <= -2.9e+22) {
		tmp = x;
	} else if (y <= 5.8e-74) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (x + 1.0)
	t_1 = x / (y + (y / x))
	tmp = 0
	if y <= -9.5e+77:
		tmp = t_0
	elif y <= -4.5e+45:
		tmp = t_1
	elif y <= -2.9e+22:
		tmp = x
	elif y <= 5.8e-74:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(x + 1.0))
	t_1 = Float64(x / Float64(y + Float64(y / x)))
	tmp = 0.0
	if (y <= -9.5e+77)
		tmp = t_0;
	elseif (y <= -4.5e+45)
		tmp = t_1;
	elseif (y <= -2.9e+22)
		tmp = x;
	elseif (y <= 5.8e-74)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (x + 1.0);
	t_1 = x / (y + (y / x));
	tmp = 0.0;
	if (y <= -9.5e+77)
		tmp = t_0;
	elseif (y <= -4.5e+45)
		tmp = t_1;
	elseif (y <= -2.9e+22)
		tmp = x;
	elseif (y <= 5.8e-74)
		tmp = t_1;
	else
		tmp = t_0;
	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[(x / N[(y + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.5e+77], t$95$0, If[LessEqual[y, -4.5e+45], t$95$1, If[LessEqual[y, -2.9e+22], x, If[LessEqual[y, 5.8e-74], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -4.5 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;y \leq 5.8 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.4999999999999998e77 or 5.8e-74 < y

    1. Initial program 93.2%

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

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

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

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

    if -9.4999999999999998e77 < y < -4.4999999999999998e45 or -2.9e22 < y < 5.8e-74

    1. Initial program 85.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}{x \cdot \frac{\frac{x}{y} + 1}{x + 1}} \]
    3. Simplified99.8%

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

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

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

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

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

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

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

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

    if -4.4999999999999998e45 < y < -2.9e22

    1. Initial program 100.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}{x \cdot \frac{\frac{x}{y} + 1}{x + 1}} \]
    3. Simplified100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.5 \cdot 10^{+77}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{+45}:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{elif}\;y \leq -2.9 \cdot 10^{+22}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-74}:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 75.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+24} \lor \neg \left(x \leq 1.1 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{x}{y}\\

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


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

    1. Initial program 77.6%

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

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

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

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

    if -9.1999999999999996e24 < x < 1.1e16

    1. Initial program 99.9%

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

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

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

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

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

Alternative 7: 74.4% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 79.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}{x \cdot \frac{\frac{x}{y} + 1}{x + 1}} \]
    3. Simplified99.9%

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

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

    if -1 < x < 3.1e15

    1. Initial program 99.9%

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

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

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

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

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

Alternative 8: 49.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 79.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}{x \cdot \frac{\frac{x}{y} + 1}{x + 1}} \]
    3. Simplified99.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{x + 1}{x}}} \]
      2. +-commutative26.3%

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

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

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

    if -1.75e8 < 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.9%

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

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

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

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

Alternative 9: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \frac{1 + \frac{x}{y}}{x + 1} \end{array} \]
(FPCore (x y) :precision binary64 (* x (/ (+ 1.0 (/ x y)) (+ x 1.0))))
double code(double x, double y) {
	return x * ((1.0 + (x / y)) / (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)) / (x + 1.0d0))
end function
public static double code(double x, double y) {
	return x * ((1.0 + (x / y)) / (x + 1.0));
}
def code(x, y):
	return x * ((1.0 + (x / y)) / (x + 1.0))
function code(x, y)
	return Float64(x * Float64(Float64(1.0 + Float64(x / y)) / Float64(x + 1.0)))
end
function tmp = code(x, y)
	tmp = x * ((1.0 + (x / y)) / (x + 1.0));
end
code[x_, y_] := N[(x * N[(N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

    \[\leadsto x \cdot \frac{1 + \frac{x}{y}}{x + 1} \]
  6. Add Preprocessing

Alternative 10: 14.4% 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 89.8%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 1 \]
  12. Add Preprocessing

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 2024075 
(FPCore (x y)
  :name "Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1"
  :precision binary64

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

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