Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.2% → 99.8%
Time: 5.9s
Alternatives: 6
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 6 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.2% 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.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \frac{\frac{x}{y} + 1}{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(x * Float64(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[(x * N[(N[(N[(x / y), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\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{\frac{x}{y} + 1}{x + 1} \]
  6. Add Preprocessing

Alternative 2: 86.4% accurate, 0.4× speedup?

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

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

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

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

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

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


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

    1. Initial program 80.1%

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

        \[\leadsto \color{blue}{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 x around inf 77.6%

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

    if -9.7999999999999998e67 < x < -2

    1. Initial program 90.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 inf 78.6%

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

    if -2 < x < -8.00000000000000065e-5

    1. Initial program 98.4%

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

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

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

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

    if -8.00000000000000065e-5 < 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 98.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.8 \cdot 10^{+67}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq -8 \cdot 10^{-5}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot \left(x + 1\right)}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot \left(1 + x \cdot \left(\frac{1}{y} + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 74.4% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;x \leq 1.8 \cdot 10^{-33}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 78.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 x around inf 80.4%

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

    if -3.19999999999999983e67 < x < 1.80000000000000017e-33

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

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

    if 1.80000000000000017e-33 < x

    1. Initial program 83.2%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{1 + x} + \frac{{x}^{2}}{1 + x}}{y}} \]
    6. Step-by-step derivation
      1. *-commutative70.5%

        \[\leadsto \frac{\frac{\color{blue}{y \cdot x}}{1 + x} + \frac{{x}^{2}}{1 + x}}{y} \]
      2. +-commutative70.5%

        \[\leadsto \frac{\frac{y \cdot x}{\color{blue}{x + 1}} + \frac{{x}^{2}}{1 + x}}{y} \]
      3. associate-/l*79.4%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{x}{x + 1}} + \frac{{x}^{2}}{1 + x}}{y} \]
      4. *-lft-identity79.4%

        \[\leadsto \frac{y \cdot \frac{\color{blue}{1 \cdot x}}{x + 1} + \frac{{x}^{2}}{1 + x}}{y} \]
      5. associate-*l/79.3%

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

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

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

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

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

        \[\leadsto \frac{y \cdot \left(\frac{1}{x + 1} \cdot x\right) + x \cdot \color{blue}{\left(\frac{1}{x + 1} \cdot x\right)}}{y} \]
      11. distribute-rgt-out99.7%

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

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

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

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

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

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

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

        \[\leadsto {\left(\frac{\color{blue}{1 \cdot y}}{\frac{x}{1 + x} \cdot \left(y + x\right)}\right)}^{-1} \]
      4. times-frac99.7%

        \[\leadsto {\color{blue}{\left(\frac{1}{\frac{x}{1 + x}} \cdot \frac{y}{y + x}\right)}}^{-1} \]
      5. clear-num99.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\frac{x + 1}{x}}}{\frac{y}{x + y}}} \]
      3. associate-/r/99.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{+67}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-33}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{x + 1}}{\frac{y}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 74.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.35 \cdot 10^{+67} \lor \neg \left(x \leq 1.7 \cdot 10^{+36}\right):\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.35000000000000009e67 or 1.6999999999999999e36 < 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.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 x around inf 79.8%

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

    if -2.35000000000000009e67 < x < 1.6999999999999999e36

    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.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 simplification77.3%

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

Alternative 5: 74.3% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 80.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 x around inf 73.2%

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

    if -1 < x < 1.06e11

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

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

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

Alternative 6: 38.8% accurate, 11.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
	return x;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = x
end function
public static double code(double x, double y) {
	return x;
}
def code(x, y):
	return x
function code(x, y)
	return x
end
function tmp = code(x, y)
	tmp = x;
end
code[x_, y_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 92.3%

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

    \[\leadsto \color{blue}{x} \]
  6. Final simplification46.5%

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 99.8% accurate, 0.8× speedup?

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

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

Reproduce

?
herbie shell --seed 2024078 
(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)))