Codec.Picture.Types:toneMapping from JuicyPixels-3.2.6.1

Percentage Accurate: 88.0% → 99.8%
Time: 6.9s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 88.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1}\\
t_1 := y + \frac{y}{x}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+100}:\\
\;\;\;\;\frac{x}{t_1}\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-34}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) < -1.00000000000000002e100

    1. Initial program 60.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\frac{1}{-x} - \color{blue}{1}}{-1}} \]
      12. div-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e100 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1)) < 1.99999999999999986e-34

    1. Initial program 99.9%

      \[\frac{x \cdot \left(\frac{x}{y} + 1\right)}{x + 1} \]
    2. Add Preprocessing

    if 1.99999999999999986e-34 < (/.f64 (*.f64 x (+.f64 (/.f64 x y) 1)) (+.f64 x 1))

    1. Initial program 78.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\frac{1}{-x} - \color{blue}{1}}{-1}} \]
      12. div-sub99.9%

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{1}{\color{blue}{-\left(-x\right)}} - \frac{1}{-1}} \]
      16. remove-double-neg99.9%

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{1}{\color{blue}{x}} - \frac{1}{-1}} \]
      17. metadata-eval99.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{1 + \frac{1}{x}} + \frac{\frac{x}{y}}{1 + \frac{1}{x}}} \]
      2. associate-/l/99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-43} \lor \neg \left(x \leq 6 \cdot 10^{-23}\right):\\
\;\;\;\;\frac{x + y}{y + \frac{y}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.1000000000000001e-43 or 6.00000000000000006e-23 < x

    1. Initial program 74.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\frac{1}{-x} - \color{blue}{1}}{-1}} \]
      12. div-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{1 + \frac{1}{x}} + \frac{\frac{x}{y}}{1 + \frac{1}{x}}} \]
      2. associate-/l/100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.1000000000000001e-43 < x < 6.00000000000000006e-23

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{\frac{1}{-x} - \frac{-x}{-x}}}{-1}} \]
      11. *-inverses99.6%

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\frac{1}{-x} - \color{blue}{1}}{-1}} \]
      12. div-sub99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 94.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+168} \lor \neg \left(y \leq 3.2 \cdot 10^{+149}\right):\\
\;\;\;\;\frac{x}{x + 1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.5000000000000001e168 or 3.2000000000000002e149 < y

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    5. Simplified96.6%

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

    if -5.5000000000000001e168 < y < 3.2000000000000002e149

    1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{\frac{1}{-x} - \frac{-x}{-x}}}{-1}} \]
      11. *-inverses99.8%

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\frac{1}{-x} - \color{blue}{1}}{-1}} \]
      12. div-sub99.8%

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

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

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

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

        \[\leadsto \frac{\frac{x}{y} + 1}{\frac{1}{\color{blue}{x}} - \frac{1}{-1}} \]
      17. metadata-eval99.8%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{1 + \frac{1}{x}} + \frac{\frac{x}{y}}{1 + \frac{1}{x}}} \]
      2. associate-/l/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{x + y}}{y + \frac{y}{x}} \]
    13. Simplified96.7%

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

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

Alternative 4: 86.5% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 71.6%

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

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

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

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

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

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

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

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

    if -5.8e10 < x < 3500

    1. Initial program 99.9%

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

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

        \[\leadsto \frac{x}{\color{blue}{x + 1}} \]
    5. Simplified77.5%

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

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

Alternative 5: 99.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \frac{1}{x}\\ \frac{\frac{x}{y}}{t_0} + \frac{1}{t_0} \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ 1.0 (/ 1.0 x)))) (+ (/ (/ x y) t_0) (/ 1.0 t_0))))
double code(double x, double y) {
	double t_0 = 1.0 + (1.0 / x);
	return ((x / y) / t_0) + (1.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 = 1.0d0 + (1.0d0 / x)
    code = ((x / y) / t_0) + (1.0d0 / t_0)
end function
public static double code(double x, double y) {
	double t_0 = 1.0 + (1.0 / x);
	return ((x / y) / t_0) + (1.0 / t_0);
}
def code(x, y):
	t_0 = 1.0 + (1.0 / x)
	return ((x / y) / t_0) + (1.0 / t_0)
function code(x, y)
	t_0 = Float64(1.0 + Float64(1.0 / x))
	return Float64(Float64(Float64(x / y) / t_0) + Float64(1.0 / t_0))
end
function tmp = code(x, y)
	t_0 = 1.0 + (1.0 / x);
	tmp = ((x / y) / t_0) + (1.0 / t_0);
end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(x / y), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{\frac{1}{-x} - \frac{-x}{-x}}}{-1}} \]
    11. *-inverses99.8%

      \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\frac{1}{-x} - \color{blue}{1}}{-1}} \]
    12. div-sub99.8%

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

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

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

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

      \[\leadsto \frac{\frac{x}{y} + 1}{\frac{1}{\color{blue}{x}} - \frac{1}{-1}} \]
    17. metadata-eval99.8%

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

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

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

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

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

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

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

Alternative 6: 73.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{+42} \lor \neg \left(x \leq 4.5 \cdot 10^{+95}\right):\\
\;\;\;\;\frac{x}{y}\\

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


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

    1. Initial program 66.5%

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

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

    if -2.50000000000000003e42 < x < 4.50000000000000017e95

    1. Initial program 98.7%

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

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

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

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

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

Alternative 7: 73.6% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 72.2%

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

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

    if -1 < x < 3.60000000000000009e-5

    1. Initial program 99.9%

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

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

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

Alternative 8: 99.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\color{blue}{\frac{1}{-x} - \frac{-x}{-x}}}{-1}} \]
    11. *-inverses99.8%

      \[\leadsto \frac{\frac{x}{y} + 1}{\frac{\frac{1}{-x} - \color{blue}{1}}{-1}} \]
    12. div-sub99.8%

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

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

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

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

      \[\leadsto \frac{\frac{x}{y} + 1}{\frac{1}{\color{blue}{x}} - \frac{1}{-1}} \]
    17. metadata-eval99.8%

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

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

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

Alternative 9: 38.9% accurate, 11.0× speedup?

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

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

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification39.3%

    \[\leadsto x \]
  5. Add Preprocessing

Developer target: 99.8% accurate, 0.8× speedup?

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

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

Reproduce

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