Linear.Projection:perspective from linear-1.19.1.3, B

Percentage Accurate: 76.8% → 99.8%
Time: 7.7s
Alternatives: 7
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 7 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: 76.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.8% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.2000000000000005e-28 or 9.99999999999999943e-30 < y

    1. Initial program 79.2%

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

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

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

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

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

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

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

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

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

    if -8.2000000000000005e-28 < y < 9.99999999999999943e-30

    1. Initial program 80.2%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{x \cdot 2}}{x - y} \cdot y \]
      7. --lowering--.f6499.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{-28}:\\ \;\;\;\;x \cdot \frac{y \cdot 2}{x - y}\\ \mathbf{elif}\;y \leq 10^{-29}:\\ \;\;\;\;y \cdot \frac{2 \cdot x}{x - y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y \cdot 2}{x - y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 84.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y \cdot x\right) \cdot \frac{2}{x - y}\\ t_1 := \frac{y \cdot \left(2 \cdot x\right)}{x - y}\\ t_2 := y \cdot \mathsf{fma}\left(y, \frac{2}{x}, 2\right)\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-264}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-296}:\\ \;\;\;\;y \cdot 2\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+104}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (* y x) (/ 2.0 (- x y))))
        (t_1 (/ (* y (* 2.0 x)) (- x y)))
        (t_2 (* y (fma y (/ 2.0 x) 2.0))))
   (if (<= t_1 (- INFINITY))
     t_2
     (if (<= t_1 -5e-264)
       t_0
       (if (<= t_1 2e-296) (* y 2.0) (if (<= t_1 2e+104) t_0 t_2))))))
double code(double x, double y) {
	double t_0 = (y * x) * (2.0 / (x - y));
	double t_1 = (y * (2.0 * x)) / (x - y);
	double t_2 = y * fma(y, (2.0 / x), 2.0);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = t_2;
	} else if (t_1 <= -5e-264) {
		tmp = t_0;
	} else if (t_1 <= 2e-296) {
		tmp = y * 2.0;
	} else if (t_1 <= 2e+104) {
		tmp = t_0;
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(x, y)
	t_0 = Float64(Float64(y * x) * Float64(2.0 / Float64(x - y)))
	t_1 = Float64(Float64(y * Float64(2.0 * x)) / Float64(x - y))
	t_2 = Float64(y * fma(y, Float64(2.0 / x), 2.0))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = t_2;
	elseif (t_1 <= -5e-264)
		tmp = t_0;
	elseif (t_1 <= 2e-296)
		tmp = Float64(y * 2.0);
	elseif (t_1 <= 2e+104)
		tmp = t_0;
	else
		tmp = t_2;
	end
	return tmp
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * x), $MachinePrecision] * N[(2.0 / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y * N[(2.0 * x), $MachinePrecision]), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(y * N[(2.0 / x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, -5e-264], t$95$0, If[LessEqual[t$95$1, 2e-296], N[(y * 2.0), $MachinePrecision], If[LessEqual[t$95$1, 2e+104], t$95$0, t$95$2]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(y \cdot x\right) \cdot \frac{2}{x - y}\\
t_1 := \frac{y \cdot \left(2 \cdot x\right)}{x - y}\\
t_2 := y \cdot \mathsf{fma}\left(y, \frac{2}{x}, 2\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-264}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-296}:\\
\;\;\;\;y \cdot 2\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\

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


\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)) < -inf.0 or 2e104 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y))

    1. Initial program 7.7%

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

      \[\leadsto \color{blue}{2 \cdot y + 2 \cdot \frac{{y}^{2}}{x}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \mathsf{fma}\left(y, \color{blue}{\frac{2}{x}}, 2\right) \]
    5. Simplified65.1%

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

    if -inf.0 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < -5.0000000000000001e-264 or 2e-296 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 2e104

    1. Initial program 99.2%

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

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

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

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

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

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

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

        \[\leadsto \left(x \cdot y\right) \cdot \color{blue}{\frac{2}{x - y}} \]
      8. --lowering--.f6498.9

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

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

    if -5.0000000000000001e-264 < (/.f64 (*.f64 (*.f64 x #s(literal 2 binary64)) y) (-.f64 x y)) < 2e-296

    1. Initial program 28.2%

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

      \[\leadsto \color{blue}{2 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot 2} \]
      2. *-lowering-*.f6470.0

        \[\leadsto \color{blue}{y \cdot 2} \]
    5. Simplified70.0%

      \[\leadsto \color{blue}{y \cdot 2} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.4%

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

Alternative 3: 93.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_0 := y \cdot \mathsf{fma}\left(y, \frac{2}{x}, 2\right)\\
\mathbf{if}\;x \leq -9.5 \cdot 10^{+167}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 2.8 \cdot 10^{+128}:\\
\;\;\;\;x \cdot \frac{y \cdot 2}{x - y}\\

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


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

    1. Initial program 69.1%

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

      \[\leadsto \color{blue}{2 \cdot y + 2 \cdot \frac{{y}^{2}}{x}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.5000000000000006e167 < x < 2.79999999999999983e128

    1. Initial program 83.9%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{2 \cdot y}}{x - y} \cdot x \]
      7. --lowering--.f6497.4

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

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

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

Alternative 4: 74.4% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.15 \cdot 10^{+75}:\\
\;\;\;\;y \cdot \mathsf{fma}\left(y, \frac{2}{x}, 2\right)\\

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

\mathbf{else}:\\
\;\;\;\;y \cdot 2\\


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

    1. Initial program 65.8%

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

      \[\leadsto \color{blue}{2 \cdot y + 2 \cdot \frac{{y}^{2}}{x}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \mathsf{fma}\left(y, \color{blue}{\frac{2}{x}}, 2\right) \]
    5. Simplified87.7%

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

    if -2.1500000000000001e75 < x < 1.0499999999999999e-15

    1. Initial program 82.1%

      \[\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. *-lowering-*.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. accelerator-lowering-fma.f64N/A

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

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

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

    if 1.0499999999999999e-15 < x

    1. Initial program 85.3%

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

      \[\leadsto \color{blue}{2 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot 2} \]
      2. *-lowering-*.f6475.6

        \[\leadsto \color{blue}{y \cdot 2} \]
    5. Simplified75.6%

      \[\leadsto \color{blue}{y \cdot 2} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 75.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.32 \cdot 10^{+34}:\\
\;\;\;\;y \cdot 2\\

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

\mathbf{else}:\\
\;\;\;\;y \cdot 2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.31999999999999991e34 or 4.39999999999999971e-15 < x

    1. Initial program 77.3%

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

      \[\leadsto \color{blue}{2 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot 2} \]
      2. *-lowering-*.f6478.3

        \[\leadsto \color{blue}{y \cdot 2} \]
    5. Simplified78.3%

      \[\leadsto \color{blue}{y \cdot 2} \]

    if -1.31999999999999991e34 < x < 4.39999999999999971e-15

    1. Initial program 82.2%

      \[\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. *-lowering-*.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. accelerator-lowering-fma.f64N/A

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

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

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

Alternative 6: 75.2% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.06 \cdot 10^{+52}:\\
\;\;\;\;y \cdot 2\\

\mathbf{elif}\;x \leq 1.25 \cdot 10^{+31}:\\
\;\;\;\;x \cdot -2\\

\mathbf{else}:\\
\;\;\;\;y \cdot 2\\


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

    1. Initial program 74.1%

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

      \[\leadsto \color{blue}{2 \cdot y} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot 2} \]
      2. *-lowering-*.f6482.6

        \[\leadsto \color{blue}{y \cdot 2} \]
    5. Simplified82.6%

      \[\leadsto \color{blue}{y \cdot 2} \]

    if -1.0599999999999999e52 < x < 1.25000000000000007e31

    1. Initial program 84.4%

      \[\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. *-lowering-*.f6472.3

        \[\leadsto \color{blue}{-2 \cdot x} \]
    5. Simplified72.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.06 \cdot 10^{+52}:\\ \;\;\;\;y \cdot 2\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{+31}:\\ \;\;\;\;x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;y \cdot 2\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 51.0% accurate, 4.2× speedup?

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

\\
x \cdot -2
\end{array}
Derivation
  1. Initial program 79.6%

    \[\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. *-lowering-*.f6447.1

      \[\leadsto \color{blue}{-2 \cdot x} \]
  5. Simplified47.1%

    \[\leadsto \color{blue}{-2 \cdot x} \]
  6. Final simplification47.1%

    \[\leadsto x \cdot -2 \]
  7. 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 2024199 
(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)))