Kahan p9 Example

Percentage Accurate: 68.1% → 92.7%
Time: 6.8s
Alternatives: 7
Speedup: 0.4×

Specification

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

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

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

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

Alternative 1: 92.7% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
      6. sub0-negN/A

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

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

        \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
      9. associate-*l/N/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      11. difference-of-squaresN/A

        \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
      12. distribute-frac-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
      13. sub0-negN/A

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

        \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
      15. neg-sub0N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
    3. Simplified100.0%

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

    if 2 < (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y)))

    1. Initial program 0.0%

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

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

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

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

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

        \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
      6. sub0-negN/A

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

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

        \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
      9. associate-*l/N/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      11. difference-of-squaresN/A

        \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
      12. distribute-frac-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
      13. sub0-negN/A

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

        \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
      15. neg-sub0N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
    3. Simplified0.0%

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

      \[\leadsto \color{blue}{2 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    6. Step-by-step derivation
      1. *-lft-identityN/A

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

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

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

        \[\leadsto {x}^{2} \cdot \left(2 \cdot \frac{1}{{y}^{2}}\right) - 1 \]
      5. sub-negN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{\left(1 + 1\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
      14. distribute-rgt1-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{{x}^{2} + \left(\mathsf{neg}\left(-1\right)\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
      16. cancel-sign-sub-invN/A

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{/.f64}\left(\left({x}^{2} - -1 \cdot {x}^{2}\right), \color{blue}{\left({y}^{2}\right)}\right)\right) \]
    7. Simplified49.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(2, x\right), y\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right)\right) \]
    9. Applied egg-rr82.6%

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

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

Alternative 2: 92.7% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

    if 2 < (/.f64 (*.f64 (-.f64 x y) (+.f64 x y)) (+.f64 (*.f64 x x) (*.f64 y y)))

    1. Initial program 0.0%

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

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

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

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

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

        \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
      6. sub0-negN/A

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

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

        \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
      9. associate-*l/N/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      11. difference-of-squaresN/A

        \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
      12. distribute-frac-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
      13. sub0-negN/A

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

        \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
      15. neg-sub0N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
    3. Simplified0.0%

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

      \[\leadsto \color{blue}{2 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    6. Step-by-step derivation
      1. *-lft-identityN/A

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

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

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

        \[\leadsto {x}^{2} \cdot \left(2 \cdot \frac{1}{{y}^{2}}\right) - 1 \]
      5. sub-negN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{\left(1 + 1\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
      14. distribute-rgt1-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{{x}^{2} + \left(\mathsf{neg}\left(-1\right)\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
      16. cancel-sign-sub-invN/A

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{/.f64}\left(\left({x}^{2} - -1 \cdot {x}^{2}\right), \color{blue}{\left({y}^{2}\right)}\right)\right) \]
    7. Simplified49.4%

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(2, x\right), y\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right)\right) \]
    9. Applied egg-rr82.6%

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

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

Alternative 3: 42.6% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 2.1500000000000001e-204

    1. Initial program 64.8%

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

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

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

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

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

        \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
      6. sub0-negN/A

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

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

        \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
      9. associate-*l/N/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      11. difference-of-squaresN/A

        \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
      12. distribute-frac-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
      13. sub0-negN/A

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

        \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
      15. neg-sub0N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
    3. Simplified64.8%

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot y}{x \cdot x + y \cdot y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{-1 \cdot {y}^{2}}{{x}^{2}} - \frac{\color{blue}{{y}^{2}}}{{x}^{2}}\right)\right) \]
      4. div-subN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(-1 \cdot {y}^{2} - {y}^{2}\right), \color{blue}{\left({x}^{2}\right)}\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(-1 \cdot {y}^{2} + \left(\mathsf{neg}\left({y}^{2}\right)\right)\right), \left({\color{blue}{x}}^{2}\right)\right)\right) \]
      7. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(-1 \cdot {y}^{2} + -1 \cdot {y}^{2}\right), \left({x}^{2}\right)\right)\right) \]
      8. distribute-rgt-outN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left({y}^{2} \cdot \left(-1 + -1\right)\right), \left({\color{blue}{x}}^{2}\right)\right)\right) \]
      9. unpow2N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, -2\right)\right), \left({x}^{2}\right)\right)\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, -2\right)\right), \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      17. *-lowering-*.f6429.1%

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

      \[\leadsto \color{blue}{1 + \frac{y \cdot \left(y \cdot -2\right)}{x \cdot x}} \]
    8. Step-by-step derivation
      1. times-fracN/A

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

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

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

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

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

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

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

    if 2.1500000000000001e-204 < y

    1. Initial program 84.7%

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

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

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

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

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

        \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
      6. sub0-negN/A

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

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

        \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
      9. associate-*l/N/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      11. difference-of-squaresN/A

        \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
      12. distribute-frac-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
      13. sub0-negN/A

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

        \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
      15. neg-sub0N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
    3. Simplified84.7%

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

      \[\leadsto \color{blue}{2 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    6. Step-by-step derivation
      1. *-lft-identityN/A

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

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

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

        \[\leadsto {x}^{2} \cdot \left(2 \cdot \frac{1}{{y}^{2}}\right) - 1 \]
      5. sub-negN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{\left(1 + 1\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
      14. distribute-rgt1-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{{x}^{2} + \left(\mathsf{neg}\left(-1\right)\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
      16. cancel-sign-sub-invN/A

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{/.f64}\left(\left({x}^{2} - -1 \cdot {x}^{2}\right), \color{blue}{\left({y}^{2}\right)}\right)\right) \]
    7. Simplified58.0%

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(2, x\right), y\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right)\right) \]
    9. Applied egg-rr73.1%

      \[\leadsto -1 + \color{blue}{\frac{2 \cdot x}{y} \cdot \frac{x}{y}} \]
    10. Step-by-step derivation
      1. flip-+N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{-1 - \frac{2 \cdot x}{y} \cdot \frac{x}{y}}{-1 \cdot -1 - \left(\frac{2 \cdot x}{y} \cdot \frac{x}{y}\right) \cdot \left(\frac{2 \cdot x}{y} \cdot \frac{x}{y}\right)}\right)}\right) \]
      4. clear-numN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 42.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.06 \cdot 10^{-204}:\\
\;\;\;\;1 + \frac{\frac{y}{x} \cdot \left(y \cdot -2\right)}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.05999999999999998e-204

    1. Initial program 64.8%

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

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

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

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

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

        \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
      6. sub0-negN/A

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

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

        \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
      9. associate-*l/N/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      11. difference-of-squaresN/A

        \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
      12. distribute-frac-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
      13. sub0-negN/A

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

        \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
      15. neg-sub0N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
    3. Simplified64.8%

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot y}{x \cdot x + y \cdot y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{-1 \cdot {y}^{2}}{{x}^{2}} - \frac{\color{blue}{{y}^{2}}}{{x}^{2}}\right)\right) \]
      4. div-subN/A

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

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(-1 \cdot {y}^{2} - {y}^{2}\right), \color{blue}{\left({x}^{2}\right)}\right)\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(-1 \cdot {y}^{2} + \left(\mathsf{neg}\left({y}^{2}\right)\right)\right), \left({\color{blue}{x}}^{2}\right)\right)\right) \]
      7. mul-1-negN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(-1 \cdot {y}^{2} + -1 \cdot {y}^{2}\right), \left({x}^{2}\right)\right)\right) \]
      8. distribute-rgt-outN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left({y}^{2} \cdot \left(-1 + -1\right)\right), \left({\color{blue}{x}}^{2}\right)\right)\right) \]
      9. unpow2N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, -2\right)\right), \left({x}^{2}\right)\right)\right) \]
      16. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(y, -2\right)\right), \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      17. *-lowering-*.f6429.1%

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

      \[\leadsto \color{blue}{1 + \frac{y \cdot \left(y \cdot -2\right)}{x \cdot x}} \]
    8. Step-by-step derivation
      1. times-fracN/A

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

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

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

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

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

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

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

    if 1.05999999999999998e-204 < y

    1. Initial program 84.7%

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

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

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

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

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

        \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
      6. sub0-negN/A

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

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

        \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
      9. associate-*l/N/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      11. difference-of-squaresN/A

        \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
      12. distribute-frac-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
      13. sub0-negN/A

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

        \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
      15. neg-sub0N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
    3. Simplified84.7%

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

      \[\leadsto \color{blue}{2 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
    6. Step-by-step derivation
      1. *-lft-identityN/A

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

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

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

        \[\leadsto {x}^{2} \cdot \left(2 \cdot \frac{1}{{y}^{2}}\right) - 1 \]
      5. sub-negN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{\left(1 + 1\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
      14. distribute-rgt1-inN/A

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

        \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{{x}^{2} + \left(\mathsf{neg}\left(-1\right)\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
      16. cancel-sign-sub-invN/A

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{/.f64}\left(\left({x}^{2} - -1 \cdot {x}^{2}\right), \color{blue}{\left({y}^{2}\right)}\right)\right) \]
    7. Simplified58.0%

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(2, x\right), y\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right)\right) \]
    9. Applied egg-rr73.1%

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

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

Alternative 5: 40.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.2 \cdot 10^{-215}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 9.1999999999999996e-215

    1. Initial program 64.6%

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

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

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

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

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

        \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
      6. sub0-negN/A

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

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

        \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
      9. associate-*l/N/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
      11. difference-of-squaresN/A

        \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
      12. distribute-frac-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
      13. sub0-negN/A

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

        \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
      15. neg-sub0N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
    3. Simplified64.6%

      \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot y}{x \cdot x + y \cdot y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf

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

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

      if 9.1999999999999996e-215 < y

      1. Initial program 85.0%

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

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

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

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

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

          \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
        6. sub0-negN/A

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

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

          \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
        9. associate-*l/N/A

          \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
        10. +-commutativeN/A

          \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
        11. difference-of-squaresN/A

          \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
        12. distribute-frac-negN/A

          \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
        13. sub0-negN/A

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

          \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
        15. neg-sub0N/A

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

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

          \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
      3. Simplified85.1%

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

        \[\leadsto \color{blue}{2 \cdot \frac{{x}^{2}}{{y}^{2}} - 1} \]
      6. Step-by-step derivation
        1. *-lft-identityN/A

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

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

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

          \[\leadsto {x}^{2} \cdot \left(2 \cdot \frac{1}{{y}^{2}}\right) - 1 \]
        5. sub-negN/A

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{\left(1 + 1\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
        14. distribute-rgt1-inN/A

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

          \[\leadsto \mathsf{+.f64}\left(-1, \left(\frac{{x}^{2} + \left(\mathsf{neg}\left(-1\right)\right) \cdot {x}^{2}}{{y}^{2}}\right)\right) \]
        16. cancel-sign-sub-invN/A

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

          \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{/.f64}\left(\left({x}^{2} - -1 \cdot {x}^{2}\right), \color{blue}{\left({y}^{2}\right)}\right)\right) \]
      7. Simplified56.9%

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

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

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

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

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

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

          \[\leadsto \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(2, x\right), y\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right)\right) \]
      9. Applied egg-rr71.6%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 9.2 \cdot 10^{-215}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1 + \frac{x \cdot 2}{y} \cdot \frac{x}{y}\\ \end{array} \]
    9. Add Preprocessing

    Alternative 6: 40.5% accurate, 2.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 7.5 \cdot 10^{-207}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \end{array} \]
    (FPCore (x y) :precision binary64 (if (<= y 7.5e-207) 1.0 -1.0))
    double code(double x, double y) {
    	double tmp;
    	if (y <= 7.5e-207) {
    		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 <= 7.5d-207) 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 <= 7.5e-207) {
    		tmp = 1.0;
    	} else {
    		tmp = -1.0;
    	}
    	return tmp;
    }
    
    def code(x, y):
    	tmp = 0
    	if y <= 7.5e-207:
    		tmp = 1.0
    	else:
    		tmp = -1.0
    	return tmp
    
    function code(x, y)
    	tmp = 0.0
    	if (y <= 7.5e-207)
    		tmp = 1.0;
    	else
    		tmp = -1.0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y)
    	tmp = 0.0;
    	if (y <= 7.5e-207)
    		tmp = 1.0;
    	else
    		tmp = -1.0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_] := If[LessEqual[y, 7.5e-207], 1.0, -1.0]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;y \leq 7.5 \cdot 10^{-207}:\\
    \;\;\;\;1\\
    
    \mathbf{else}:\\
    \;\;\;\;-1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < 7.5000000000000006e-207

      1. Initial program 64.8%

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

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

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

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

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

          \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
        6. sub0-negN/A

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

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

          \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
        9. associate-*l/N/A

          \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
        10. +-commutativeN/A

          \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
        11. difference-of-squaresN/A

          \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
        12. distribute-frac-negN/A

          \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
        13. sub0-negN/A

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

          \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
        15. neg-sub0N/A

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

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

          \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
      3. Simplified64.8%

        \[\leadsto \color{blue}{\frac{x \cdot x - y \cdot y}{x \cdot x + y \cdot y}} \]
      4. Add Preprocessing
      5. Taylor expanded in x around inf

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

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

        if 7.5000000000000006e-207 < y

        1. Initial program 84.7%

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

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

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

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

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

            \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
          6. sub0-negN/A

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

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

            \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
          9. associate-*l/N/A

            \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
          10. +-commutativeN/A

            \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
          11. difference-of-squaresN/A

            \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
          12. distribute-frac-negN/A

            \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
          13. sub0-negN/A

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

            \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
          15. neg-sub0N/A

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

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

            \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
        3. Simplified84.7%

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

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

            \[\leadsto \color{blue}{-1} \]
        7. Recombined 2 regimes into one program.
        8. Add Preprocessing

        Alternative 7: 67.6% accurate, 15.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 68.3%

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

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

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

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

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

            \[\leadsto \left(0 - \left(y - x\right)\right) \cdot \frac{\color{blue}{x + y}}{x \cdot x + y \cdot y} \]
          6. sub0-negN/A

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

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

            \[\leadsto \mathsf{neg}\left(\frac{x + y}{x \cdot x + y \cdot y} \cdot \left(y - x\right)\right) \]
          9. associate-*l/N/A

            \[\leadsto \mathsf{neg}\left(\frac{\left(x + y\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
          10. +-commutativeN/A

            \[\leadsto \mathsf{neg}\left(\frac{\left(y + x\right) \cdot \left(y - x\right)}{x \cdot x + y \cdot y}\right) \]
          11. difference-of-squaresN/A

            \[\leadsto \mathsf{neg}\left(\frac{y \cdot y - x \cdot x}{x \cdot x + y \cdot y}\right) \]
          12. distribute-frac-negN/A

            \[\leadsto \frac{\mathsf{neg}\left(\left(y \cdot y - x \cdot x\right)\right)}{\color{blue}{x \cdot x + y \cdot y}} \]
          13. sub0-negN/A

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

            \[\leadsto \frac{\left(0 - y \cdot y\right) + x \cdot x}{\color{blue}{x \cdot x} + y \cdot y} \]
          15. neg-sub0N/A

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

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

            \[\leadsto \mathsf{/.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(y\right)\right) + x \cdot x\right), \color{blue}{\left(x \cdot x + y \cdot y\right)}\right) \]
        3. Simplified68.4%

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

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

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

          Developer Target 1: 99.9% accurate, 0.1× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;0.5 < t\_0 \land t\_0 < 2:\\ \;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{2}{1 + \frac{x}{y} \cdot \frac{x}{y}}\\ \end{array} \end{array} \]
          (FPCore (x y)
           :precision binary64
           (let* ((t_0 (fabs (/ x y))))
             (if (and (< 0.5 t_0) (< t_0 2.0))
               (/ (* (- x y) (+ x y)) (+ (* x x) (* y y)))
               (- 1.0 (/ 2.0 (+ 1.0 (* (/ x y) (/ x y))))))))
          double code(double x, double y) {
          	double t_0 = fabs((x / y));
          	double tmp;
          	if ((0.5 < t_0) && (t_0 < 2.0)) {
          		tmp = ((x - y) * (x + y)) / ((x * x) + (y * y));
          	} else {
          		tmp = 1.0 - (2.0 / (1.0 + ((x / y) * (x / y))));
          	}
          	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 = abs((x / y))
              if ((0.5d0 < t_0) .and. (t_0 < 2.0d0)) then
                  tmp = ((x - y) * (x + y)) / ((x * x) + (y * y))
              else
                  tmp = 1.0d0 - (2.0d0 / (1.0d0 + ((x / y) * (x / y))))
              end if
              code = tmp
          end function
          
          public static double code(double x, double y) {
          	double t_0 = Math.abs((x / y));
          	double tmp;
          	if ((0.5 < t_0) && (t_0 < 2.0)) {
          		tmp = ((x - y) * (x + y)) / ((x * x) + (y * y));
          	} else {
          		tmp = 1.0 - (2.0 / (1.0 + ((x / y) * (x / y))));
          	}
          	return tmp;
          }
          
          def code(x, y):
          	t_0 = math.fabs((x / y))
          	tmp = 0
          	if (0.5 < t_0) and (t_0 < 2.0):
          		tmp = ((x - y) * (x + y)) / ((x * x) + (y * y))
          	else:
          		tmp = 1.0 - (2.0 / (1.0 + ((x / y) * (x / y))))
          	return tmp
          
          function code(x, y)
          	t_0 = abs(Float64(x / y))
          	tmp = 0.0
          	if ((0.5 < t_0) && (t_0 < 2.0))
          		tmp = Float64(Float64(Float64(x - y) * Float64(x + y)) / Float64(Float64(x * x) + Float64(y * y)));
          	else
          		tmp = Float64(1.0 - Float64(2.0 / Float64(1.0 + Float64(Float64(x / y) * Float64(x / y)))));
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y)
          	t_0 = abs((x / y));
          	tmp = 0.0;
          	if ((0.5 < t_0) && (t_0 < 2.0))
          		tmp = ((x - y) * (x + y)) / ((x * x) + (y * y));
          	else
          		tmp = 1.0 - (2.0 / (1.0 + ((x / y) * (x / y))));
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[And[Less[0.5, t$95$0], Less[t$95$0, 2.0]], N[(N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(2.0 / N[(1.0 + N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \left|\frac{x}{y}\right|\\
          \mathbf{if}\;0.5 < t\_0 \land t\_0 < 2:\\
          \;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\
          
          \mathbf{else}:\\
          \;\;\;\;1 - \frac{2}{1 + \frac{x}{y} \cdot \frac{x}{y}}\\
          
          
          \end{array}
          \end{array}
          

          Reproduce

          ?
          herbie shell --seed 2024156 
          (FPCore (x y)
            :name "Kahan p9 Example"
            :precision binary64
            :pre (and (and (< 0.0 x) (< x 1.0)) (< y 1.0))
          
            :alt
            (! :herbie-platform default (if (< 1/2 (fabs (/ x y)) 2) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1 (/ 2 (+ 1 (* (/ x y) (/ x y)))))))
          
            (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))