Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.3% → 99.9%
Time: 5.9s
Alternatives: 9
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 9 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.3% 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.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: 85.7% accurate, 0.8× speedup?

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

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

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

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

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


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

    1. Initial program 77.8%

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

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

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

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

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

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

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

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

    if -9e10 < x < 3.00000000000000008e-58

    1. Initial program 99.8%

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

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

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

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

    if 3.00000000000000008e-58 < x < 0.00559999999999999994

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -90000000000:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-58}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 0.0056:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \end{array} \]

Alternative 3: 86.0% accurate, 0.8× speedup?

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

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

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

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

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


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

    1. Initial program 77.8%

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

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

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

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

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

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

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

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

    if -9e10 < x < 1.39999999999999997e-56

    1. Initial program 99.8%

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

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

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

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

    if 1.39999999999999997e-56 < x < 8600

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 72.7% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq 2 \cdot 10^{-57}:\\
\;\;\;\;x\\

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

\mathbf{elif}\;x \leq 2.4 \cdot 10^{+76}:\\
\;\;\;\;1\\

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


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

    1. Initial program 75.4%

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

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

    if -1 < x < 1.99999999999999991e-57

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

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

    if 1.99999999999999991e-57 < x < 0.149999999999999994

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.149999999999999994 < x < 2.4e76

    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}{\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 97.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-57}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 0.15:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{+76}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 5: 83.8% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

    if -1 < x < 5.40000000000000051e-54

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

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

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

Alternative 6: 84.2% accurate, 1.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9e10 or 5.40000000000000051e-54 < x

    1. Initial program 78.6%

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

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

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

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

        \[\leadsto \color{blue}{\frac{x - 1}{y}} + 1 \]
      4. sub-neg95.8%

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

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

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

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

    if -9e10 < x < 5.40000000000000051e-54

    1. Initial program 99.8%

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

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

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

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

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

Alternative 7: 71.7% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;x \leq 5.4 \cdot 10^{-54}:\\
\;\;\;\;x\\

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


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

    1. Initial program 78.8%

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

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

    if -1 < x < 5.40000000000000051e-54

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

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

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

Alternative 8: 47.3% accurate, 2.1× speedup?

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

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

\mathbf{elif}\;x \leq 5.4 \cdot 10^{-54}:\\
\;\;\;\;x\\

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


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

    1. Initial program 78.8%

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

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

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

    if -1 < x < 5.40000000000000051e-54

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-54}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 9: 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.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. Taylor expanded in x around inf 50.5%

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

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

    \[\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 2023224 
(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)))