Linear.Projection:perspective from linear-1.19.1.3, B

Percentage Accurate: 77.8% → 99.0%
Time: 8.9s
Alternatives: 8
Speedup: 0.7×

Specification

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

\\
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\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 8 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: 77.8% accurate, 1.0× speedup?

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

\\
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\end{array}

Alternative 1: 99.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ t_1 := y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{if}\;t\_0 \leq -0.04:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-303}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;\frac{y + y}{1 - \frac{y}{x}}\\ \mathbf{elif}\;t\_0 \leq 0.5:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (* (* x 2.0) y) (- x y))) (t_1 (* y (/ (* x 2.0) (- x y)))))
   (if (<= t_0 -0.04)
     t_1
     (if (<= t_0 -1e-303)
       t_0
       (if (<= t_0 0.0)
         (/ (+ y y) (- 1.0 (/ y x)))
         (if (<= t_0 0.5) t_0 t_1))))))
double code(double x, double y) {
	double t_0 = ((x * 2.0) * y) / (x - y);
	double t_1 = y * ((x * 2.0) / (x - y));
	double tmp;
	if (t_0 <= -0.04) {
		tmp = t_1;
	} else if (t_0 <= -1e-303) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = (y + y) / (1.0 - (y / x));
	} else if (t_0 <= 0.5) {
		tmp = t_0;
	} else {
		tmp = 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 * 2.0d0) * y) / (x - y)
    t_1 = y * ((x * 2.0d0) / (x - y))
    if (t_0 <= (-0.04d0)) then
        tmp = t_1
    else if (t_0 <= (-1d-303)) then
        tmp = t_0
    else if (t_0 <= 0.0d0) then
        tmp = (y + y) / (1.0d0 - (y / x))
    else if (t_0 <= 0.5d0) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = ((x * 2.0) * y) / (x - y);
	double t_1 = y * ((x * 2.0) / (x - y));
	double tmp;
	if (t_0 <= -0.04) {
		tmp = t_1;
	} else if (t_0 <= -1e-303) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = (y + y) / (1.0 - (y / x));
	} else if (t_0 <= 0.5) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = ((x * 2.0) * y) / (x - y)
	t_1 = y * ((x * 2.0) / (x - y))
	tmp = 0
	if t_0 <= -0.04:
		tmp = t_1
	elif t_0 <= -1e-303:
		tmp = t_0
	elif t_0 <= 0.0:
		tmp = (y + y) / (1.0 - (y / x))
	elif t_0 <= 0.5:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y))
	t_1 = Float64(y * Float64(Float64(x * 2.0) / Float64(x - y)))
	tmp = 0.0
	if (t_0 <= -0.04)
		tmp = t_1;
	elseif (t_0 <= -1e-303)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = Float64(Float64(y + y) / Float64(1.0 - Float64(y / x)));
	elseif (t_0 <= 0.5)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = ((x * 2.0) * y) / (x - y);
	t_1 = y * ((x * 2.0) / (x - y));
	tmp = 0.0;
	if (t_0 <= -0.04)
		tmp = t_1;
	elseif (t_0 <= -1e-303)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = (y + y) / (1.0 - (y / x));
	elseif (t_0 <= 0.5)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(N[(x * 2.0), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.04], t$95$1, If[LessEqual[t$95$0, -1e-303], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(y + y), $MachinePrecision] / N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.5], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\
t_1 := y \cdot \frac{x \cdot 2}{x - y}\\
\mathbf{if}\;t\_0 \leq -0.04:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-303}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{y + y}{1 - \frac{y}{x}}\\

\mathbf{elif}\;t\_0 \leq 0.5:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -0.0400000000000000008 or 0.5 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y))

    1. Initial program 61.9%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
      4. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      7. lower-/.f6499.9

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
    4. Applied rewrites99.9%

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

    if -0.0400000000000000008 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -9.99999999999999931e-304 or -0.0 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 0.5

    1. Initial program 99.0%

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

    if -9.99999999999999931e-304 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -0.0

    1. Initial program 12.6%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
      4. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      7. lower-/.f6499.9

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
    4. Applied rewrites99.9%

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
    5. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \frac{x \cdot 2}{\color{blue}{x - y}} \cdot y \]
      2. flip--N/A

        \[\leadsto \frac{x \cdot 2}{\color{blue}{\frac{x \cdot x - y \cdot y}{x + y}}} \cdot y \]
      3. div-invN/A

        \[\leadsto \frac{x \cdot 2}{\color{blue}{\left(x \cdot x - y \cdot y\right) \cdot \frac{1}{x + y}}} \cdot y \]
      4. difference-of-squaresN/A

        \[\leadsto \frac{x \cdot 2}{\color{blue}{\left(\left(x + y\right) \cdot \left(x - y\right)\right)} \cdot \frac{1}{x + y}} \cdot y \]
      5. lift--.f64N/A

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

        \[\leadsto \frac{x \cdot 2}{\color{blue}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)}} \cdot y \]
      7. lower-*.f64N/A

        \[\leadsto \frac{x \cdot 2}{\color{blue}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)}} \cdot y \]
      8. lower-+.f64N/A

        \[\leadsto \frac{x \cdot 2}{\color{blue}{\left(x + y\right)} \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)} \cdot y \]
      9. lower-*.f64N/A

        \[\leadsto \frac{x \cdot 2}{\left(x + y\right) \cdot \color{blue}{\left(\left(x - y\right) \cdot \frac{1}{x + y}\right)}} \cdot y \]
      10. lower-/.f64N/A

        \[\leadsto \frac{x \cdot 2}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \color{blue}{\frac{1}{x + y}}\right)} \cdot y \]
      11. lower-+.f6499.7

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

      \[\leadsto \frac{x \cdot 2}{\color{blue}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)}} \cdot y \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)} \cdot y} \]
      2. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)}} \]
      4. lift-*.f64N/A

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

        \[\leadsto \frac{\color{blue}{x \cdot \left(2 \cdot y\right)}}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{x \cdot \color{blue}{\left(2 \cdot y\right)}}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)} \]
      7. *-commutativeN/A

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

        \[\leadsto \color{blue}{\left(2 \cdot y\right) \cdot \frac{x}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)}} \]
      9. lift-*.f64N/A

        \[\leadsto \left(2 \cdot y\right) \cdot \frac{x}{\color{blue}{\left(x + y\right) \cdot \left(\left(x - y\right) \cdot \frac{1}{x + y}\right)}} \]
      10. lift-*.f64N/A

        \[\leadsto \left(2 \cdot y\right) \cdot \frac{x}{\left(x + y\right) \cdot \color{blue}{\left(\left(x - y\right) \cdot \frac{1}{x + y}\right)}} \]
      11. *-commutativeN/A

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

        \[\leadsto \left(2 \cdot y\right) \cdot \frac{x}{\color{blue}{\left(\left(x + y\right) \cdot \frac{1}{x + y}\right) \cdot \left(x - y\right)}} \]
      13. lift-/.f64N/A

        \[\leadsto \left(2 \cdot y\right) \cdot \frac{x}{\left(\left(x + y\right) \cdot \color{blue}{\frac{1}{x + y}}\right) \cdot \left(x - y\right)} \]
      14. rgt-mult-inverseN/A

        \[\leadsto \left(2 \cdot y\right) \cdot \frac{x}{\color{blue}{1} \cdot \left(x - y\right)} \]
      15. *-lft-identityN/A

        \[\leadsto \left(2 \cdot y\right) \cdot \frac{x}{\color{blue}{x - y}} \]
      16. clear-numN/A

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

      \[\leadsto \color{blue}{\frac{y \cdot 2}{1 - \frac{y}{x}}} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{y \cdot 2}}{1 - \frac{y}{x}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{2 \cdot y}}{1 - \frac{y}{x}} \]
      3. count-2N/A

        \[\leadsto \frac{\color{blue}{y + y}}{1 - \frac{y}{x}} \]
      4. lift-+.f6499.9

        \[\leadsto \frac{\color{blue}{y + y}}{1 - \frac{y}{x}} \]
    10. Applied rewrites99.9%

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

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

Alternative 2: 99.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ t_1 := y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{if}\;t\_0 \leq -0.04:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-303}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0.5:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (* (* x 2.0) y) (- x y))) (t_1 (* y (/ (* x 2.0) (- x y)))))
   (if (<= t_0 -0.04)
     t_1
     (if (<= t_0 -1e-303)
       t_0
       (if (<= t_0 0.0) t_1 (if (<= t_0 0.5) t_0 t_1))))))
double code(double x, double y) {
	double t_0 = ((x * 2.0) * y) / (x - y);
	double t_1 = y * ((x * 2.0) / (x - y));
	double tmp;
	if (t_0 <= -0.04) {
		tmp = t_1;
	} else if (t_0 <= -1e-303) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = t_1;
	} else if (t_0 <= 0.5) {
		tmp = t_0;
	} else {
		tmp = 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 * 2.0d0) * y) / (x - y)
    t_1 = y * ((x * 2.0d0) / (x - y))
    if (t_0 <= (-0.04d0)) then
        tmp = t_1
    else if (t_0 <= (-1d-303)) then
        tmp = t_0
    else if (t_0 <= 0.0d0) then
        tmp = t_1
    else if (t_0 <= 0.5d0) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = ((x * 2.0) * y) / (x - y);
	double t_1 = y * ((x * 2.0) / (x - y));
	double tmp;
	if (t_0 <= -0.04) {
		tmp = t_1;
	} else if (t_0 <= -1e-303) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = t_1;
	} else if (t_0 <= 0.5) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y):
	t_0 = ((x * 2.0) * y) / (x - y)
	t_1 = y * ((x * 2.0) / (x - y))
	tmp = 0
	if t_0 <= -0.04:
		tmp = t_1
	elif t_0 <= -1e-303:
		tmp = t_0
	elif t_0 <= 0.0:
		tmp = t_1
	elif t_0 <= 0.5:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y)
	t_0 = Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y))
	t_1 = Float64(y * Float64(Float64(x * 2.0) / Float64(x - y)))
	tmp = 0.0
	if (t_0 <= -0.04)
		tmp = t_1;
	elseif (t_0 <= -1e-303)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = t_1;
	elseif (t_0 <= 0.5)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = ((x * 2.0) * y) / (x - y);
	t_1 = y * ((x * 2.0) / (x - y));
	tmp = 0.0;
	if (t_0 <= -0.04)
		tmp = t_1;
	elseif (t_0 <= -1e-303)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = t_1;
	elseif (t_0 <= 0.5)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(N[(x * 2.0), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.04], t$95$1, If[LessEqual[t$95$0, -1e-303], t$95$0, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 0.5], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\left(x \cdot 2\right) \cdot y}{x - y}\\
t_1 := y \cdot \frac{x \cdot 2}{x - y}\\
\mathbf{if}\;t\_0 \leq -0.04:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq -1 \cdot 10^{-303}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 0.5:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -0.0400000000000000008 or -9.99999999999999931e-304 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -0.0 or 0.5 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y))

    1. Initial program 46.7%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
      4. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      7. lower-/.f6499.9

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
    4. Applied rewrites99.9%

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

    if -0.0400000000000000008 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -9.99999999999999931e-304 or -0.0 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 0.5

    1. Initial program 99.0%

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

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

Alternative 3: 94.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{if}\;x \leq -1.15 \cdot 10^{-174}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-186}:\\ \;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* y (/ (* x 2.0) (- x y)))))
   (if (<= x -1.15e-174)
     t_0
     (if (<= x 1.25e-186) (* -2.0 (fma x (/ x y) x)) t_0))))
double code(double x, double y) {
	double t_0 = y * ((x * 2.0) / (x - y));
	double tmp;
	if (x <= -1.15e-174) {
		tmp = t_0;
	} else if (x <= 1.25e-186) {
		tmp = -2.0 * fma(x, (x / y), x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(y * Float64(Float64(x * 2.0) / Float64(x - y)))
	tmp = 0.0
	if (x <= -1.15e-174)
		tmp = t_0;
	elseif (x <= 1.25e-186)
		tmp = Float64(-2.0 * fma(x, Float64(x / y), x));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(y * N[(N[(x * 2.0), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.15e-174], t$95$0, If[LessEqual[x, 1.25e-186], N[(-2.0 * N[(x * N[(x / y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \frac{x \cdot 2}{x - y}\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{-174}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-186}:\\
\;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\

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


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

    1. Initial program 81.0%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
      4. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      7. lower-/.f6496.4

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
    4. Applied rewrites96.4%

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

    if -1.1499999999999999e-174 < x < 1.25e-186

    1. Initial program 75.0%

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

      \[\leadsto \color{blue}{x \cdot \left(-2 \cdot \frac{x}{y} - 2\right)} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto x \cdot \color{blue}{\left(-2 \cdot \frac{x}{y} + \left(\mathsf{neg}\left(2\right)\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto x \cdot \left(-2 \cdot \frac{x}{y} + \color{blue}{-2}\right) \]
      3. distribute-lft-inN/A

        \[\leadsto \color{blue}{x \cdot \left(-2 \cdot \frac{x}{y}\right) + x \cdot -2} \]
      4. *-commutativeN/A

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x}{y}} \cdot -2 + x \cdot -2 \]
      7. unpow2N/A

        \[\leadsto \frac{\color{blue}{{x}^{2}}}{y} \cdot -2 + x \cdot -2 \]
      8. distribute-rgt-outN/A

        \[\leadsto \color{blue}{-2 \cdot \left(\frac{{x}^{2}}{y} + x\right)} \]
      9. +-commutativeN/A

        \[\leadsto -2 \cdot \color{blue}{\left(x + \frac{{x}^{2}}{y}\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \color{blue}{-2 \cdot \left(x + \frac{{x}^{2}}{y}\right)} \]
      11. +-commutativeN/A

        \[\leadsto -2 \cdot \color{blue}{\left(\frac{{x}^{2}}{y} + x\right)} \]
      12. unpow2N/A

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

        \[\leadsto -2 \cdot \left(\color{blue}{x \cdot \frac{x}{y}} + x\right) \]
      14. lower-fma.f64N/A

        \[\leadsto -2 \cdot \color{blue}{\mathsf{fma}\left(x, \frac{x}{y}, x\right)} \]
      15. lower-/.f6493.4

        \[\leadsto -2 \cdot \mathsf{fma}\left(x, \color{blue}{\frac{x}{y}}, x\right) \]
    5. Applied rewrites93.4%

      \[\leadsto \color{blue}{-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification95.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.15 \cdot 10^{-174}:\\ \;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-186}:\\ \;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x \cdot 2}{x - y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 72.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\ \;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\ \mathbf{else}:\\ \;\;\;\;y + \mathsf{fma}\left(\frac{y}{x}, y + y, y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -5.1e+56)
   (+ y y)
   (if (<= x 1.72e-121)
     (* -2.0 (fma x (/ x y) x))
     (+ y (fma (/ y x) (+ y y) y)))))
double code(double x, double y) {
	double tmp;
	if (x <= -5.1e+56) {
		tmp = y + y;
	} else if (x <= 1.72e-121) {
		tmp = -2.0 * fma(x, (x / y), x);
	} else {
		tmp = y + fma((y / x), (y + y), y);
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (x <= -5.1e+56)
		tmp = Float64(y + y);
	elseif (x <= 1.72e-121)
		tmp = Float64(-2.0 * fma(x, Float64(x / y), x));
	else
		tmp = Float64(y + fma(Float64(y / x), Float64(y + y), y));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[x, -5.1e+56], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.72e-121], N[(-2.0 * N[(x * N[(x / y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(y + N[(N[(y / x), $MachinePrecision] * N[(y + y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\
\;\;\;\;y + y\\

\mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\
\;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\

\mathbf{else}:\\
\;\;\;\;y + \mathsf{fma}\left(\frac{y}{x}, y + y, y\right)\\


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

    1. Initial program 73.6%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
      4. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      7. lower-/.f64100.0

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      2. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
      3. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right)} \cdot y}{x - y} \]
      5. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
      6. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
      7. lower-/.f64N/A

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

        \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(2 \cdot y\right)}}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
      11. lower-*.f6473.4

        \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(y \cdot 2\right)}}} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
      13. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
      14. lower-*.f6473.4

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
    6. Applied rewrites73.4%

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

      \[\leadsto \color{blue}{2 \cdot y} \]
    8. Step-by-step derivation
      1. count-2N/A

        \[\leadsto \color{blue}{y + y} \]
      2. lower-+.f6480.1

        \[\leadsto \color{blue}{y + y} \]
    9. Applied rewrites80.1%

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

    if -5.1000000000000002e56 < x < 1.72000000000000007e-121

    1. Initial program 81.3%

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

      \[\leadsto \color{blue}{x \cdot \left(-2 \cdot \frac{x}{y} - 2\right)} \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto x \cdot \color{blue}{\left(-2 \cdot \frac{x}{y} + \left(\mathsf{neg}\left(2\right)\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto x \cdot \left(-2 \cdot \frac{x}{y} + \color{blue}{-2}\right) \]
      3. distribute-lft-inN/A

        \[\leadsto \color{blue}{x \cdot \left(-2 \cdot \frac{x}{y}\right) + x \cdot -2} \]
      4. *-commutativeN/A

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x}{y}} \cdot -2 + x \cdot -2 \]
      7. unpow2N/A

        \[\leadsto \frac{\color{blue}{{x}^{2}}}{y} \cdot -2 + x \cdot -2 \]
      8. distribute-rgt-outN/A

        \[\leadsto \color{blue}{-2 \cdot \left(\frac{{x}^{2}}{y} + x\right)} \]
      9. +-commutativeN/A

        \[\leadsto -2 \cdot \color{blue}{\left(x + \frac{{x}^{2}}{y}\right)} \]
      10. lower-*.f64N/A

        \[\leadsto \color{blue}{-2 \cdot \left(x + \frac{{x}^{2}}{y}\right)} \]
      11. +-commutativeN/A

        \[\leadsto -2 \cdot \color{blue}{\left(\frac{{x}^{2}}{y} + x\right)} \]
      12. unpow2N/A

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

        \[\leadsto -2 \cdot \left(\color{blue}{x \cdot \frac{x}{y}} + x\right) \]
      14. lower-fma.f64N/A

        \[\leadsto -2 \cdot \color{blue}{\mathsf{fma}\left(x, \frac{x}{y}, x\right)} \]
      15. lower-/.f6479.9

        \[\leadsto -2 \cdot \mathsf{fma}\left(x, \color{blue}{\frac{x}{y}}, x\right) \]
    5. Applied rewrites79.9%

      \[\leadsto \color{blue}{-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)} \]

    if 1.72000000000000007e-121 < x

    1. Initial program 82.1%

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
      4. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      7. lower-/.f6499.8

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
    4. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      2. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
      3. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right)} \cdot y}{x - y} \]
      5. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
      6. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
      7. lower-/.f64N/A

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

        \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(2 \cdot y\right)}}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
      11. lower-*.f6481.8

        \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(y \cdot 2\right)}}} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
      13. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
      14. lower-*.f6481.8

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
    6. Applied rewrites81.8%

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

      \[\leadsto \color{blue}{2 \cdot y + 2 \cdot \frac{{y}^{2}}{x}} \]
    8. Step-by-step derivation
      1. distribute-lft-outN/A

        \[\leadsto \color{blue}{2 \cdot \left(y + \frac{{y}^{2}}{x}\right)} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{2 \cdot \left(y + \frac{{y}^{2}}{x}\right)} \]
      3. +-commutativeN/A

        \[\leadsto 2 \cdot \color{blue}{\left(\frac{{y}^{2}}{x} + y\right)} \]
      4. unpow2N/A

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

        \[\leadsto 2 \cdot \left(\color{blue}{y \cdot \frac{y}{x}} + y\right) \]
      6. lower-fma.f64N/A

        \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(y, \frac{y}{x}, y\right)} \]
      7. lower-/.f6476.2

        \[\leadsto 2 \cdot \mathsf{fma}\left(y, \color{blue}{\frac{y}{x}}, y\right) \]
    9. Applied rewrites76.2%

      \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)} \]
    10. Step-by-step derivation
      1. Applied rewrites76.2%

        \[\leadsto \mathsf{fma}\left(\frac{y}{x}, y + y, y\right) + \color{blue}{y} \]
    11. Recombined 3 regimes into one program.
    12. Final simplification78.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\ \;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\ \mathbf{else}:\\ \;\;\;\;y + \mathsf{fma}\left(\frac{y}{x}, y + y, y\right)\\ \end{array} \]
    13. Add Preprocessing

    Alternative 5: 72.9% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\ \;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (if (<= x -5.1e+56)
       (+ y y)
       (if (<= x 1.72e-121) (* -2.0 (fma x (/ x y) x)) (* 2.0 (fma y (/ y x) y)))))
    double code(double x, double y) {
    	double tmp;
    	if (x <= -5.1e+56) {
    		tmp = y + y;
    	} else if (x <= 1.72e-121) {
    		tmp = -2.0 * fma(x, (x / y), x);
    	} else {
    		tmp = 2.0 * fma(y, (y / x), y);
    	}
    	return tmp;
    }
    
    function code(x, y)
    	tmp = 0.0
    	if (x <= -5.1e+56)
    		tmp = Float64(y + y);
    	elseif (x <= 1.72e-121)
    		tmp = Float64(-2.0 * fma(x, Float64(x / y), x));
    	else
    		tmp = Float64(2.0 * fma(y, Float64(y / x), y));
    	end
    	return tmp
    end
    
    code[x_, y_] := If[LessEqual[x, -5.1e+56], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.72e-121], N[(-2.0 * N[(x * N[(x / y), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * N[(y / x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\
    \;\;\;\;y + y\\
    
    \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\
    \;\;\;\;-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if x < -5.1000000000000002e56

      1. Initial program 73.6%

        \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
        3. *-commutativeN/A

          \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
        4. associate-/l*N/A

          \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
        5. *-commutativeN/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        6. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        7. lower-/.f64100.0

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
      4. Applied rewrites100.0%

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        2. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
        3. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        4. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right)} \cdot y}{x - y} \]
        5. clear-numN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        6. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        7. lower-/.f64N/A

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

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(2 \cdot y\right)}}} \]
        9. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        11. lower-*.f6473.4

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(y \cdot 2\right)}}} \]
        12. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        13. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
        14. lower-*.f6473.4

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
      6. Applied rewrites73.4%

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

        \[\leadsto \color{blue}{2 \cdot y} \]
      8. Step-by-step derivation
        1. count-2N/A

          \[\leadsto \color{blue}{y + y} \]
        2. lower-+.f6480.1

          \[\leadsto \color{blue}{y + y} \]
      9. Applied rewrites80.1%

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

      if -5.1000000000000002e56 < x < 1.72000000000000007e-121

      1. Initial program 81.3%

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

        \[\leadsto \color{blue}{x \cdot \left(-2 \cdot \frac{x}{y} - 2\right)} \]
      4. Step-by-step derivation
        1. sub-negN/A

          \[\leadsto x \cdot \color{blue}{\left(-2 \cdot \frac{x}{y} + \left(\mathsf{neg}\left(2\right)\right)\right)} \]
        2. metadata-evalN/A

          \[\leadsto x \cdot \left(-2 \cdot \frac{x}{y} + \color{blue}{-2}\right) \]
        3. distribute-lft-inN/A

          \[\leadsto \color{blue}{x \cdot \left(-2 \cdot \frac{x}{y}\right) + x \cdot -2} \]
        4. *-commutativeN/A

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

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

          \[\leadsto \color{blue}{\frac{x \cdot x}{y}} \cdot -2 + x \cdot -2 \]
        7. unpow2N/A

          \[\leadsto \frac{\color{blue}{{x}^{2}}}{y} \cdot -2 + x \cdot -2 \]
        8. distribute-rgt-outN/A

          \[\leadsto \color{blue}{-2 \cdot \left(\frac{{x}^{2}}{y} + x\right)} \]
        9. +-commutativeN/A

          \[\leadsto -2 \cdot \color{blue}{\left(x + \frac{{x}^{2}}{y}\right)} \]
        10. lower-*.f64N/A

          \[\leadsto \color{blue}{-2 \cdot \left(x + \frac{{x}^{2}}{y}\right)} \]
        11. +-commutativeN/A

          \[\leadsto -2 \cdot \color{blue}{\left(\frac{{x}^{2}}{y} + x\right)} \]
        12. unpow2N/A

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

          \[\leadsto -2 \cdot \left(\color{blue}{x \cdot \frac{x}{y}} + x\right) \]
        14. lower-fma.f64N/A

          \[\leadsto -2 \cdot \color{blue}{\mathsf{fma}\left(x, \frac{x}{y}, x\right)} \]
        15. lower-/.f6479.9

          \[\leadsto -2 \cdot \mathsf{fma}\left(x, \color{blue}{\frac{x}{y}}, x\right) \]
      5. Applied rewrites79.9%

        \[\leadsto \color{blue}{-2 \cdot \mathsf{fma}\left(x, \frac{x}{y}, x\right)} \]

      if 1.72000000000000007e-121 < x

      1. Initial program 82.1%

        \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
        3. *-commutativeN/A

          \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
        4. associate-/l*N/A

          \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
        5. *-commutativeN/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        6. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        7. lower-/.f6499.8

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
      4. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        2. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
        3. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        4. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right)} \cdot y}{x - y} \]
        5. clear-numN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        6. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        7. lower-/.f64N/A

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

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(2 \cdot y\right)}}} \]
        9. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        11. lower-*.f6481.8

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(y \cdot 2\right)}}} \]
        12. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        13. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
        14. lower-*.f6481.8

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
      6. Applied rewrites81.8%

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

        \[\leadsto \color{blue}{2 \cdot y + 2 \cdot \frac{{y}^{2}}{x}} \]
      8. Step-by-step derivation
        1. distribute-lft-outN/A

          \[\leadsto \color{blue}{2 \cdot \left(y + \frac{{y}^{2}}{x}\right)} \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{2 \cdot \left(y + \frac{{y}^{2}}{x}\right)} \]
        3. +-commutativeN/A

          \[\leadsto 2 \cdot \color{blue}{\left(\frac{{y}^{2}}{x} + y\right)} \]
        4. unpow2N/A

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

          \[\leadsto 2 \cdot \left(\color{blue}{y \cdot \frac{y}{x}} + y\right) \]
        6. lower-fma.f64N/A

          \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(y, \frac{y}{x}, y\right)} \]
        7. lower-/.f6476.2

          \[\leadsto 2 \cdot \mathsf{fma}\left(y, \color{blue}{\frac{y}{x}}, y\right) \]
      9. Applied rewrites76.2%

        \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)} \]
    3. Recombined 3 regimes into one program.
    4. Add Preprocessing

    Alternative 6: 72.9% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\ \;\;\;\;x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (if (<= x -5.1e+56)
       (+ y y)
       (if (<= x 1.72e-121) (* x -2.0) (* 2.0 (fma y (/ y x) y)))))
    double code(double x, double y) {
    	double tmp;
    	if (x <= -5.1e+56) {
    		tmp = y + y;
    	} else if (x <= 1.72e-121) {
    		tmp = x * -2.0;
    	} else {
    		tmp = 2.0 * fma(y, (y / x), y);
    	}
    	return tmp;
    }
    
    function code(x, y)
    	tmp = 0.0
    	if (x <= -5.1e+56)
    		tmp = Float64(y + y);
    	elseif (x <= 1.72e-121)
    		tmp = Float64(x * -2.0);
    	else
    		tmp = Float64(2.0 * fma(y, Float64(y / x), y));
    	end
    	return tmp
    end
    
    code[x_, y_] := If[LessEqual[x, -5.1e+56], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.72e-121], N[(x * -2.0), $MachinePrecision], N[(2.0 * N[(y * N[(y / x), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\
    \;\;\;\;y + y\\
    
    \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\
    \;\;\;\;x \cdot -2\\
    
    \mathbf{else}:\\
    \;\;\;\;2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if x < -5.1000000000000002e56

      1. Initial program 73.6%

        \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
        3. *-commutativeN/A

          \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
        4. associate-/l*N/A

          \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
        5. *-commutativeN/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        6. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        7. lower-/.f64100.0

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
      4. Applied rewrites100.0%

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        2. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
        3. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        4. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right)} \cdot y}{x - y} \]
        5. clear-numN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        6. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        7. lower-/.f64N/A

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

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(2 \cdot y\right)}}} \]
        9. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        11. lower-*.f6473.4

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(y \cdot 2\right)}}} \]
        12. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        13. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
        14. lower-*.f6473.4

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
      6. Applied rewrites73.4%

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

        \[\leadsto \color{blue}{2 \cdot y} \]
      8. Step-by-step derivation
        1. count-2N/A

          \[\leadsto \color{blue}{y + y} \]
        2. lower-+.f6480.1

          \[\leadsto \color{blue}{y + y} \]
      9. Applied rewrites80.1%

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

      if -5.1000000000000002e56 < x < 1.72000000000000007e-121

      1. Initial program 81.3%

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

        \[\leadsto \color{blue}{-2 \cdot x} \]
      4. Step-by-step derivation
        1. lower-*.f6479.7

          \[\leadsto \color{blue}{-2 \cdot x} \]
      5. Applied rewrites79.7%

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

      if 1.72000000000000007e-121 < x

      1. Initial program 82.1%

        \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
        3. *-commutativeN/A

          \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
        4. associate-/l*N/A

          \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
        5. *-commutativeN/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        6. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        7. lower-/.f6499.8

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
      4. Applied rewrites99.8%

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        2. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
        3. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        4. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right)} \cdot y}{x - y} \]
        5. clear-numN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        6. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        7. lower-/.f64N/A

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

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(2 \cdot y\right)}}} \]
        9. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        11. lower-*.f6481.8

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(y \cdot 2\right)}}} \]
        12. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        13. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
        14. lower-*.f6481.8

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
      6. Applied rewrites81.8%

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

        \[\leadsto \color{blue}{2 \cdot y + 2 \cdot \frac{{y}^{2}}{x}} \]
      8. Step-by-step derivation
        1. distribute-lft-outN/A

          \[\leadsto \color{blue}{2 \cdot \left(y + \frac{{y}^{2}}{x}\right)} \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{2 \cdot \left(y + \frac{{y}^{2}}{x}\right)} \]
        3. +-commutativeN/A

          \[\leadsto 2 \cdot \color{blue}{\left(\frac{{y}^{2}}{x} + y\right)} \]
        4. unpow2N/A

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

          \[\leadsto 2 \cdot \left(\color{blue}{y \cdot \frac{y}{x}} + y\right) \]
        6. lower-fma.f64N/A

          \[\leadsto 2 \cdot \color{blue}{\mathsf{fma}\left(y, \frac{y}{x}, y\right)} \]
        7. lower-/.f6476.2

          \[\leadsto 2 \cdot \mathsf{fma}\left(y, \color{blue}{\frac{y}{x}}, y\right) \]
      9. Applied rewrites76.2%

        \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)} \]
    3. Recombined 3 regimes into one program.
    4. Final simplification78.7%

      \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\ \;\;\;\;x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 7: 73.0% accurate, 1.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\ \;\;\;\;x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;y + y\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (if (<= x -5.1e+56) (+ y y) (if (<= x 1.72e-121) (* x -2.0) (+ y y))))
    double code(double x, double y) {
    	double tmp;
    	if (x <= -5.1e+56) {
    		tmp = y + y;
    	} else if (x <= 1.72e-121) {
    		tmp = x * -2.0;
    	} else {
    		tmp = y + y;
    	}
    	return tmp;
    }
    
    real(8) function code(x, y)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8) :: tmp
        if (x <= (-5.1d+56)) then
            tmp = y + y
        else if (x <= 1.72d-121) then
            tmp = x * (-2.0d0)
        else
            tmp = y + y
        end if
        code = tmp
    end function
    
    public static double code(double x, double y) {
    	double tmp;
    	if (x <= -5.1e+56) {
    		tmp = y + y;
    	} else if (x <= 1.72e-121) {
    		tmp = x * -2.0;
    	} else {
    		tmp = y + y;
    	}
    	return tmp;
    }
    
    def code(x, y):
    	tmp = 0
    	if x <= -5.1e+56:
    		tmp = y + y
    	elif x <= 1.72e-121:
    		tmp = x * -2.0
    	else:
    		tmp = y + y
    	return tmp
    
    function code(x, y)
    	tmp = 0.0
    	if (x <= -5.1e+56)
    		tmp = Float64(y + y);
    	elseif (x <= 1.72e-121)
    		tmp = Float64(x * -2.0);
    	else
    		tmp = Float64(y + y);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y)
    	tmp = 0.0;
    	if (x <= -5.1e+56)
    		tmp = y + y;
    	elseif (x <= 1.72e-121)
    		tmp = x * -2.0;
    	else
    		tmp = y + y;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_] := If[LessEqual[x, -5.1e+56], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.72e-121], N[(x * -2.0), $MachinePrecision], N[(y + y), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\
    \;\;\;\;y + y\\
    
    \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\
    \;\;\;\;x \cdot -2\\
    
    \mathbf{else}:\\
    \;\;\;\;y + y\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -5.1000000000000002e56 or 1.72000000000000007e-121 < x

      1. Initial program 78.5%

        \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
        3. *-commutativeN/A

          \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
        4. associate-/l*N/A

          \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
        5. *-commutativeN/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        6. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        7. lower-/.f6499.9

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
      4. Applied rewrites99.9%

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
        2. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
        3. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
        4. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right)} \cdot y}{x - y} \]
        5. clear-numN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        6. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
        7. lower-/.f64N/A

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

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(2 \cdot y\right)}}} \]
        9. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        10. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        11. lower-*.f6478.3

          \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(y \cdot 2\right)}}} \]
        12. lift-*.f64N/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
        13. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
        14. lower-*.f6478.3

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

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

        \[\leadsto \color{blue}{2 \cdot y} \]
      8. Step-by-step derivation
        1. count-2N/A

          \[\leadsto \color{blue}{y + y} \]
        2. lower-+.f6477.8

          \[\leadsto \color{blue}{y + y} \]
      9. Applied rewrites77.8%

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

      if -5.1000000000000002e56 < x < 1.72000000000000007e-121

      1. Initial program 81.3%

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

        \[\leadsto \color{blue}{-2 \cdot x} \]
      4. Step-by-step derivation
        1. lower-*.f6479.7

          \[\leadsto \color{blue}{-2 \cdot x} \]
      5. Applied rewrites79.7%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.1 \cdot 10^{+56}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-121}:\\ \;\;\;\;x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;y + y\\ \end{array} \]
    5. Add Preprocessing

    Alternative 8: 50.3% accurate, 6.3× speedup?

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

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right) \cdot y}}{x - y} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2\right)}}{x - y} \]
      4. associate-/l*N/A

        \[\leadsto \color{blue}{y \cdot \frac{x \cdot 2}{x - y}} \]
      5. *-commutativeN/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      6. lower-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      7. lower-/.f6488.7

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
    4. Applied rewrites88.7%

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y} \]
      2. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y}} \cdot y \]
      3. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot 2\right) \cdot y}{x - y}} \]
      4. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot 2\right)} \cdot y}{x - y} \]
      5. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
      6. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{\left(x \cdot 2\right) \cdot y}}} \]
      7. lower-/.f64N/A

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

        \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(2 \cdot y\right)}}} \]
      9. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
      10. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
      11. lower-*.f6479.6

        \[\leadsto \frac{1}{\frac{x - y}{\color{blue}{x \cdot \left(y \cdot 2\right)}}} \]
      12. lift-*.f64N/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(y \cdot 2\right)}}} \]
      13. *-commutativeN/A

        \[\leadsto \frac{1}{\frac{x - y}{x \cdot \color{blue}{\left(2 \cdot y\right)}}} \]
      14. lower-*.f6479.6

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

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

      \[\leadsto \color{blue}{2 \cdot y} \]
    8. Step-by-step derivation
      1. count-2N/A

        \[\leadsto \color{blue}{y + y} \]
      2. lower-+.f6452.2

        \[\leadsto \color{blue}{y + y} \]
    9. Applied rewrites52.2%

      \[\leadsto \color{blue}{y + y} \]
    10. Add Preprocessing

    Developer Target 1: 99.5% accurate, 0.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{if}\;x < -1.7210442634149447 \cdot 10^{+81}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x < 83645045635564430:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (let* ((t_0 (* (/ (* 2.0 x) (- x y)) y)))
       (if (< x -1.7210442634149447e+81)
         t_0
         (if (< x 83645045635564430.0) (/ (* x 2.0) (/ (- x y) y)) t_0))))
    double code(double x, double y) {
    	double t_0 = ((2.0 * x) / (x - y)) * y;
    	double tmp;
    	if (x < -1.7210442634149447e+81) {
    		tmp = t_0;
    	} else if (x < 83645045635564430.0) {
    		tmp = (x * 2.0) / ((x - y) / y);
    	} 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 = ((2.0d0 * x) / (x - y)) * y
        if (x < (-1.7210442634149447d+81)) then
            tmp = t_0
        else if (x < 83645045635564430.0d0) then
            tmp = (x * 2.0d0) / ((x - y) / y)
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y) {
    	double t_0 = ((2.0 * x) / (x - y)) * y;
    	double tmp;
    	if (x < -1.7210442634149447e+81) {
    		tmp = t_0;
    	} else if (x < 83645045635564430.0) {
    		tmp = (x * 2.0) / ((x - y) / y);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y):
    	t_0 = ((2.0 * x) / (x - y)) * y
    	tmp = 0
    	if x < -1.7210442634149447e+81:
    		tmp = t_0
    	elif x < 83645045635564430.0:
    		tmp = (x * 2.0) / ((x - y) / y)
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y)
    	t_0 = Float64(Float64(Float64(2.0 * x) / Float64(x - y)) * y)
    	tmp = 0.0
    	if (x < -1.7210442634149447e+81)
    		tmp = t_0;
    	elseif (x < 83645045635564430.0)
    		tmp = Float64(Float64(x * 2.0) / Float64(Float64(x - y) / y));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y)
    	t_0 = ((2.0 * x) / (x - y)) * y;
    	tmp = 0.0;
    	if (x < -1.7210442634149447e+81)
    		tmp = t_0;
    	elseif (x < 83645045635564430.0)
    		tmp = (x * 2.0) / ((x - y) / y);
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_] := Block[{t$95$0 = N[(N[(N[(2.0 * x), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[Less[x, -1.7210442634149447e+81], t$95$0, If[Less[x, 83645045635564430.0], N[(N[(x * 2.0), $MachinePrecision] / N[(N[(x - y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{2 \cdot x}{x - y} \cdot y\\
    \mathbf{if}\;x < -1.7210442634149447 \cdot 10^{+81}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;x < 83645045635564430:\\
    \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2024238 
    (FPCore (x y)
      :name "Linear.Projection:perspective from linear-1.19.1.3, B"
      :precision binary64
    
      :alt
      (! :herbie-platform default (if (< x -1721044263414944700000000000000000000000000000000000000000000000000000000000000000) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564430) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y))))
    
      (/ (* (* x 2.0) y) (- x y)))