Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.3% → 99.9%
Time: 8.3s
Alternatives: 11
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 11 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, 0.7× speedup?

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

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

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


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

    1. Initial program 74.1%

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y} + 1}{\frac{x + 1}{x}}} \]
      3. +-commutative100.0%

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{1 + x}}{x}} \]
      4. remove-double-neg100.0%

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

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{1}{x} - \color{blue}{-1}} \]
    3. Simplified100.0%

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

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

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

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

        \[\leadsto 1 + \color{blue}{\frac{x - 1}{y}} \]
      3. sub-neg100.0%

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

        \[\leadsto 1 + \frac{x + \color{blue}{-1}}{y} \]
    7. Simplified100.0%

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

    if -1.16e16 < x < 2e15

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

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

Alternative 2: 85.7% accurate, 0.8× speedup?

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

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

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

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

\mathbf{elif}\;x \leq 4 \cdot 10^{+119}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.1e11 or 3.99999999999999978e119 < x

    1. Initial program 70.7%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in x around inf 83.0%

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

    if -3.1e11 < x < -5.5000000000000004e-12 or 0.00949999999999999976 < x < 3.99999999999999978e119

    1. Initial program 96.1%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in y around inf 83.4%

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    4. Simplified83.4%

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

    if -5.5000000000000004e-12 < x < 0.00949999999999999976

    1. Initial program 99.9%

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{1 + x}}{x}} \]
      4. remove-double-neg99.6%

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\color{blue}{\frac{1}{x} - \frac{-x}{x}}} \]
      7. distribute-frac-neg99.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y} + 1}{1} \cdot x} \]
      2. /-rgt-identity98.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -310000000000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-12}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 0.0095:\\ \;\;\;\;x \cdot \left(\frac{x}{y} + 1\right)\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+119}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 3: 98.6% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -38 or 8e4 < x

    1. Initial program 75.3%

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y} + 1}{\frac{x + 1}{x}}} \]
      3. +-commutative100.0%

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{1 + x}}{x}} \]
      4. remove-double-neg100.0%

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

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{1}{x} - \color{blue}{-1}} \]
    3. Simplified100.0%

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

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

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

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

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

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

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

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

    if -38 < x < 8e4

    1. Initial program 99.9%

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{1 + x}}{x}} \]
      4. remove-double-neg99.6%

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\color{blue}{\frac{1}{x} - \frac{-x}{x}}} \]
      7. distribute-frac-neg99.6%

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

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

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

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

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

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

        \[\leadsto \frac{1}{1 + \frac{1}{x}} + \frac{-x}{-\color{blue}{\log \left(e^{y \cdot \left(1 + \frac{1}{x}\right)}\right)}} \]
      3. neg-log72.3%

        \[\leadsto \frac{1}{1 + \frac{1}{x}} + \frac{-x}{\color{blue}{\log \left(\frac{1}{e^{y \cdot \left(1 + \frac{1}{x}\right)}}\right)}} \]
      4. distribute-lft-in72.3%

        \[\leadsto \frac{1}{1 + \frac{1}{x}} + \frac{-x}{\log \left(\frac{1}{e^{\color{blue}{y \cdot 1 + y \cdot \frac{1}{x}}}}\right)} \]
      5. div-inv72.3%

        \[\leadsto \frac{1}{1 + \frac{1}{x}} + \frac{-x}{\log \left(\frac{1}{e^{y \cdot 1 + \color{blue}{\frac{y}{x}}}}\right)} \]
      6. exp-sum46.2%

        \[\leadsto \frac{1}{1 + \frac{1}{x}} + \frac{-x}{\log \left(\frac{1}{\color{blue}{e^{y \cdot 1} \cdot e^{\frac{y}{x}}}}\right)} \]
      7. *-rgt-identity46.2%

        \[\leadsto \frac{1}{1 + \frac{1}{x}} + \frac{-x}{\log \left(\frac{1}{e^{\color{blue}{y}} \cdot e^{\frac{y}{x}}}\right)} \]
      8. exp-sum72.3%

        \[\leadsto \frac{1}{1 + \frac{1}{x}} + \frac{-x}{\log \left(\frac{1}{\color{blue}{e^{y + \frac{y}{x}}}}\right)} \]
      9. neg-log72.3%

        \[\leadsto \frac{1}{1 + \frac{1}{x}} + \frac{-x}{\color{blue}{-\log \left(e^{y + \frac{y}{x}}\right)}} \]
      10. add-log-exp99.7%

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

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

        \[\leadsto \frac{1}{1 + \frac{1}{x}} + \frac{1}{\color{blue}{\frac{y + \frac{y}{x}}{x}}} \]
      13. inv-pow99.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto x + \frac{x}{y + \frac{\color{blue}{y}}{x}} \]
    12. Simplified98.8%

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

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

Alternative 4: 72.9% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq 9.2 \cdot 10^{-16}:\\
\;\;\;\;x\\

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

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


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

    1. Initial program 71.8%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in x around inf 80.0%

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

    if -1 < x < 9.1999999999999996e-16

    1. Initial program 99.9%

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

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

    if 9.1999999999999996e-16 < x < 3.99999999999999978e119

    1. Initial program 95.7%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in x around inf 86.4%

      \[\leadsto \color{blue}{\left(1 + \left(\frac{1}{x \cdot y} + \frac{x}{y}\right)\right) - \left(\frac{1}{x} + \frac{1}{y}\right)} \]
    3. Step-by-step derivation
      1. associate--r+86.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+119}:\\ \;\;\;\;1 + \frac{-1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 5: 97.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 75.3%

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y} + 1}{\frac{x + 1}{x}}} \]
      3. +-commutative100.0%

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{1 + x}}{x}} \]
      4. remove-double-neg100.0%

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

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{1}{x} - \color{blue}{-1}} \]
    3. Simplified100.0%

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

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

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

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

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

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

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

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

    if -1 < x < 1.19999999999999996

    1. Initial program 99.9%

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{1 + x}}{x}} \]
      4. remove-double-neg99.6%

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\color{blue}{\frac{1}{x} - \frac{-x}{x}}} \]
      7. distribute-frac-neg99.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y} + 1}{1} \cdot x} \]
      2. /-rgt-identity97.9%

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

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

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

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

Alternative 6: 97.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 75.3%

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y} + 1}{\frac{x + 1}{x}}} \]
      3. +-commutative100.0%

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{1 + x}}{x}} \]
      4. remove-double-neg100.0%

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

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{1}{x} - \color{blue}{-1}} \]
    3. Simplified100.0%

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

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

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

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

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

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

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

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

    if -1 < x < 1.25

    1. Initial program 99.9%

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{1 + x}}{x}} \]
      4. remove-double-neg99.6%

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\color{blue}{\frac{1}{x} - \frac{-x}{x}}} \]
      7. distribute-frac-neg99.6%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x}{y} + 1}{1} \cdot x} \]
      2. /-rgt-identity97.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot x + 1 \cdot x} \]
      4. *-un-lft-identity97.9%

        \[\leadsto \frac{x}{y} \cdot x + \color{blue}{x} \]
    8. Applied egg-rr97.9%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot x + x} \]
    9. Step-by-step derivation
      1. associate-*l/89.5%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{x}}} + x \]
    10. Applied egg-rr98.0%

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

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

Alternative 7: 99.8% accurate, 1.0× speedup?

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

\\
\frac{\frac{x}{y} + 1}{\frac{1}{x} - -1}
\end{array}
Derivation
  1. Initial program 87.8%

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

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

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

      \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{1 + x}}{x}} \]
    4. remove-double-neg99.8%

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

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

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

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

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

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

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

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

Alternative 8: 73.0% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 0.0078:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{+119}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.0)
   (/ x y)
   (if (<= x 0.0078) x (if (<= x 4.4e+119) 1.0 (/ x y)))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.0) {
		tmp = x / y;
	} else if (x <= 0.0078) {
		tmp = x;
	} else if (x <= 4.4e+119) {
		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 <= 0.0078d0) then
        tmp = x
    else if (x <= 4.4d+119) 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 <= 0.0078) {
		tmp = x;
	} else if (x <= 4.4e+119) {
		tmp = 1.0;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.0:
		tmp = x / y
	elif x <= 0.0078:
		tmp = x
	elif x <= 4.4e+119:
		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 <= 0.0078)
		tmp = x;
	elseif (x <= 4.4e+119)
		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 <= 0.0078)
		tmp = x;
	elseif (x <= 4.4e+119)
		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, 0.0078], x, If[LessEqual[x, 4.4e+119], 1.0, N[(x / y), $MachinePrecision]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq 4.4 \cdot 10^{+119}:\\
\;\;\;\;1\\

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


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

    1. Initial program 71.8%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in x around inf 80.0%

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

    if -1 < x < 0.0077999999999999996

    1. Initial program 99.9%

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

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

    if 0.0077999999999999996 < x < 4.4000000000000003e119

    1. Initial program 95.2%

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

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    4. Simplified76.2%

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

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

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

Alternative 9: 74.1% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 70.7%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in x around inf 83.0%

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

    if -4.6e11 < x < 3.99999999999999978e119

    1. Initial program 99.3%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in y around inf 72.8%

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    4. Simplified72.8%

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

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

Alternative 10: 48.7% accurate, 2.1× speedup?

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

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

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

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


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

    1. Initial program 75.5%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Taylor expanded in y around inf 28.0%

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    4. Simplified28.0%

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

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

    if -1 < x < 0.0077999999999999996

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 0.0078:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 11: 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.8%

    \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
  2. Taylor expanded in y around inf 50.0%

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

      \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
  4. Simplified50.0%

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

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

    \[\leadsto 1 \]

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 2023310 
(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)))