Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.3% → 99.9%
Time: 7.0s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 88.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 2: 95.4% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 78.5%

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

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

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    4. Taylor expanded in x around inf 99.4%

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. neg-mul-199.4%

        \[\leadsto 1 - \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. distribute-neg-frac99.4%

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

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

    if -1 < 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.8%

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 80.2%

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

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    3. Applied egg-rr80.2%

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    4. Taylor expanded in x around inf 98.9%

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

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

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

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

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

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

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

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

Alternative 3: 72.2% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-96}:\\
\;\;\;\;x\\

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

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


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

    1. Initial program 77.8%

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

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

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

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

    if -1.4499999999999999e75 < x < -1

    1. Initial program 100.0%

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

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    3. Applied egg-rr99.8%

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    4. Taylor expanded in x around inf 95.5%

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\frac{1 - x}{y}} \]
    6. Simplified95.5%

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

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

    if -1 < x < 1.40000000000000008e-96

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

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

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

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

    if 1.40000000000000008e-96 < x < 1

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.5%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot x} \]
    7. Applied egg-rr66.7%

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

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

Alternative 4: 72.4% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;x \leq 1.35 \cdot 10^{-95}:\\
\;\;\;\;x - x \cdot x\\

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

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


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

    1. Initial program 77.8%

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

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

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

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

    if -1.04999999999999999e75 < x < -1

    1. Initial program 100.0%

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

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    3. Applied egg-rr99.8%

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    4. Taylor expanded in x around inf 95.5%

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\frac{1 - x}{y}} \]
    6. Simplified95.5%

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

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

    if -1 < x < 1.35e-95

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

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

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

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

      \[\leadsto \color{blue}{x + -1 \cdot {x}^{2}} \]
    6. Step-by-step derivation
      1. mul-1-neg81.9%

        \[\leadsto x + \color{blue}{\left(-{x}^{2}\right)} \]
      2. unsub-neg81.9%

        \[\leadsto \color{blue}{x - {x}^{2}} \]
      3. unpow281.9%

        \[\leadsto x - \color{blue}{x \cdot x} \]
    7. Simplified81.9%

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

    if 1.35e-95 < x < 1

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.5%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot x} \]
    7. Applied egg-rr66.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.05 \cdot 10^{+75}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-95}:\\ \;\;\;\;x - x \cdot x\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 5: 84.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.85 \cdot 10^{+26}:\\
\;\;\;\;1 + \frac{x}{y}\\

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

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

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


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

    1. Initial program 77.1%

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

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    3. Applied egg-rr77.0%

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. neg-mul-1100.0%

        \[\leadsto 1 - \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. distribute-neg-frac100.0%

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

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

    if -2.8500000000000002e26 < x < 1.99999999999999998e-95

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.9%

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

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

    if 1.99999999999999998e-95 < x < 1

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.5%

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

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

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

    if 1 < x

    1. Initial program 80.2%

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

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    3. Applied egg-rr80.2%

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    4. Taylor expanded in x around inf 98.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.85 \cdot 10^{+26}:\\ \;\;\;\;1 + \frac{x}{y}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-95}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x + -1}{y}\\ \end{array} \]

Alternative 6: 84.8% accurate, 0.8× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.8500000000000002e26 or 6.4e6 < x

    1. Initial program 78.6%

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

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

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    4. Taylor expanded in x around inf 99.9%

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. neg-mul-199.9%

        \[\leadsto 1 - \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. distribute-neg-frac99.9%

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

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

    if -2.8500000000000002e26 < x < 2.4999999999999998e-97

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.9%

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

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

    if 2.4999999999999998e-97 < x < 6.4e6

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.85 \cdot 10^{+26}:\\ \;\;\;\;1 + \frac{x}{y}\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-97}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 6400000:\\ \;\;\;\;\frac{x}{y + \frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{y}\\ \end{array} \]

Alternative 7: 72.8% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 77.8%

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

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

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

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

    if -1.7999999999999999e77 < x < 7.20000000000000016e-96

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.9%

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

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

    if 7.20000000000000016e-96 < x < 1

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.5%

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} \cdot x} \]
    7. Applied egg-rr66.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{+77}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-96}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;x \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 8: 72.8% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 77.8%

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

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

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

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

    if -1.34999999999999995e76 < x < 2.29999999999999999e-95

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.9%

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

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

    if 2.29999999999999999e-95 < x < 1

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{+76}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-95}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 9: 72.8% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 75.1%

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

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

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

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

    if -6.5e77 < x < 1.9e-96

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.9%

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

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

    if 1.9e-96 < x < 1.30000000000000004

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.5%

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

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

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

    if 1.30000000000000004 < x

    1. Initial program 80.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+77}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-96}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.3:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + -1}{y}\\ \end{array} \]

Alternative 10: 84.5% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 79.1%

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

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    3. Applied egg-rr79.0%

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    4. Taylor expanded in x around inf 98.0%

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{-1 \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. neg-mul-198.0%

        \[\leadsto 1 - \color{blue}{\left(-\frac{x}{y}\right)} \]
      2. distribute-neg-frac98.0%

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

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

    if -2.8500000000000002e26 < x < 2.29999999999999999e-95

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.9%

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

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

    if 2.29999999999999999e-95 < x < 1.6e-12

    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}{\frac{x}{\frac{x + 1}{\frac{x}{y} + 1}}} \]
    3. Simplified99.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.85 \cdot 10^{+26}:\\ \;\;\;\;1 + \frac{x}{y}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-95}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-12}:\\ \;\;\;\;\frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{x}{y}\\ \end{array} \]

Alternative 11: 73.2% accurate, 1.2× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.20000000000000014e78 or 0.450000000000000011 < 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*100.0%

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

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

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

    if -2.20000000000000014e78 < x < -1

    1. Initial program 100.0%

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

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    3. Applied egg-rr99.8%

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    4. Taylor expanded in x around inf 95.5%

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{\frac{1 - x}{y}} \]
    6. Simplified95.5%

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

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

    if -1 < x < 0.450000000000000011

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

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

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

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

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

Alternative 12: 50.1% accurate, 2.1× speedup?

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

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

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

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


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

    1. Initial program 79.4%

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

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

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
    4. Taylor expanded in x around inf 99.1%

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

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

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

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

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

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

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

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

    if -1 < 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.8%

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

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

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

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

Alternative 13: 14.8% 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.4%

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

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
  3. Applied egg-rr89.4%

    \[\leadsto \frac{x \cdot \color{blue}{\mathsf{fma}\left(\frac{1}{y}, x, 1\right)}}{x + 1} \]
  4. Taylor expanded in x around inf 51.9%

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

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

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

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

      \[\leadsto \color{blue}{1 - \left(\frac{1}{y} - \frac{x}{y}\right)} \]
    5. div-sub51.9%

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

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

    \[\leadsto \color{blue}{1} \]
  8. Final simplification17.2%

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