Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

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

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

Initial Program: 87.8% accurate, 1.0× speedup?

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

\\
\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}
\end{array}

Alternative 1: 99.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
\frac{x}{y} \cdot t\_0 + t\_0
\end{array}
\end{array}
Derivation
  1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(x \cdot \frac{1}{1 + x}\right) \cdot \color{blue}{\left(1 + \frac{x}{y}\right)} \]
    5. distribute-lft-in99.8%

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

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

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

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

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

      \[\leadsto \frac{x}{x + 1} + \color{blue}{\frac{x}{1 + x}} \cdot \frac{x}{y} \]
    11. +-commutative99.9%

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

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

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

Alternative 2: 74.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -3.6 \cdot 10^{+129}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1950000000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-52}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 2.65 \cdot 10^{+14}:\\ \;\;\;\;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 -3.6e+129)
     (/ x y)
     (if (<= x -2.05e+106)
       1.0
       (if (<= x -1950000000.0)
         (/ x y)
         (if (<= x 1.45e-52)
           t_0
           (if (<= x 9e-9)
             (* x (/ x y))
             (if (<= x 2.65e+14) t_0 (/ x y)))))))))
double code(double x, double y) {
	double t_0 = x / (x + 1.0);
	double tmp;
	if (x <= -3.6e+129) {
		tmp = x / y;
	} else if (x <= -2.05e+106) {
		tmp = 1.0;
	} else if (x <= -1950000000.0) {
		tmp = x / y;
	} else if (x <= 1.45e-52) {
		tmp = t_0;
	} else if (x <= 9e-9) {
		tmp = x * (x / y);
	} else if (x <= 2.65e+14) {
		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 <= (-3.6d+129)) then
        tmp = x / y
    else if (x <= (-2.05d+106)) then
        tmp = 1.0d0
    else if (x <= (-1950000000.0d0)) then
        tmp = x / y
    else if (x <= 1.45d-52) then
        tmp = t_0
    else if (x <= 9d-9) then
        tmp = x * (x / y)
    else if (x <= 2.65d+14) 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 <= -3.6e+129) {
		tmp = x / y;
	} else if (x <= -2.05e+106) {
		tmp = 1.0;
	} else if (x <= -1950000000.0) {
		tmp = x / y;
	} else if (x <= 1.45e-52) {
		tmp = t_0;
	} else if (x <= 9e-9) {
		tmp = x * (x / y);
	} else if (x <= 2.65e+14) {
		tmp = t_0;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (x + 1.0)
	tmp = 0
	if x <= -3.6e+129:
		tmp = x / y
	elif x <= -2.05e+106:
		tmp = 1.0
	elif x <= -1950000000.0:
		tmp = x / y
	elif x <= 1.45e-52:
		tmp = t_0
	elif x <= 9e-9:
		tmp = x * (x / y)
	elif x <= 2.65e+14:
		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 <= -3.6e+129)
		tmp = Float64(x / y);
	elseif (x <= -2.05e+106)
		tmp = 1.0;
	elseif (x <= -1950000000.0)
		tmp = Float64(x / y);
	elseif (x <= 1.45e-52)
		tmp = t_0;
	elseif (x <= 9e-9)
		tmp = Float64(x * Float64(x / y));
	elseif (x <= 2.65e+14)
		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 <= -3.6e+129)
		tmp = x / y;
	elseif (x <= -2.05e+106)
		tmp = 1.0;
	elseif (x <= -1950000000.0)
		tmp = x / y;
	elseif (x <= 1.45e-52)
		tmp = t_0;
	elseif (x <= 9e-9)
		tmp = x * (x / y);
	elseif (x <= 2.65e+14)
		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, -3.6e+129], N[(x / y), $MachinePrecision], If[LessEqual[x, -2.05e+106], 1.0, If[LessEqual[x, -1950000000.0], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.45e-52], t$95$0, If[LessEqual[x, 9e-9], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.65e+14], t$95$0, N[(x / y), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -1950000000:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 9 \cdot 10^{-9}:\\
\;\;\;\;x \cdot \frac{x}{y}\\

\mathbf{elif}\;x \leq 2.65 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -3.6000000000000001e129 or -2.0500000000000001e106 < x < -1.95e9 or 2.65e14 < x

    1. Initial program 77.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 77.7%

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

    if -3.6000000000000001e129 < x < -2.0500000000000001e106

    1. Initial program 100.0%

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
    6. Step-by-step derivation
      1. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
      2. clear-num100.0%

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

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

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

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

    if -1.95e9 < x < 1.4500000000000001e-52 or 8.99999999999999953e-9 < x < 2.65e14

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

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

    if 1.4500000000000001e-52 < x < 8.99999999999999953e-9

    1. Initial program 99.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+129}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1950000000:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-52}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 2.65 \cdot 10^{+14}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 74.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{+129}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -600000000:\\ \;\;\;\;\frac{x + -1}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-52}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-8}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+14}:\\ \;\;\;\;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 -3.4e+129)
     (/ x y)
     (if (<= x -2.05e+106)
       1.0
       (if (<= x -600000000.0)
         (/ (+ x -1.0) y)
         (if (<= x 1.25e-52)
           t_0
           (if (<= x 1.05e-8)
             (* x (/ x y))
             (if (<= x 2.3e+14) t_0 (/ x y)))))))))
double code(double x, double y) {
	double t_0 = x / (x + 1.0);
	double tmp;
	if (x <= -3.4e+129) {
		tmp = x / y;
	} else if (x <= -2.05e+106) {
		tmp = 1.0;
	} else if (x <= -600000000.0) {
		tmp = (x + -1.0) / y;
	} else if (x <= 1.25e-52) {
		tmp = t_0;
	} else if (x <= 1.05e-8) {
		tmp = x * (x / y);
	} else if (x <= 2.3e+14) {
		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 <= (-3.4d+129)) then
        tmp = x / y
    else if (x <= (-2.05d+106)) then
        tmp = 1.0d0
    else if (x <= (-600000000.0d0)) then
        tmp = (x + (-1.0d0)) / y
    else if (x <= 1.25d-52) then
        tmp = t_0
    else if (x <= 1.05d-8) then
        tmp = x * (x / y)
    else if (x <= 2.3d+14) 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 <= -3.4e+129) {
		tmp = x / y;
	} else if (x <= -2.05e+106) {
		tmp = 1.0;
	} else if (x <= -600000000.0) {
		tmp = (x + -1.0) / y;
	} else if (x <= 1.25e-52) {
		tmp = t_0;
	} else if (x <= 1.05e-8) {
		tmp = x * (x / y);
	} else if (x <= 2.3e+14) {
		tmp = t_0;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (x + 1.0)
	tmp = 0
	if x <= -3.4e+129:
		tmp = x / y
	elif x <= -2.05e+106:
		tmp = 1.0
	elif x <= -600000000.0:
		tmp = (x + -1.0) / y
	elif x <= 1.25e-52:
		tmp = t_0
	elif x <= 1.05e-8:
		tmp = x * (x / y)
	elif x <= 2.3e+14:
		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 <= -3.4e+129)
		tmp = Float64(x / y);
	elseif (x <= -2.05e+106)
		tmp = 1.0;
	elseif (x <= -600000000.0)
		tmp = Float64(Float64(x + -1.0) / y);
	elseif (x <= 1.25e-52)
		tmp = t_0;
	elseif (x <= 1.05e-8)
		tmp = Float64(x * Float64(x / y));
	elseif (x <= 2.3e+14)
		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 <= -3.4e+129)
		tmp = x / y;
	elseif (x <= -2.05e+106)
		tmp = 1.0;
	elseif (x <= -600000000.0)
		tmp = (x + -1.0) / y;
	elseif (x <= 1.25e-52)
		tmp = t_0;
	elseif (x <= 1.05e-8)
		tmp = x * (x / y);
	elseif (x <= 2.3e+14)
		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, -3.4e+129], N[(x / y), $MachinePrecision], If[LessEqual[x, -2.05e+106], 1.0, If[LessEqual[x, -600000000.0], N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 1.25e-52], t$95$0, If[LessEqual[x, 1.05e-8], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.3e+14], t$95$0, N[(x / y), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.05 \cdot 10^{-8}:\\
\;\;\;\;x \cdot \frac{x}{y}\\

\mathbf{elif}\;x \leq 2.3 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -3.40000000000000018e129 or 2.3e14 < x

    1. Initial program 73.1%

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

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

    if -3.40000000000000018e129 < x < -2.0500000000000001e106

    1. Initial program 100.0%

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
    6. Step-by-step derivation
      1. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
      2. clear-num100.0%

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

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

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

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

    if -2.0500000000000001e106 < x < -6e8

    1. Initial program 95.4%

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

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

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

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

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

    if -6e8 < x < 1.25e-52 or 1.04999999999999997e-8 < x < 2.3e14

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

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

    if 1.25e-52 < x < 1.04999999999999997e-8

    1. Initial program 99.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{+129}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -600000000:\\ \;\;\;\;\frac{x + -1}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-52}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-8}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+14}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 74.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+129}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -180000000:\\ \;\;\;\;\frac{x + -1}{y}\\ \mathbf{elif}\;x \leq 10^{-52}:\\ \;\;\;\;x \cdot \frac{1}{x + 1}\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+18}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -9e+129)
   (/ x y)
   (if (<= x -2.05e+106)
     1.0
     (if (<= x -180000000.0)
       (/ (+ x -1.0) y)
       (if (<= x 1e-52)
         (* x (/ 1.0 (+ x 1.0)))
         (if (<= x 6.8e-9)
           (* x (/ x y))
           (if (<= x 7.5e+18) (/ x (+ x 1.0)) (/ x y))))))))
double code(double x, double y) {
	double tmp;
	if (x <= -9e+129) {
		tmp = x / y;
	} else if (x <= -2.05e+106) {
		tmp = 1.0;
	} else if (x <= -180000000.0) {
		tmp = (x + -1.0) / y;
	} else if (x <= 1e-52) {
		tmp = x * (1.0 / (x + 1.0));
	} else if (x <= 6.8e-9) {
		tmp = x * (x / y);
	} else if (x <= 7.5e+18) {
		tmp = x / (x + 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 <= (-9d+129)) then
        tmp = x / y
    else if (x <= (-2.05d+106)) then
        tmp = 1.0d0
    else if (x <= (-180000000.0d0)) then
        tmp = (x + (-1.0d0)) / y
    else if (x <= 1d-52) then
        tmp = x * (1.0d0 / (x + 1.0d0))
    else if (x <= 6.8d-9) then
        tmp = x * (x / y)
    else if (x <= 7.5d+18) then
        tmp = x / (x + 1.0d0)
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -9e+129) {
		tmp = x / y;
	} else if (x <= -2.05e+106) {
		tmp = 1.0;
	} else if (x <= -180000000.0) {
		tmp = (x + -1.0) / y;
	} else if (x <= 1e-52) {
		tmp = x * (1.0 / (x + 1.0));
	} else if (x <= 6.8e-9) {
		tmp = x * (x / y);
	} else if (x <= 7.5e+18) {
		tmp = x / (x + 1.0);
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -9e+129:
		tmp = x / y
	elif x <= -2.05e+106:
		tmp = 1.0
	elif x <= -180000000.0:
		tmp = (x + -1.0) / y
	elif x <= 1e-52:
		tmp = x * (1.0 / (x + 1.0))
	elif x <= 6.8e-9:
		tmp = x * (x / y)
	elif x <= 7.5e+18:
		tmp = x / (x + 1.0)
	else:
		tmp = x / y
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -9e+129)
		tmp = Float64(x / y);
	elseif (x <= -2.05e+106)
		tmp = 1.0;
	elseif (x <= -180000000.0)
		tmp = Float64(Float64(x + -1.0) / y);
	elseif (x <= 1e-52)
		tmp = Float64(x * Float64(1.0 / Float64(x + 1.0)));
	elseif (x <= 6.8e-9)
		tmp = Float64(x * Float64(x / y));
	elseif (x <= 7.5e+18)
		tmp = Float64(x / Float64(x + 1.0));
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -9e+129)
		tmp = x / y;
	elseif (x <= -2.05e+106)
		tmp = 1.0;
	elseif (x <= -180000000.0)
		tmp = (x + -1.0) / y;
	elseif (x <= 1e-52)
		tmp = x * (1.0 / (x + 1.0));
	elseif (x <= 6.8e-9)
		tmp = x * (x / y);
	elseif (x <= 7.5e+18)
		tmp = x / (x + 1.0);
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -9e+129], N[(x / y), $MachinePrecision], If[LessEqual[x, -2.05e+106], 1.0, If[LessEqual[x, -180000000.0], N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 1e-52], N[(x * N[(1.0 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.8e-9], N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.5e+18], N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\
\;\;\;\;1\\

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

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

\mathbf{elif}\;x \leq 6.8 \cdot 10^{-9}:\\
\;\;\;\;x \cdot \frac{x}{y}\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{+18}:\\
\;\;\;\;\frac{x}{x + 1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < -9.0000000000000003e129 or 7.5e18 < x

    1. Initial program 73.1%

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

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

    if -9.0000000000000003e129 < x < -2.0500000000000001e106

    1. Initial program 100.0%

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
    6. Step-by-step derivation
      1. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
      2. clear-num100.0%

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

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

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

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

    if -2.0500000000000001e106 < x < -1.8e8

    1. Initial program 95.4%

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

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

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

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

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

    if -1.8e8 < x < 1e-52

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

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

    if 1e-52 < x < 6.7999999999999997e-9

    1. Initial program 99.6%

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

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

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

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

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

    if 6.7999999999999997e-9 < x < 7.5e18

    1. Initial program 99.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+129}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -180000000:\\ \;\;\;\;\frac{x + -1}{y}\\ \mathbf{elif}\;x \leq 10^{-52}:\\ \;\;\;\;x \cdot \frac{1}{x + 1}\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+18}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 73.3% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \leq 1.3 \cdot 10^{-52}:\\
\;\;\;\;x \cdot \left(1 - x\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -3.40000000000000018e129 or -2.0500000000000001e106 < x < -1 or 4.2e11 < x

    1. Initial program 77.6%

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

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

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

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

    if -3.40000000000000018e129 < x < -2.0500000000000001e106

    1. Initial program 100.0%

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
    6. Step-by-step derivation
      1. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
      2. clear-num100.0%

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

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

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

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

    if -1 < x < 1.2999999999999999e-52

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
    6. Taylor expanded in x around 0 82.0%

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

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

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

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

    if 1.2999999999999999e-52 < x < 4.2e11

    1. Initial program 99.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{+129}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-52}:\\ \;\;\;\;x \cdot \left(1 - x\right)\\ \mathbf{elif}\;x \leq 420000000000:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 86.3% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;x \leq 6.8 \cdot 10^{-9}:\\
\;\;\;\;x \cdot \frac{x}{y}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.45e8 or 4.2e11 < x

    1. Initial program 78.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. Step-by-step derivation
      1. clear-num99.8%

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

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

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

      \[\leadsto \color{blue}{\left(1 + \frac{x}{y}\right) - \frac{1}{y}} \]
    8. 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} \]
      5. +-commutative100.0%

        \[\leadsto 1 + \frac{\color{blue}{-1 + x}}{y} \]
      6. metadata-eval100.0%

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

        \[\leadsto 1 + \frac{-1 \cdot 1 + \color{blue}{\left(-\left(-x\right)\right)}}{y} \]
      8. neg-mul-1100.0%

        \[\leadsto 1 + \frac{-1 \cdot 1 + \color{blue}{-1 \cdot \left(-x\right)}}{y} \]
      9. distribute-lft-in100.0%

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot \left(1 + \left(-x\right)\right)}}{y} \]
      10. neg-mul-1100.0%

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

        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{1 + -1 \cdot x}{y}} \]
      12. mul-1-neg100.0%

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

        \[\leadsto \color{blue}{1 - \frac{1 + -1 \cdot x}{y}} \]
      14. neg-mul-1100.0%

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

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

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

    if -1.45e8 < x < 1.2999999999999999e-52

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

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

    if 1.2999999999999999e-52 < x < 6.7999999999999997e-9

    1. Initial program 99.6%

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

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

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

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

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

    if 6.7999999999999997e-9 < x < 4.2e11

    1. Initial program 99.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -145000000:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-52}:\\ \;\;\;\;x \cdot \frac{1}{x + 1}\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 420000000000:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 74.0% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -1 \lor \neg \left(x \leq 0.55\right):\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.8999999999999997e129 or -2.0500000000000001e106 < x < -1 or 0.55000000000000004 < x

    1. Initial program 77.9%

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

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

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

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

    if -3.8999999999999997e129 < x < -2.0500000000000001e106

    1. Initial program 100.0%

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
    6. Step-by-step derivation
      1. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
      2. clear-num100.0%

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

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

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

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

    if -1 < x < 0.55000000000000004

    1. Initial program 99.9%

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
    6. Taylor expanded in x around 0 76.0%

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

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

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

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

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

Alternative 8: 86.2% accurate, 0.5× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.45e8 or 2.39999999999999998e-8 < x

    1. Initial program 78.6%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 + \frac{\color{blue}{-1 + x}}{y} \]
      6. metadata-eval98.2%

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot 1} + x}{y} \]
      7. remove-double-neg98.2%

        \[\leadsto 1 + \frac{-1 \cdot 1 + \color{blue}{\left(-\left(-x\right)\right)}}{y} \]
      8. neg-mul-198.2%

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

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot \left(1 + \left(-x\right)\right)}}{y} \]
      10. neg-mul-198.2%

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

        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{1 + -1 \cdot x}{y}} \]
      12. mul-1-neg98.2%

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

        \[\leadsto \color{blue}{1 - \frac{1 + -1 \cdot x}{y}} \]
      14. neg-mul-198.2%

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

        \[\leadsto 1 - \frac{\color{blue}{1 - x}}{y} \]
    9. Simplified98.2%

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

    if -1.45e8 < x < 1.4200000000000001e-52

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

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

    if 1.4200000000000001e-52 < x < 2.39999999999999998e-8

    1. Initial program 99.6%

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

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

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

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

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

Alternative 9: 86.6% accurate, 0.5× speedup?

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

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

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

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

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


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

    1. Initial program 82.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(1 + \frac{x}{y}\right) - \frac{1}{y}} \]
    8. 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} \]
      5. +-commutative100.0%

        \[\leadsto 1 + \frac{\color{blue}{-1 + x}}{y} \]
      6. metadata-eval100.0%

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

        \[\leadsto 1 + \frac{-1 \cdot 1 + \color{blue}{\left(-\left(-x\right)\right)}}{y} \]
      8. neg-mul-1100.0%

        \[\leadsto 1 + \frac{-1 \cdot 1 + \color{blue}{-1 \cdot \left(-x\right)}}{y} \]
      9. distribute-lft-in100.0%

        \[\leadsto 1 + \frac{\color{blue}{-1 \cdot \left(1 + \left(-x\right)\right)}}{y} \]
      10. neg-mul-1100.0%

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

        \[\leadsto 1 + \color{blue}{-1 \cdot \frac{1 + -1 \cdot x}{y}} \]
      12. mul-1-neg100.0%

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

        \[\leadsto \color{blue}{1 - \frac{1 + -1 \cdot x}{y}} \]
      14. neg-mul-1100.0%

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

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

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

    if -1.45e8 < x < 1.25e-52

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

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

    if 1.25e-52 < x < 8.5e-9

    1. Initial program 99.6%

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

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

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

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

    if 8.5e-9 < x

    1. Initial program 75.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(x \cdot \frac{1}{1 + x}\right) \cdot \color{blue}{\left(1 + \frac{x}{y}\right)} \]
      5. distribute-lft-in99.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -145000000:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-52}:\\ \;\;\;\;x \cdot \frac{1}{x + 1}\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot \left(x + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} + \frac{x}{x + 1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 73.6% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;x \leq -2.05 \cdot 10^{+106}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \leq -1 \lor \neg \left(x \leq 420000000000\right):\\
\;\;\;\;\frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.40000000000000018e129 or -2.0500000000000001e106 < x < -1 or 4.2e11 < x

    1. Initial program 77.6%

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

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

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

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

    if -3.40000000000000018e129 < x < -2.0500000000000001e106

    1. Initial program 100.0%

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
    6. Step-by-step derivation
      1. un-div-inv100.0%

        \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
      2. clear-num100.0%

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

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

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

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

    if -1 < x < 4.2e11

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

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

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

Alternative 11: 49.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.053:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= x -0.053) 1.0 (if (<= x 1.0) x 1.0)))
double code(double x, double y) {
	double tmp;
	if (x <= -0.053) {
		tmp = 1.0;
	} else if (x <= 1.0) {
		tmp = x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-0.053d0)) then
        tmp = 1.0d0
    else if (x <= 1.0d0) then
        tmp = x
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -0.053) {
		tmp = 1.0;
	} else if (x <= 1.0) {
		tmp = x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -0.053:
		tmp = 1.0
	elif x <= 1.0:
		tmp = x
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -0.053)
		tmp = 1.0;
	elseif (x <= 1.0)
		tmp = x;
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -0.053)
		tmp = 1.0;
	elseif (x <= 1.0)
		tmp = x;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -0.053], 1.0, If[LessEqual[x, 1.0], x, 1.0]]
\begin{array}{l}

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

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

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


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

    1. Initial program 79.0%

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

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
    6. Step-by-step derivation
      1. un-div-inv29.0%

        \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
      2. clear-num29.0%

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

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

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

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

    if -0.0529999999999999985 < x < 1

    1. Initial program 99.9%

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

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

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

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

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

Alternative 12: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 13: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

Alternative 14: 14.2% accurate, 11.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 89.3%

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

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

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

    \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x}} \]
  6. Step-by-step derivation
    1. un-div-inv52.8%

      \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
    2. clear-num52.7%

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

      \[\leadsto \frac{1}{\frac{\color{blue}{x + 1}}{x}} \]
  7. Applied egg-rr52.7%

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

    \[\leadsto \color{blue}{1} \]
  9. Final simplification16.0%

    \[\leadsto 1 \]
  10. Add Preprocessing

Developer target: 99.9% accurate, 0.8× speedup?

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

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

Reproduce

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