Linear.Projection:perspective from linear-1.19.1.3, B

Percentage Accurate: 77.1% → 98.9%
Time: 7.0s
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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    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: 77.1% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    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: 98.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{+41} \lor \neg \left(x \leq 8.5 \cdot 10^{-139}\right):\\ \;\;\;\;\left(2 \cdot \frac{x}{x - y}\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{x - y} \cdot x\right) \cdot 2\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -3.5e+41) (not (<= x 8.5e-139)))
   (* (* 2.0 (/ x (- x y))) y)
   (* (* (/ y (- x y)) x) 2.0)))
double code(double x, double y) {
	double tmp;
	if ((x <= -3.5e+41) || !(x <= 8.5e-139)) {
		tmp = (2.0 * (x / (x - y))) * y;
	} else {
		tmp = ((y / (x - y)) * x) * 2.0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((x <= (-3.5d+41)) .or. (.not. (x <= 8.5d-139))) then
        tmp = (2.0d0 * (x / (x - y))) * y
    else
        tmp = ((y / (x - y)) * x) * 2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((x <= -3.5e+41) || !(x <= 8.5e-139)) {
		tmp = (2.0 * (x / (x - y))) * y;
	} else {
		tmp = ((y / (x - y)) * x) * 2.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (x <= -3.5e+41) or not (x <= 8.5e-139):
		tmp = (2.0 * (x / (x - y))) * y
	else:
		tmp = ((y / (x - y)) * x) * 2.0
	return tmp
function code(x, y)
	tmp = 0.0
	if ((x <= -3.5e+41) || !(x <= 8.5e-139))
		tmp = Float64(Float64(2.0 * Float64(x / Float64(x - y))) * y);
	else
		tmp = Float64(Float64(Float64(y / Float64(x - y)) * x) * 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((x <= -3.5e+41) || ~((x <= 8.5e-139)))
		tmp = (2.0 * (x / (x - y))) * y;
	else
		tmp = ((y / (x - y)) * x) * 2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[x, -3.5e+41], N[Not[LessEqual[x, 8.5e-139]], $MachinePrecision]], N[(N[(2.0 * N[(x / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(N[(y / N[(x - y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * 2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{+41} \lor \neg \left(x \leq 8.5 \cdot 10^{-139}\right):\\
\;\;\;\;\left(2 \cdot \frac{x}{x - y}\right) \cdot y\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{x - y} \cdot x\right) \cdot 2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.4999999999999999e41 or 8.5000000000000003e-139 < 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. lift-*.f64N/A

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

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

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

        \[\leadsto \color{blue}{\left(2 \cdot \frac{x}{x - y}\right)} \cdot y \]
      11. lower-/.f64100.0

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

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

    if -3.4999999999999999e41 < x < 8.5000000000000003e-139

    1. Initial program 77.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. associate-/l*N/A

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.8% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y \leq -1.55 \cdot 10^{-179}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{-194}:\\
\;\;\;\;2 \cdot y\\

\mathbf{elif}\;y \leq 6.6 \cdot 10^{+158}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.25e144

    1. Initial program 61.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. lower-*.f6486.4

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

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

    if -1.25e144 < y < -1.5500000000000001e-179 or 1.8e-194 < y < 6.60000000000000035e158

    1. Initial program 88.8%

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

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

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

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

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

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

    if -1.5500000000000001e-179 < y < 1.8e-194

    1. Initial program 70.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} \]
    4. Step-by-step derivation
      1. lower-*.f6490.2

        \[\leadsto \color{blue}{2 \cdot y} \]
    5. Applied rewrites90.2%

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

    if 6.60000000000000035e158 < y

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 94.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{-200} \lor \neg \left(x \leq 1.6 \cdot 10^{-159}\right):\\ \;\;\;\;\left(2 \cdot \frac{x}{x - y}\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{x}{y}, x\right) \cdot -2\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= x -2.6e-200) (not (<= x 1.6e-159)))
   (* (* 2.0 (/ x (- x y))) y)
   (* (fma x (/ x y) x) -2.0)))
double code(double x, double y) {
	double tmp;
	if ((x <= -2.6e-200) || !(x <= 1.6e-159)) {
		tmp = (2.0 * (x / (x - y))) * y;
	} else {
		tmp = fma(x, (x / y), x) * -2.0;
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if ((x <= -2.6e-200) || !(x <= 1.6e-159))
		tmp = Float64(Float64(2.0 * Float64(x / Float64(x - y))) * y);
	else
		tmp = Float64(fma(x, Float64(x / y), x) * -2.0);
	end
	return tmp
end
code[x_, y_] := If[Or[LessEqual[x, -2.6e-200], N[Not[LessEqual[x, 1.6e-159]], $MachinePrecision]], N[(N[(2.0 * N[(x / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(x * N[(x / y), $MachinePrecision] + x), $MachinePrecision] * -2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.6 \cdot 10^{-200} \lor \neg \left(x \leq 1.6 \cdot 10^{-159}\right):\\
\;\;\;\;\left(2 \cdot \frac{x}{x - y}\right) \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.5999999999999999e-200 or 1.6e-159 < x

    1. Initial program 80.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. lift-*.f64N/A

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

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

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

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

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

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

    if -2.5999999999999999e-200 < x < 1.6e-159

    1. Initial program 65.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{-200} \lor \neg \left(x \leq 1.6 \cdot 10^{-159}\right):\\ \;\;\;\;\left(2 \cdot \frac{x}{x - y}\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{x}{y}, x\right) \cdot -2\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 73.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1860 \lor \neg \left(y \leq 3.5 \cdot 10^{-87}\right):\\ \;\;\;\;-2 \cdot x\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(\frac{y}{x}, y, y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -1860.0) (not (<= y 3.5e-87)))
   (* -2.0 x)
   (* 2.0 (fma (/ y x) y y))))
double code(double x, double y) {
	double tmp;
	if ((y <= -1860.0) || !(y <= 3.5e-87)) {
		tmp = -2.0 * x;
	} else {
		tmp = 2.0 * fma((y / x), y, y);
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if ((y <= -1860.0) || !(y <= 3.5e-87))
		tmp = Float64(-2.0 * x);
	else
		tmp = Float64(2.0 * fma(Float64(y / x), y, y));
	end
	return tmp
end
code[x_, y_] := If[Or[LessEqual[y, -1860.0], N[Not[LessEqual[y, 3.5e-87]], $MachinePrecision]], N[(-2.0 * x), $MachinePrecision], N[(2.0 * N[(N[(y / x), $MachinePrecision] * y + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1860 \lor \neg \left(y \leq 3.5 \cdot 10^{-87}\right):\\
\;\;\;\;-2 \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1860 or 3.50000000000000012e-87 < y

    1. Initial program 75.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. lower-*.f6475.7

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

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

    if -1860 < y < 3.50000000000000012e-87

    1. Initial program 81.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 + \left(2 \cdot \frac{{y}^{2}}{x} + 2 \cdot \frac{{y}^{3}}{{x}^{2}}\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(\frac{y}{x}, \mathsf{fma}\left(\frac{y}{x}, y, y\right), y\right)} \]
    6. Taylor expanded in x around inf

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1860 \lor \neg \left(y \leq 3.5 \cdot 10^{-87}\right):\\ \;\;\;\;-2 \cdot x\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(\frac{y}{x}, y, y\right)\\ \end{array} \]
    10. Add Preprocessing

    Alternative 5: 73.6% accurate, 0.7× speedup?

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

      1. Initial program 71.0%

        \[\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-*.f6478.5

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

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

      if -1860 < y < 4.49999999999999958e-87

      1. Initial program 81.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 + \left(2 \cdot \frac{{y}^{2}}{x} + 2 \cdot \frac{{y}^{3}}{{x}^{2}}\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{2 \cdot \mathsf{fma}\left(\frac{y}{x}, \mathsf{fma}\left(\frac{y}{x}, y, y\right), y\right)} \]
      6. Taylor expanded in x around inf

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

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

        if 4.49999999999999958e-87 < y

        1. Initial program 78.5%

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

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

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

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

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

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

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

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

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

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

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

      Alternative 6: 73.8% accurate, 1.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1900 \lor \neg \left(y \leq 4.5 \cdot 10^{-87}\right):\\ \;\;\;\;-2 \cdot x\\ \mathbf{else}:\\ \;\;\;\;2 \cdot y\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (or (<= y -1900.0) (not (<= y 4.5e-87))) (* -2.0 x) (* 2.0 y)))
      double code(double x, double y) {
      	double tmp;
      	if ((y <= -1900.0) || !(y <= 4.5e-87)) {
      		tmp = -2.0 * x;
      	} else {
      		tmp = 2.0 * y;
      	}
      	return tmp;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x, y)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8) :: tmp
          if ((y <= (-1900.0d0)) .or. (.not. (y <= 4.5d-87))) then
              tmp = (-2.0d0) * x
          else
              tmp = 2.0d0 * y
          end if
          code = tmp
      end function
      
      public static double code(double x, double y) {
      	double tmp;
      	if ((y <= -1900.0) || !(y <= 4.5e-87)) {
      		tmp = -2.0 * x;
      	} else {
      		tmp = 2.0 * y;
      	}
      	return tmp;
      }
      
      def code(x, y):
      	tmp = 0
      	if (y <= -1900.0) or not (y <= 4.5e-87):
      		tmp = -2.0 * x
      	else:
      		tmp = 2.0 * y
      	return tmp
      
      function code(x, y)
      	tmp = 0.0
      	if ((y <= -1900.0) || !(y <= 4.5e-87))
      		tmp = Float64(-2.0 * x);
      	else
      		tmp = Float64(2.0 * y);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y)
      	tmp = 0.0;
      	if ((y <= -1900.0) || ~((y <= 4.5e-87)))
      		tmp = -2.0 * x;
      	else
      		tmp = 2.0 * y;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_] := If[Or[LessEqual[y, -1900.0], N[Not[LessEqual[y, 4.5e-87]], $MachinePrecision]], N[(-2.0 * x), $MachinePrecision], N[(2.0 * y), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y \leq -1900 \lor \neg \left(y \leq 4.5 \cdot 10^{-87}\right):\\
      \;\;\;\;-2 \cdot x\\
      
      \mathbf{else}:\\
      \;\;\;\;2 \cdot y\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -1900 or 4.49999999999999958e-87 < y

        1. Initial program 75.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. lower-*.f6475.7

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

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

        if -1900 < y < 4.49999999999999958e-87

        1. Initial program 81.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. lower-*.f6482.8

            \[\leadsto \color{blue}{2 \cdot y} \]
        5. Applied rewrites82.8%

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

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

      Alternative 7: 50.0% accurate, 4.2× speedup?

      \[\begin{array}{l} \\ -2 \cdot x \end{array} \]
      (FPCore (x y) :precision binary64 (* -2.0 x))
      double code(double x, double y) {
      	return -2.0 * x;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x, y)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          code = (-2.0d0) * x
      end function
      
      public static double code(double x, double y) {
      	return -2.0 * x;
      }
      
      def code(x, y):
      	return -2.0 * x
      
      function code(x, y)
      	return Float64(-2.0 * x)
      end
      
      function tmp = code(x, y)
      	tmp = -2.0 * x;
      end
      
      code[x_, y_] := N[(-2.0 * x), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      -2 \cdot x
      \end{array}
      
      Derivation
      1. Initial program 78.2%

        \[\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-*.f6448.9

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

        \[\leadsto \color{blue}{-2 \cdot x} \]
      6. Add Preprocessing

      Developer Target 1: 99.3% 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;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x, y)
      use fmin_fmax_functions
          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 2024364 
      (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)))