Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.3% → 99.8%
Time: 7.5s
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.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 87.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. Final simplification99.9%

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

Alternative 2: 86.5% accurate, 0.4× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -3.6e44

    1. Initial program 73.1%

      \[\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 inf 76.6%

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

    if -3.6e44 < x < -2.8999999999999998e-7

    1. Initial program 100.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 80.9%

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

    if -2.8999999999999998e-7 < x < 3.4000000000000001e-12

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

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

    if 3.4000000000000001e-12 < x

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y + x \cdot y}{x}}} \]
    9. Step-by-step derivation
      1. distribute-rgt1-in64.7%

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

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

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

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

        \[\leadsto \frac{x}{\color{blue}{\frac{y \cdot x}{x}} + \frac{y}{x}} \]
      6. associate-/l*78.4%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{x}{x}} + \frac{y}{x}} \]
      7. *-inverses78.4%

        \[\leadsto \frac{x}{y \cdot \color{blue}{1} + \frac{y}{x}} \]
      8. *-rgt-identity78.4%

        \[\leadsto \frac{x}{\color{blue}{y} + \frac{y}{x}} \]
    10. Simplified78.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+44}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-12}:\\ \;\;\;\;x \cdot \left(1 + x \cdot \left(\frac{1}{y} + -1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 86.1% accurate, 0.5× speedup?

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

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

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

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

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


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

    1. Initial program 74.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 76.6%

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

    if -4.60000000000000009e44 < x < -1.22e-8

    1. Initial program 100.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 80.9%

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

    if -1.22e-8 < x < 56

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

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

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

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

Alternative 4: 86.4% accurate, 0.5× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -8.0000000000000007e44

    1. Initial program 73.1%

      \[\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 inf 76.6%

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

    if -8.0000000000000007e44 < x < -5.00000000000000031e-10

    1. Initial program 100.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 80.9%

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

    if -5.00000000000000031e-10 < x < 3.4000000000000001e-12

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

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

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

    if 3.4000000000000001e-12 < x

    1. Initial program 75.5%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{y + x \cdot y}{x}}} \]
    9. Step-by-step derivation
      1. distribute-rgt1-in64.7%

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

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

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

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

        \[\leadsto \frac{x}{\color{blue}{\frac{y \cdot x}{x}} + \frac{y}{x}} \]
      6. associate-/l*78.4%

        \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{x}{x}} + \frac{y}{x}} \]
      7. *-inverses78.4%

        \[\leadsto \frac{x}{y \cdot \color{blue}{1} + \frac{y}{x}} \]
      8. *-rgt-identity78.4%

        \[\leadsto \frac{x}{\color{blue}{y} + \frac{y}{x}} \]
    10. Simplified78.4%

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

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

Alternative 5: 74.2% accurate, 0.7× speedup?

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

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

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


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

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

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

    if -1 < x < 3.4000000000000001e-12

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

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot x\right)} \]
    7. Step-by-step derivation
      1. neg-mul-185.2%

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

        \[\leadsto x \cdot \color{blue}{\left(1 - x\right)} \]
    8. Simplified85.2%

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

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

Alternative 6: 74.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+44} \lor \neg \left(x \leq 2.4 \cdot 10^{+53}\right):\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -6.9999999999999998e44 or 2.4e53 < x

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

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

    if -6.9999999999999998e44 < x < 2.4e53

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

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

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

Alternative 7: 74.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 3.4 \cdot 10^{-12}\right):\\ \;\;\;\;\frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -1.0) (not (<= x 3.4e-12))) (/ x y) x))
double code(double x, double y) {
	double tmp;
	if ((x <= -1.0) || !(x <= 3.4e-12)) {
		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.4d-12))) 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.4e-12)) {
		tmp = x / y;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -1.0) or not (x <= 3.4e-12):
		tmp = x / y
	else:
		tmp = x
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -1.0) || !(x <= 3.4e-12))
		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.4e-12)))
		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.4e-12]], $MachinePrecision]], N[(x / y), $MachinePrecision], x]
\begin{array}{l}

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

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


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

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

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

    if -1 < x < 3.4000000000000001e-12

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

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

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

Alternative 8: 49.5% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq 3.4 \cdot 10^{-12}:\\
\;\;\;\;x\\

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


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

    1. Initial program 76.2%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 52.7%

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

        \[\leadsto \frac{\frac{x \cdot y + \color{blue}{x \cdot x}}{y}}{x + 1} \]
      2. distribute-lft-out53.1%

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

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

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

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

    if -1 < x < 3.4000000000000001e-12

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

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

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

Alternative 9: 13.9% 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 87.9%

    \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
  2. Add Preprocessing
  3. Taylor expanded in y around 0 66.7%

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

      \[\leadsto \frac{\frac{x \cdot y + \color{blue}{x \cdot x}}{y}}{x + 1} \]
    2. distribute-lft-out66.9%

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

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

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

    \[\leadsto \color{blue}{1} \]
  8. Final simplification14.9%

    \[\leadsto 1 \]
  9. 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 2024077 
(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)))