Linear.Projection:perspective from linear-1.19.1.3, A

Percentage Accurate: 100.0% → 100.0%
Time: 7.2s
Alternatives: 9
Speedup: 1.0×

Specification

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

\\
\frac{x + 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 9 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

\\
\frac{x + y}{x - y}
\end{array}

Alternative 1: 100.0% accurate, 0.8× speedup?

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

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

    \[\frac{x + y}{x - y} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. clear-numN/A

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

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{x - y}{x + y}\right)}\right) \]
    3. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\left(x - y\right), \color{blue}{\left(x + y\right)}\right)\right) \]
    4. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x, y\right), \left(\color{blue}{x} + y\right)\right)\right) \]
    5. +-lowering-+.f64100.0%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x, y\right), \mathsf{+.f64}\left(x, \color{blue}{y}\right)\right)\right) \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{1}{\frac{x - y}{x + y}}} \]
  5. Add Preprocessing

Alternative 2: 75.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := -1 + -2 \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -4.8 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 4.6 \cdot 10^{+18}:\\
\;\;\;\;1 + \frac{y \cdot 2}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.8e21 or 4.6e18 < y

    1. Initial program 99.9%

      \[\frac{x + y}{x - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

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

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

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

        \[\leadsto \frac{x}{y} \cdot -2 + -1 \]
      4. associate-*l/N/A

        \[\leadsto \frac{x \cdot -2}{y} + -1 \]
      5. metadata-evalN/A

        \[\leadsto \frac{x \cdot \left(-1 - 1\right)}{y} + -1 \]
      6. distribute-rgt-out--N/A

        \[\leadsto \frac{-1 \cdot x - 1 \cdot x}{y} + -1 \]
      7. *-lft-identityN/A

        \[\leadsto \frac{-1 \cdot x - x}{y} + -1 \]
      8. +-commutativeN/A

        \[\leadsto -1 + \color{blue}{\frac{-1 \cdot x - x}{y}} \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{-1 \cdot x - x}{y}\right)}\right) \]
      10. *-lft-identityN/A

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{-1 \cdot x - 1 \cdot x}{y}\right)\right) \]
      11. distribute-rgt-out--N/A

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{x \cdot \left(-1 - 1\right)}{y}\right)\right) \]
      12. metadata-evalN/A

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(-2, \color{blue}{\left(\frac{x}{y}\right)}\right)\right) \]
      16. /-lowering-/.f6485.0%

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(-2, \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right)\right) \]
    5. Simplified85.0%

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

    if -4.8e21 < y < 4.6e18

    1. Initial program 100.0%

      \[\frac{x + y}{x - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{y \cdot \left(1 - -1\right)}{x}\right)\right) \]
      14. distribute-rgt-out--N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{1 \cdot y - -1 \cdot y}{x}\right)\right) \]
      15. *-lft-identityN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{y - -1 \cdot y}{x}\right)\right) \]
      16. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(y - -1 \cdot y\right), \color{blue}{x}\right)\right) \]
      17. *-lft-identityN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(1 \cdot y - -1 \cdot y\right), x\right)\right) \]
      18. distribute-rgt-out--N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(y \cdot \left(1 - -1\right)\right), x\right)\right) \]
      19. metadata-evalN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(y \cdot 2\right), x\right)\right) \]
      20. *-lowering-*.f6476.6%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, 2\right), x\right)\right) \]
    5. Simplified76.6%

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

Alternative 3: 75.3% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := -1 + -2 \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -2.8 \cdot 10^{+23}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 3.9 \cdot 10^{+18}:\\
\;\;\;\;1 + \frac{y}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.8e23 or 3.9e18 < y

    1. Initial program 99.9%

      \[\frac{x + y}{x - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

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

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

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

        \[\leadsto \frac{x}{y} \cdot -2 + -1 \]
      4. associate-*l/N/A

        \[\leadsto \frac{x \cdot -2}{y} + -1 \]
      5. metadata-evalN/A

        \[\leadsto \frac{x \cdot \left(-1 - 1\right)}{y} + -1 \]
      6. distribute-rgt-out--N/A

        \[\leadsto \frac{-1 \cdot x - 1 \cdot x}{y} + -1 \]
      7. *-lft-identityN/A

        \[\leadsto \frac{-1 \cdot x - x}{y} + -1 \]
      8. +-commutativeN/A

        \[\leadsto -1 + \color{blue}{\frac{-1 \cdot x - x}{y}} \]
      9. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(-1, \color{blue}{\left(\frac{-1 \cdot x - x}{y}\right)}\right) \]
      10. *-lft-identityN/A

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{-1 \cdot x - 1 \cdot x}{y}\right)\right) \]
      11. distribute-rgt-out--N/A

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{x \cdot \left(-1 - 1\right)}{y}\right)\right) \]
      12. metadata-evalN/A

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(-2, \color{blue}{\left(\frac{x}{y}\right)}\right)\right) \]
      16. /-lowering-/.f6485.0%

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(-2, \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right)\right) \]
    5. Simplified85.0%

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

    if -2.8e23 < y < 3.9e18

    1. Initial program 100.0%

      \[\frac{x + y}{x - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, y\right), \color{blue}{x}\right) \]
    4. Step-by-step derivation
      1. Simplified76.2%

        \[\leadsto \frac{x + y}{\color{blue}{x}} \]
      2. Step-by-step derivation
        1. clear-numN/A

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

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

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

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

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

          \[\leadsto \frac{y}{x} + \frac{x}{\color{blue}{x}} \]
        7. *-inversesN/A

          \[\leadsto \frac{y}{x} + 1 \]
        8. +-lowering-+.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\left(\frac{y}{x}\right), \color{blue}{1}\right) \]
        9. /-lowering-/.f6476.2%

          \[\leadsto \mathsf{+.f64}\left(\mathsf{/.f64}\left(y, x\right), 1\right) \]
      3. Applied egg-rr76.2%

        \[\leadsto \color{blue}{\frac{y}{x} + 1} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification79.9%

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{+23}:\\ \;\;\;\;-1 + -2 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+18}:\\ \;\;\;\;1 + \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;-1 + -2 \cdot \frac{x}{y}\\ \end{array} \]
    7. Add Preprocessing

    Alternative 4: 75.1% accurate, 0.5× speedup?

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

      1. Initial program 99.9%

        \[\frac{x + y}{x - y} \]
      2. Add Preprocessing
      3. Taylor expanded in x around 0

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{y}, \mathsf{\_.f64}\left(x, y\right)\right) \]
      4. Step-by-step derivation
        1. Simplified84.8%

          \[\leadsto \frac{\color{blue}{y}}{x - y} \]
        2. Taylor expanded in y around inf

          \[\leadsto \color{blue}{-1 \cdot \frac{x}{y} - 1} \]
        3. Step-by-step derivation
          1. sub-negN/A

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

            \[\leadsto -1 \cdot \frac{x}{y} + -1 \]
          3. +-commutativeN/A

            \[\leadsto -1 + \color{blue}{-1 \cdot \frac{x}{y}} \]
          4. mul-1-negN/A

            \[\leadsto -1 + \left(\mathsf{neg}\left(\frac{x}{y}\right)\right) \]
          5. sub-negN/A

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

            \[\leadsto \mathsf{\_.f64}\left(-1, \color{blue}{\left(\frac{x}{y}\right)}\right) \]
          7. /-lowering-/.f6485.2%

            \[\leadsto \mathsf{\_.f64}\left(-1, \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
        4. Simplified85.2%

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

        if -2.8e20 < y < 2.7e16

        1. Initial program 100.0%

          \[\frac{x + y}{x - y} \]
        2. Add Preprocessing
        3. Taylor expanded in x around inf

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, y\right), \color{blue}{x}\right) \]
        4. Step-by-step derivation
          1. Simplified76.5%

            \[\leadsto \frac{x + y}{\color{blue}{x}} \]
          2. Step-by-step derivation
            1. clear-numN/A

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

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

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

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

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

              \[\leadsto \frac{y}{x} + \frac{x}{\color{blue}{x}} \]
            7. *-inversesN/A

              \[\leadsto \frac{y}{x} + 1 \]
            8. +-lowering-+.f64N/A

              \[\leadsto \mathsf{+.f64}\left(\left(\frac{y}{x}\right), \color{blue}{1}\right) \]
            9. /-lowering-/.f6476.5%

              \[\leadsto \mathsf{+.f64}\left(\mathsf{/.f64}\left(y, x\right), 1\right) \]
          3. Applied egg-rr76.5%

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

          if 2.7e16 < y

          1. Initial program 99.9%

            \[\frac{x + y}{x - y} \]
          2. Add Preprocessing
          3. Taylor expanded in x around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{y}, \mathsf{\_.f64}\left(x, y\right)\right) \]
          4. Step-by-step derivation
            1. Simplified82.2%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{+20}:\\ \;\;\;\;-1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+16}:\\ \;\;\;\;1 + \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x - y}\\ \end{array} \]
          7. Add Preprocessing

          Alternative 5: 75.1% accurate, 0.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := -1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -3 \cdot 10^{+23}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+18}:\\ \;\;\;\;1 + \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
          (FPCore (x y)
           :precision binary64
           (let* ((t_0 (- -1.0 (/ x y))))
             (if (<= y -3e+23) t_0 (if (<= y 3.9e+18) (+ 1.0 (/ y x)) t_0))))
          double code(double x, double y) {
          	double t_0 = -1.0 - (x / y);
          	double tmp;
          	if (y <= -3e+23) {
          		tmp = t_0;
          	} else if (y <= 3.9e+18) {
          		tmp = 1.0 + (y / x);
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          real(8) function code(x, y)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8) :: t_0
              real(8) :: tmp
              t_0 = (-1.0d0) - (x / y)
              if (y <= (-3d+23)) then
                  tmp = t_0
              else if (y <= 3.9d+18) then
                  tmp = 1.0d0 + (y / x)
              else
                  tmp = t_0
              end if
              code = tmp
          end function
          
          public static double code(double x, double y) {
          	double t_0 = -1.0 - (x / y);
          	double tmp;
          	if (y <= -3e+23) {
          		tmp = t_0;
          	} else if (y <= 3.9e+18) {
          		tmp = 1.0 + (y / x);
          	} else {
          		tmp = t_0;
          	}
          	return tmp;
          }
          
          def code(x, y):
          	t_0 = -1.0 - (x / y)
          	tmp = 0
          	if y <= -3e+23:
          		tmp = t_0
          	elif y <= 3.9e+18:
          		tmp = 1.0 + (y / x)
          	else:
          		tmp = t_0
          	return tmp
          
          function code(x, y)
          	t_0 = Float64(-1.0 - Float64(x / y))
          	tmp = 0.0
          	if (y <= -3e+23)
          		tmp = t_0;
          	elseif (y <= 3.9e+18)
          		tmp = Float64(1.0 + Float64(y / x));
          	else
          		tmp = t_0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y)
          	t_0 = -1.0 - (x / y);
          	tmp = 0.0;
          	if (y <= -3e+23)
          		tmp = t_0;
          	elseif (y <= 3.9e+18)
          		tmp = 1.0 + (y / x);
          	else
          		tmp = t_0;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_] := Block[{t$95$0 = N[(-1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3e+23], t$95$0, If[LessEqual[y, 3.9e+18], N[(1.0 + N[(y / x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := -1 - \frac{x}{y}\\
          \mathbf{if}\;y \leq -3 \cdot 10^{+23}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;y \leq 3.9 \cdot 10^{+18}:\\
          \;\;\;\;1 + \frac{y}{x}\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_0\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -3.0000000000000001e23 or 3.9e18 < y

            1. Initial program 99.9%

              \[\frac{x + y}{x - y} \]
            2. Add Preprocessing
            3. Taylor expanded in x around 0

              \[\leadsto \mathsf{/.f64}\left(\color{blue}{y}, \mathsf{\_.f64}\left(x, y\right)\right) \]
            4. Step-by-step derivation
              1. Simplified84.0%

                \[\leadsto \frac{\color{blue}{y}}{x - y} \]
              2. Taylor expanded in y around inf

                \[\leadsto \color{blue}{-1 \cdot \frac{x}{y} - 1} \]
              3. Step-by-step derivation
                1. sub-negN/A

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

                  \[\leadsto -1 \cdot \frac{x}{y} + -1 \]
                3. +-commutativeN/A

                  \[\leadsto -1 + \color{blue}{-1 \cdot \frac{x}{y}} \]
                4. mul-1-negN/A

                  \[\leadsto -1 + \left(\mathsf{neg}\left(\frac{x}{y}\right)\right) \]
                5. sub-negN/A

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

                  \[\leadsto \mathsf{\_.f64}\left(-1, \color{blue}{\left(\frac{x}{y}\right)}\right) \]
                7. /-lowering-/.f6484.2%

                  \[\leadsto \mathsf{\_.f64}\left(-1, \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
              4. Simplified84.2%

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

              if -3.0000000000000001e23 < y < 3.9e18

              1. Initial program 100.0%

                \[\frac{x + y}{x - y} \]
              2. Add Preprocessing
              3. Taylor expanded in x around inf

                \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, y\right), \color{blue}{x}\right) \]
              4. Step-by-step derivation
                1. Simplified76.2%

                  \[\leadsto \frac{x + y}{\color{blue}{x}} \]
                2. Step-by-step derivation
                  1. clear-numN/A

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

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

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

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

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

                    \[\leadsto \frac{y}{x} + \frac{x}{\color{blue}{x}} \]
                  7. *-inversesN/A

                    \[\leadsto \frac{y}{x} + 1 \]
                  8. +-lowering-+.f64N/A

                    \[\leadsto \mathsf{+.f64}\left(\left(\frac{y}{x}\right), \color{blue}{1}\right) \]
                  9. /-lowering-/.f6476.2%

                    \[\leadsto \mathsf{+.f64}\left(\mathsf{/.f64}\left(y, x\right), 1\right) \]
                3. Applied egg-rr76.2%

                  \[\leadsto \color{blue}{\frac{y}{x} + 1} \]
              5. Recombined 2 regimes into one program.
              6. Final simplification79.5%

                \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{+23}:\\ \;\;\;\;-1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{+18}:\\ \;\;\;\;1 + \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;-1 - \frac{x}{y}\\ \end{array} \]
              7. Add Preprocessing

              Alternative 6: 74.7% accurate, 0.5× speedup?

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

                1. Initial program 99.9%

                  \[\frac{x + y}{x - y} \]
                2. Add Preprocessing
                3. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{-1} \]
                4. Step-by-step derivation
                  1. Simplified83.6%

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

                  if -1.16e23 < y < 1.1e20

                  1. Initial program 100.0%

                    \[\frac{x + y}{x - y} \]
                  2. Add Preprocessing
                  3. Taylor expanded in x around inf

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, y\right), \color{blue}{x}\right) \]
                  4. Step-by-step derivation
                    1. Simplified76.2%

                      \[\leadsto \frac{x + y}{\color{blue}{x}} \]
                    2. Step-by-step derivation
                      1. clear-numN/A

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

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

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

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

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

                        \[\leadsto \frac{y}{x} + \frac{x}{\color{blue}{x}} \]
                      7. *-inversesN/A

                        \[\leadsto \frac{y}{x} + 1 \]
                      8. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{+.f64}\left(\left(\frac{y}{x}\right), \color{blue}{1}\right) \]
                      9. /-lowering-/.f6476.2%

                        \[\leadsto \mathsf{+.f64}\left(\mathsf{/.f64}\left(y, x\right), 1\right) \]
                    3. Applied egg-rr76.2%

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.16 \cdot 10^{+23}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+20}:\\ \;\;\;\;1 + \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
                  7. Add Preprocessing

                  Alternative 7: 74.5% accurate, 0.6× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.95 \cdot 10^{+23}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+17}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
                  (FPCore (x y)
                   :precision binary64
                   (if (<= y -1.95e+23) -1.0 (if (<= y 1.95e+17) 1.0 -1.0)))
                  double code(double x, double y) {
                  	double tmp;
                  	if (y <= -1.95e+23) {
                  		tmp = -1.0;
                  	} else if (y <= 1.95e+17) {
                  		tmp = 1.0;
                  	} else {
                  		tmp = -1.0;
                  	}
                  	return tmp;
                  }
                  
                  real(8) function code(x, y)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      real(8) :: tmp
                      if (y <= (-1.95d+23)) then
                          tmp = -1.0d0
                      else if (y <= 1.95d+17) then
                          tmp = 1.0d0
                      else
                          tmp = -1.0d0
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double y) {
                  	double tmp;
                  	if (y <= -1.95e+23) {
                  		tmp = -1.0;
                  	} else if (y <= 1.95e+17) {
                  		tmp = 1.0;
                  	} else {
                  		tmp = -1.0;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y):
                  	tmp = 0
                  	if y <= -1.95e+23:
                  		tmp = -1.0
                  	elif y <= 1.95e+17:
                  		tmp = 1.0
                  	else:
                  		tmp = -1.0
                  	return tmp
                  
                  function code(x, y)
                  	tmp = 0.0
                  	if (y <= -1.95e+23)
                  		tmp = -1.0;
                  	elseif (y <= 1.95e+17)
                  		tmp = 1.0;
                  	else
                  		tmp = -1.0;
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y)
                  	tmp = 0.0;
                  	if (y <= -1.95e+23)
                  		tmp = -1.0;
                  	elseif (y <= 1.95e+17)
                  		tmp = 1.0;
                  	else
                  		tmp = -1.0;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_] := If[LessEqual[y, -1.95e+23], -1.0, If[LessEqual[y, 1.95e+17], 1.0, -1.0]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;y \leq -1.95 \cdot 10^{+23}:\\
                  \;\;\;\;-1\\
                  
                  \mathbf{elif}\;y \leq 1.95 \cdot 10^{+17}:\\
                  \;\;\;\;1\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;-1\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if y < -1.95e23 or 1.95e17 < y

                    1. Initial program 99.9%

                      \[\frac{x + y}{x - y} \]
                    2. Add Preprocessing
                    3. Taylor expanded in x around 0

                      \[\leadsto \color{blue}{-1} \]
                    4. Step-by-step derivation
                      1. Simplified83.0%

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

                      if -1.95e23 < y < 1.95e17

                      1. Initial program 100.0%

                        \[\frac{x + y}{x - y} \]
                      2. Add Preprocessing
                      3. Taylor expanded in x around inf

                        \[\leadsto \color{blue}{1} \]
                      4. Step-by-step derivation
                        1. Simplified75.8%

                          \[\leadsto \color{blue}{1} \]
                      5. Recombined 2 regimes into one program.
                      6. Add Preprocessing

                      Alternative 8: 100.0% accurate, 1.0× speedup?

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

                        \[\frac{x + y}{x - y} \]
                      2. Add Preprocessing
                      3. Add Preprocessing

                      Alternative 9: 49.9% accurate, 7.0× speedup?

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

                        \[\frac{x + y}{x - y} \]
                      2. Add Preprocessing
                      3. Taylor expanded in x around 0

                        \[\leadsto \color{blue}{-1} \]
                      4. Step-by-step derivation
                        1. Simplified48.5%

                          \[\leadsto \color{blue}{-1} \]
                        2. Add Preprocessing

                        Developer Target 1: 100.0% accurate, 0.5× speedup?

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

                        Reproduce

                        ?
                        herbie shell --seed 2024155 
                        (FPCore (x y)
                          :name "Linear.Projection:perspective from linear-1.19.1.3, A"
                          :precision binary64
                        
                          :alt
                          (! :herbie-platform default (/ 1 (- (/ x (+ x y)) (/ y (+ x y)))))
                        
                          (/ (+ x y) (- x y)))