Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3

Percentage Accurate: 99.9% → 99.9%
Time: 13.6s
Alternatives: 13
Speedup: 1.0×

Specification

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

\\
x + \frac{\left|y - x\right|}{2}
\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 13 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: 99.9% accurate, 1.0× speedup?

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

\\
x + \frac{\left|y - x\right|}{2}
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

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

\\
x + \frac{\left|x - y\right|}{2}
\end{array}
Derivation
  1. Initial program 99.9%

    \[x + \frac{\left|y - x\right|}{2} \]
  2. Add Preprocessing
  3. Final simplification99.9%

    \[\leadsto x + \frac{\left|x - y\right|}{2} \]
  4. Add Preprocessing

Alternative 2: 83.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-195}:\\
\;\;\;\;x - 0.5 \cdot \left(x + y\right)\\

\mathbf{elif}\;y \leq 1.6 \cdot 10^{-88}:\\
\;\;\;\;x + \frac{\left|x\right|}{2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.10000000000000003e-195

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{x \cdot \left(\frac{y}{x} - 1\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. *-inverses85.2%

        \[\leadsto x + \frac{\left|x \cdot \left(\frac{y}{x} - \color{blue}{\frac{x}{x}}\right)\right|}{2} \]
      2. div-sub85.2%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{y - x}{x}}\right|}{2} \]
      3. add-sqr-sqrt42.3%

        \[\leadsto x + \frac{\left|x \cdot \frac{y - x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right|}{2} \]
      4. associate-/r*42.4%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    5. Applied egg-rr42.4%

      \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    6. Step-by-step derivation
      1. div-inv42.4%

        \[\leadsto x + \color{blue}{\left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \frac{1}{2}} \]
      2. metadata-eval42.4%

        \[\leadsto x + \left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \color{blue}{0.5} \]
    7. Applied egg-rr70.6%

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

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

        \[\leadsto x - \color{blue}{\frac{x \cdot \left(y + x\right)}{x}} \cdot 0.5 \]
      3. *-commutative55.9%

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

        \[\leadsto x - \color{blue}{\left(\left(y + x\right) \cdot \frac{x}{x}\right)} \cdot 0.5 \]
      5. *-inverses85.3%

        \[\leadsto x - \left(\left(y + x\right) \cdot \color{blue}{1}\right) \cdot 0.5 \]
      6. *-rgt-identity85.3%

        \[\leadsto x - \color{blue}{\left(y + x\right)} \cdot 0.5 \]
      7. *-commutative85.3%

        \[\leadsto x - \color{blue}{0.5 \cdot \left(y + x\right)} \]
      8. +-commutative85.3%

        \[\leadsto x - 0.5 \cdot \color{blue}{\left(x + y\right)} \]
    9. Simplified85.3%

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

    if -1.10000000000000003e-195 < y < 1.60000000000000006e-88

    1. Initial program 99.8%

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

      \[\leadsto x + \frac{\left|\color{blue}{-1 \cdot x}\right|}{2} \]
    4. Step-by-step derivation
      1. neg-mul-193.6%

        \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    5. Simplified93.6%

      \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]

    if 1.60000000000000006e-88 < y

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt98.2%

        \[\leadsto x + \frac{\left|\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right) \cdot \sqrt[3]{y - x}}\right|}{2} \]
      2. fabs-mul98.2%

        \[\leadsto x + \frac{\color{blue}{\left|\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right| \cdot \left|\sqrt[3]{y - x}\right|}}{2} \]
      3. pow298.2%

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

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

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}}\right| \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
      2. fabs-sqr98.2%

        \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    6. Applied egg-rr98.2%

      \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    7. Step-by-step derivation
      1. unpow298.2%

        \[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    8. Simplified98.2%

      \[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt82.2%

        \[\leadsto x + \frac{{\left(\sqrt[3]{y - x}\right)}^{2} \cdot \left|\color{blue}{\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}}\right|}{2} \]
      2. fabs-sqr82.2%

        \[\leadsto x + \frac{{\left(\sqrt[3]{y - x}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}\right)}}{2} \]
      3. unpow282.2%

        \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left(\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}\right)}{2} \]
      4. add-sqr-sqrt85.1%

        \[\leadsto x + \frac{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right) \cdot \color{blue}{\sqrt[3]{y - x}}}{2} \]
      5. add-cube-cbrt86.7%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
      6. sub-neg86.7%

        \[\leadsto x + \frac{\color{blue}{y + \left(-x\right)}}{2} \]
      7. add-sqr-sqrt44.7%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{2} \]
      8. sqrt-unprod79.0%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{2} \]
      9. sqr-neg79.0%

        \[\leadsto x + \frac{y + \sqrt{\color{blue}{x \cdot x}}}{2} \]
      10. sqrt-unprod53.8%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{2} \]
      11. add-sqr-sqrt88.8%

        \[\leadsto x + \frac{y + \color{blue}{x}}{2} \]
      12. flip-+52.6%

        \[\leadsto x + \frac{\color{blue}{\frac{y \cdot y - x \cdot x}{y - x}}}{2} \]
      13. clear-num52.5%

        \[\leadsto x + \frac{\color{blue}{\frac{1}{\frac{y - x}{y \cdot y - x \cdot x}}}}{2} \]
      14. sub-neg52.5%

        \[\leadsto x + \frac{\frac{1}{\frac{\color{blue}{y + \left(-x\right)}}{y \cdot y - x \cdot x}}}{2} \]
      15. add-sqr-sqrt22.5%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{y \cdot y - x \cdot x}}}{2} \]
      16. sqrt-unprod50.8%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{y \cdot y - x \cdot x}}}{2} \]
      17. sqr-neg50.8%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \sqrt{\color{blue}{x \cdot x}}}{y \cdot y - x \cdot x}}}{2} \]
      18. sqrt-unprod28.7%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y \cdot y - x \cdot x}}}{2} \]
      19. add-sqr-sqrt54.8%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{x}}{y \cdot y - x \cdot x}}}{2} \]
      20. difference-of-squares54.9%

        \[\leadsto x + \frac{\frac{1}{\frac{y + x}{\color{blue}{\left(y + x\right) \cdot \left(y - x\right)}}}}{2} \]
      21. sub-neg54.9%

        \[\leadsto x + \frac{\frac{1}{\frac{y + x}{\left(y + x\right) \cdot \color{blue}{\left(y + \left(-x\right)\right)}}}}{2} \]
    10. Applied egg-rr52.9%

      \[\leadsto x + \frac{\color{blue}{\frac{1}{\frac{y + x}{{\left(y + x\right)}^{2}}}}}{2} \]
    11. Step-by-step derivation
      1. associate-/r/52.9%

        \[\leadsto x + \frac{\color{blue}{\frac{1}{y + x} \cdot {\left(y + x\right)}^{2}}}{2} \]
      2. *-commutative52.9%

        \[\leadsto x + \frac{\color{blue}{{\left(y + x\right)}^{2} \cdot \frac{1}{y + x}}}{2} \]
      3. +-commutative52.9%

        \[\leadsto x + \frac{{\color{blue}{\left(x + y\right)}}^{2} \cdot \frac{1}{y + x}}{2} \]
      4. +-commutative52.9%

        \[\leadsto x + \frac{{\left(x + y\right)}^{2} \cdot \frac{1}{\color{blue}{x + y}}}{2} \]
    12. Simplified52.9%

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

        \[\leadsto x + \color{blue}{{\left(x + y\right)}^{2} \cdot \frac{\frac{1}{x + y}}{2}} \]
      2. unpow252.9%

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

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

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

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

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

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

      \[\leadsto x + \color{blue}{\left(y + x\right) \cdot \left(\left(y + x\right) \cdot \frac{1}{2 \cdot \left(y + x\right)}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.6%

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

Alternative 3: 83.2% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{+14}:\\
\;\;\;\;x - 0.5 \cdot \left(x + y\right)\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-34}:\\
\;\;\;\;x + \frac{\left|y\right|}{2}\\

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


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

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{x \cdot \left(\frac{y}{x} - 1\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. *-inverses99.9%

        \[\leadsto x + \frac{\left|x \cdot \left(\frac{y}{x} - \color{blue}{\frac{x}{x}}\right)\right|}{2} \]
      2. div-sub99.9%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{y - x}{x}}\right|}{2} \]
      3. add-sqr-sqrt0.0%

        \[\leadsto x + \frac{\left|x \cdot \frac{y - x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right|}{2} \]
      4. associate-/r*0.0%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    5. Applied egg-rr0.0%

      \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    6. Step-by-step derivation
      1. div-inv0.0%

        \[\leadsto x + \color{blue}{\left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \frac{1}{2}} \]
      2. metadata-eval0.0%

        \[\leadsto x + \left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \color{blue}{0.5} \]
    7. Applied egg-rr92.1%

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

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

        \[\leadsto x - \color{blue}{\frac{x \cdot \left(y + x\right)}{x}} \cdot 0.5 \]
      3. *-commutative36.3%

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

        \[\leadsto x - \color{blue}{\left(\left(y + x\right) \cdot \frac{x}{x}\right)} \cdot 0.5 \]
      5. *-inverses92.1%

        \[\leadsto x - \left(\left(y + x\right) \cdot \color{blue}{1}\right) \cdot 0.5 \]
      6. *-rgt-identity92.1%

        \[\leadsto x - \color{blue}{\left(y + x\right)} \cdot 0.5 \]
      7. *-commutative92.1%

        \[\leadsto x - \color{blue}{0.5 \cdot \left(y + x\right)} \]
      8. +-commutative92.1%

        \[\leadsto x - 0.5 \cdot \color{blue}{\left(x + y\right)} \]
    9. Simplified92.1%

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

    if -1.75e14 < x < 6.1999999999999996e-34

    1. Initial program 100.0%

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

      \[\leadsto x + \frac{\left|\color{blue}{y}\right|}{2} \]

    if 6.1999999999999996e-34 < x

    1. Initial program 99.7%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt99.0%

        \[\leadsto x + \frac{\left|\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right) \cdot \sqrt[3]{y - x}}\right|}{2} \]
      2. fabs-mul99.0%

        \[\leadsto x + \frac{\color{blue}{\left|\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right| \cdot \left|\sqrt[3]{y - x}\right|}}{2} \]
      3. pow299.0%

        \[\leadsto x + \frac{\left|\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}}\right| \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    4. Applied egg-rr99.0%

      \[\leadsto x + \frac{\color{blue}{\left|{\left(\sqrt[3]{y - x}\right)}^{2}\right| \cdot \left|\sqrt[3]{y - x}\right|}}{2} \]
    5. Step-by-step derivation
      1. unpow299.0%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}}\right| \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
      2. fabs-sqr99.0%

        \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    6. Applied egg-rr99.0%

      \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    7. Step-by-step derivation
      1. unpow299.0%

        \[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    8. Simplified99.0%

      \[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt15.5%

        \[\leadsto x + \frac{{\left(\sqrt[3]{y - x}\right)}^{2} \cdot \left|\color{blue}{\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}}\right|}{2} \]
      2. fabs-sqr15.5%

        \[\leadsto x + \frac{{\left(\sqrt[3]{y - x}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}\right)}}{2} \]
      3. unpow215.5%

        \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left(\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}\right)}{2} \]
      4. add-sqr-sqrt28.0%

        \[\leadsto x + \frac{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right) \cdot \color{blue}{\sqrt[3]{y - x}}}{2} \]
      5. add-cube-cbrt28.2%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
      6. sub-neg28.2%

        \[\leadsto x + \frac{\color{blue}{y + \left(-x\right)}}{2} \]
      7. add-sqr-sqrt0.0%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{2} \]
      8. sqrt-unprod48.9%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{2} \]
      9. sqr-neg48.9%

        \[\leadsto x + \frac{y + \sqrt{\color{blue}{x \cdot x}}}{2} \]
      10. sqrt-unprod82.4%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{2} \]
      11. add-sqr-sqrt82.4%

        \[\leadsto x + \frac{y + \color{blue}{x}}{2} \]
      12. flip-+40.7%

        \[\leadsto x + \frac{\color{blue}{\frac{y \cdot y - x \cdot x}{y - x}}}{2} \]
      13. clear-num40.7%

        \[\leadsto x + \frac{\color{blue}{\frac{1}{\frac{y - x}{y \cdot y - x \cdot x}}}}{2} \]
      14. sub-neg40.7%

        \[\leadsto x + \frac{\frac{1}{\frac{\color{blue}{y + \left(-x\right)}}{y \cdot y - x \cdot x}}}{2} \]
      15. add-sqr-sqrt0.0%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{y \cdot y - x \cdot x}}}{2} \]
      16. sqrt-unprod14.2%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{y \cdot y - x \cdot x}}}{2} \]
      17. sqr-neg14.2%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \sqrt{\color{blue}{x \cdot x}}}{y \cdot y - x \cdot x}}}{2} \]
      18. sqrt-unprod14.2%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y \cdot y - x \cdot x}}}{2} \]
      19. add-sqr-sqrt14.2%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{x}}{y \cdot y - x \cdot x}}}{2} \]
      20. difference-of-squares14.2%

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

        \[\leadsto x + \frac{\frac{1}{\frac{y + x}{\left(y + x\right) \cdot \color{blue}{\left(y + \left(-x\right)\right)}}}}{2} \]
    10. Applied egg-rr41.1%

      \[\leadsto x + \frac{\color{blue}{\frac{1}{\frac{y + x}{{\left(y + x\right)}^{2}}}}}{2} \]
    11. Step-by-step derivation
      1. associate-/r/41.1%

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

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

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

        \[\leadsto x + \frac{{\left(x + y\right)}^{2} \cdot \frac{1}{\color{blue}{x + y}}}{2} \]
    12. Simplified41.1%

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

        \[\leadsto x + \color{blue}{{\left(x + y\right)}^{2} \cdot \frac{\frac{1}{x + y}}{2}} \]
      2. unpow241.1%

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

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

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

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

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

        \[\leadsto x + \left(y + x\right) \cdot \left(\left(y + x\right) \cdot \frac{1}{2 \cdot \color{blue}{\left(y + x\right)}}\right) \]
    14. Applied egg-rr82.4%

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

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

Alternative 4: 82.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-70}:\\
\;\;\;\;x - 0.5 \cdot \left(x + y\right)\\

\mathbf{elif}\;x \leq 1.35 \cdot 10^{-31}:\\
\;\;\;\;0.5 \cdot \left|y\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.44999999999999986e-70

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{x \cdot \left(\frac{y}{x} - 1\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. *-inverses98.7%

        \[\leadsto x + \frac{\left|x \cdot \left(\frac{y}{x} - \color{blue}{\frac{x}{x}}\right)\right|}{2} \]
      2. div-sub98.7%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{y - x}{x}}\right|}{2} \]
      3. add-sqr-sqrt0.0%

        \[\leadsto x + \frac{\left|x \cdot \frac{y - x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right|}{2} \]
      4. associate-/r*0.0%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    5. Applied egg-rr0.0%

      \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    6. Step-by-step derivation
      1. div-inv0.0%

        \[\leadsto x + \color{blue}{\left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \frac{1}{2}} \]
      2. metadata-eval0.0%

        \[\leadsto x + \left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \color{blue}{0.5} \]
    7. Applied egg-rr86.7%

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

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

        \[\leadsto x - \color{blue}{\frac{x \cdot \left(y + x\right)}{x}} \cdot 0.5 \]
      3. *-commutative42.1%

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

        \[\leadsto x - \color{blue}{\left(\left(y + x\right) \cdot \frac{x}{x}\right)} \cdot 0.5 \]
      5. *-inverses86.7%

        \[\leadsto x - \left(\left(y + x\right) \cdot \color{blue}{1}\right) \cdot 0.5 \]
      6. *-rgt-identity86.7%

        \[\leadsto x - \color{blue}{\left(y + x\right)} \cdot 0.5 \]
      7. *-commutative86.7%

        \[\leadsto x - \color{blue}{0.5 \cdot \left(y + x\right)} \]
      8. +-commutative86.7%

        \[\leadsto x - 0.5 \cdot \color{blue}{\left(x + y\right)} \]
    9. Simplified86.7%

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

    if -1.44999999999999986e-70 < x < 1.35000000000000007e-31

    1. Initial program 100.0%

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

      \[\leadsto x + \frac{\left|\color{blue}{y}\right|}{2} \]
    4. Taylor expanded in x around 0 84.4%

      \[\leadsto \color{blue}{0.5 \cdot \left|y\right|} \]

    if 1.35000000000000007e-31 < x

    1. Initial program 99.7%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt99.0%

        \[\leadsto x + \frac{\left|\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right) \cdot \sqrt[3]{y - x}}\right|}{2} \]
      2. fabs-mul99.0%

        \[\leadsto x + \frac{\color{blue}{\left|\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right| \cdot \left|\sqrt[3]{y - x}\right|}}{2} \]
      3. pow299.0%

        \[\leadsto x + \frac{\left|\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}}\right| \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    4. Applied egg-rr99.0%

      \[\leadsto x + \frac{\color{blue}{\left|{\left(\sqrt[3]{y - x}\right)}^{2}\right| \cdot \left|\sqrt[3]{y - x}\right|}}{2} \]
    5. Step-by-step derivation
      1. unpow299.0%

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}}\right| \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
      2. fabs-sqr99.0%

        \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    6. Applied egg-rr99.0%

      \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    7. Step-by-step derivation
      1. unpow299.0%

        \[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    8. Simplified99.0%

      \[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt15.5%

        \[\leadsto x + \frac{{\left(\sqrt[3]{y - x}\right)}^{2} \cdot \left|\color{blue}{\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}}\right|}{2} \]
      2. fabs-sqr15.5%

        \[\leadsto x + \frac{{\left(\sqrt[3]{y - x}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}\right)}}{2} \]
      3. unpow215.5%

        \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left(\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}\right)}{2} \]
      4. add-sqr-sqrt28.0%

        \[\leadsto x + \frac{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right) \cdot \color{blue}{\sqrt[3]{y - x}}}{2} \]
      5. add-cube-cbrt28.2%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
      6. sub-neg28.2%

        \[\leadsto x + \frac{\color{blue}{y + \left(-x\right)}}{2} \]
      7. add-sqr-sqrt0.0%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{2} \]
      8. sqrt-unprod48.9%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{2} \]
      9. sqr-neg48.9%

        \[\leadsto x + \frac{y + \sqrt{\color{blue}{x \cdot x}}}{2} \]
      10. sqrt-unprod82.4%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{2} \]
      11. add-sqr-sqrt82.4%

        \[\leadsto x + \frac{y + \color{blue}{x}}{2} \]
      12. flip-+40.7%

        \[\leadsto x + \frac{\color{blue}{\frac{y \cdot y - x \cdot x}{y - x}}}{2} \]
      13. clear-num40.7%

        \[\leadsto x + \frac{\color{blue}{\frac{1}{\frac{y - x}{y \cdot y - x \cdot x}}}}{2} \]
      14. sub-neg40.7%

        \[\leadsto x + \frac{\frac{1}{\frac{\color{blue}{y + \left(-x\right)}}{y \cdot y - x \cdot x}}}{2} \]
      15. add-sqr-sqrt0.0%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{y \cdot y - x \cdot x}}}{2} \]
      16. sqrt-unprod14.2%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{y \cdot y - x \cdot x}}}{2} \]
      17. sqr-neg14.2%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \sqrt{\color{blue}{x \cdot x}}}{y \cdot y - x \cdot x}}}{2} \]
      18. sqrt-unprod14.2%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y \cdot y - x \cdot x}}}{2} \]
      19. add-sqr-sqrt14.2%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{x}}{y \cdot y - x \cdot x}}}{2} \]
      20. difference-of-squares14.2%

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

        \[\leadsto x + \frac{\frac{1}{\frac{y + x}{\left(y + x\right) \cdot \color{blue}{\left(y + \left(-x\right)\right)}}}}{2} \]
    10. Applied egg-rr41.1%

      \[\leadsto x + \frac{\color{blue}{\frac{1}{\frac{y + x}{{\left(y + x\right)}^{2}}}}}{2} \]
    11. Step-by-step derivation
      1. associate-/r/41.1%

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

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

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

        \[\leadsto x + \frac{{\left(x + y\right)}^{2} \cdot \frac{1}{\color{blue}{x + y}}}{2} \]
    12. Simplified41.1%

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

        \[\leadsto x + \color{blue}{{\left(x + y\right)}^{2} \cdot \frac{\frac{1}{x + y}}{2}} \]
      2. unpow241.1%

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

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

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

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

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

        \[\leadsto x + \left(y + x\right) \cdot \left(\left(y + x\right) \cdot \frac{1}{2 \cdot \color{blue}{\left(y + x\right)}}\right) \]
    14. Applied egg-rr82.4%

      \[\leadsto x + \color{blue}{\left(y + x\right) \cdot \left(\left(y + x\right) \cdot \frac{1}{2 \cdot \left(y + x\right)}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification84.5%

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

Alternative 5: 77.1% accurate, 4.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{-208}:\\
\;\;\;\;x - 0.5 \cdot \left(x + y\right)\\

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


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

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{x \cdot \left(\frac{y}{x} - 1\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. *-inverses85.5%

        \[\leadsto x + \frac{\left|x \cdot \left(\frac{y}{x} - \color{blue}{\frac{x}{x}}\right)\right|}{2} \]
      2. div-sub85.5%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{y - x}{x}}\right|}{2} \]
      3. add-sqr-sqrt41.5%

        \[\leadsto x + \frac{\left|x \cdot \frac{y - x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right|}{2} \]
      4. associate-/r*41.6%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    5. Applied egg-rr41.6%

      \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    6. Step-by-step derivation
      1. div-inv41.6%

        \[\leadsto x + \color{blue}{\left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \frac{1}{2}} \]
      2. metadata-eval41.6%

        \[\leadsto x + \left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \color{blue}{0.5} \]
    7. Applied egg-rr71.1%

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

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

        \[\leadsto x - \color{blue}{\frac{x \cdot \left(y + x\right)}{x}} \cdot 0.5 \]
      3. *-commutative56.8%

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

        \[\leadsto x - \color{blue}{\left(\left(y + x\right) \cdot \frac{x}{x}\right)} \cdot 0.5 \]
      5. *-inverses85.6%

        \[\leadsto x - \left(\left(y + x\right) \cdot \color{blue}{1}\right) \cdot 0.5 \]
      6. *-rgt-identity85.6%

        \[\leadsto x - \color{blue}{\left(y + x\right)} \cdot 0.5 \]
      7. *-commutative85.6%

        \[\leadsto x - \color{blue}{0.5 \cdot \left(y + x\right)} \]
      8. +-commutative85.6%

        \[\leadsto x - 0.5 \cdot \color{blue}{\left(x + y\right)} \]
    9. Simplified85.6%

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

    if -8.9999999999999992e-208 < y

    1. Initial program 99.8%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt98.3%

        \[\leadsto x + \frac{\left|\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right) \cdot \sqrt[3]{y - x}}\right|}{2} \]
      2. fabs-mul98.3%

        \[\leadsto x + \frac{\color{blue}{\left|\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right| \cdot \left|\sqrt[3]{y - x}\right|}}{2} \]
      3. pow298.3%

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

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

        \[\leadsto x + \frac{\left|\color{blue}{\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}}\right| \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
      2. fabs-sqr98.3%

        \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    6. Applied egg-rr98.3%

      \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    7. Step-by-step derivation
      1. unpow298.3%

        \[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    8. Simplified98.3%

      \[\leadsto x + \frac{\color{blue}{{\left(\sqrt[3]{y - x}\right)}^{2}} \cdot \left|\sqrt[3]{y - x}\right|}{2} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt65.7%

        \[\leadsto x + \frac{{\left(\sqrt[3]{y - x}\right)}^{2} \cdot \left|\color{blue}{\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}}\right|}{2} \]
      2. fabs-sqr65.7%

        \[\leadsto x + \frac{{\left(\sqrt[3]{y - x}\right)}^{2} \cdot \color{blue}{\left(\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}\right)}}{2} \]
      3. unpow265.7%

        \[\leadsto x + \frac{\color{blue}{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right)} \cdot \left(\sqrt{\sqrt[3]{y - x}} \cdot \sqrt{\sqrt[3]{y - x}}\right)}{2} \]
      4. add-sqr-sqrt71.4%

        \[\leadsto x + \frac{\left(\sqrt[3]{y - x} \cdot \sqrt[3]{y - x}\right) \cdot \color{blue}{\sqrt[3]{y - x}}}{2} \]
      5. add-cube-cbrt72.7%

        \[\leadsto x + \frac{\color{blue}{y - x}}{2} \]
      6. sub-neg72.7%

        \[\leadsto x + \frac{\color{blue}{y + \left(-x\right)}}{2} \]
      7. add-sqr-sqrt43.9%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{2} \]
      8. sqrt-unprod70.3%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{2} \]
      9. sqr-neg70.3%

        \[\leadsto x + \frac{y + \sqrt{\color{blue}{x \cdot x}}}{2} \]
      10. sqrt-unprod53.4%

        \[\leadsto x + \frac{y + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{2} \]
      11. add-sqr-sqrt77.3%

        \[\leadsto x + \frac{y + \color{blue}{x}}{2} \]
      12. flip-+48.2%

        \[\leadsto x + \frac{\color{blue}{\frac{y \cdot y - x \cdot x}{y - x}}}{2} \]
      13. clear-num48.1%

        \[\leadsto x + \frac{\color{blue}{\frac{1}{\frac{y - x}{y \cdot y - x \cdot x}}}}{2} \]
      14. sub-neg48.1%

        \[\leadsto x + \frac{\frac{1}{\frac{\color{blue}{y + \left(-x\right)}}{y \cdot y - x \cdot x}}}{2} \]
      15. add-sqr-sqrt15.3%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{y \cdot y - x \cdot x}}}{2} \]
      16. sqrt-unprod34.9%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{y \cdot y - x \cdot x}}}{2} \]
      17. sqr-neg34.9%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \sqrt{\color{blue}{x \cdot x}}}{y \cdot y - x \cdot x}}}{2} \]
      18. sqrt-unprod20.4%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{y \cdot y - x \cdot x}}}{2} \]
      19. add-sqr-sqrt44.2%

        \[\leadsto x + \frac{\frac{1}{\frac{y + \color{blue}{x}}{y \cdot y - x \cdot x}}}{2} \]
      20. difference-of-squares44.2%

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

        \[\leadsto x + \frac{\frac{1}{\frac{y + x}{\left(y + x\right) \cdot \color{blue}{\left(y + \left(-x\right)\right)}}}}{2} \]
    10. Applied egg-rr48.3%

      \[\leadsto x + \frac{\color{blue}{\frac{1}{\frac{y + x}{{\left(y + x\right)}^{2}}}}}{2} \]
    11. Step-by-step derivation
      1. associate-/r/48.4%

        \[\leadsto x + \frac{\color{blue}{\frac{1}{y + x} \cdot {\left(y + x\right)}^{2}}}{2} \]
      2. *-commutative48.4%

        \[\leadsto x + \frac{\color{blue}{{\left(y + x\right)}^{2} \cdot \frac{1}{y + x}}}{2} \]
      3. +-commutative48.4%

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

        \[\leadsto x + \frac{{\left(x + y\right)}^{2} \cdot \frac{1}{\color{blue}{x + y}}}{2} \]
    12. Simplified48.4%

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

        \[\leadsto x + \color{blue}{{\left(x + y\right)}^{2} \cdot \frac{\frac{1}{x + y}}{2}} \]
      2. unpow248.4%

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

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

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

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

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

        \[\leadsto x + \left(y + x\right) \cdot \left(\left(y + x\right) \cdot \frac{1}{2 \cdot \color{blue}{\left(y + x\right)}}\right) \]
    14. Applied egg-rr77.2%

      \[\leadsto x + \color{blue}{\left(y + x\right) \cdot \left(\left(y + x\right) \cdot \frac{1}{2 \cdot \left(y + x\right)}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.6%

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

Alternative 6: 78.3% accurate, 7.1× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(x + y\right)\\
\mathbf{if}\;y \leq -4 \cdot 10^{-208}:\\
\;\;\;\;x - t\_0\\

\mathbf{elif}\;y \leq 7.4 \cdot 10^{-245}:\\
\;\;\;\;x \cdot 1.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.0000000000000004e-208

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{x \cdot \left(\frac{y}{x} - 1\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. *-inverses85.5%

        \[\leadsto x + \frac{\left|x \cdot \left(\frac{y}{x} - \color{blue}{\frac{x}{x}}\right)\right|}{2} \]
      2. div-sub85.5%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{y - x}{x}}\right|}{2} \]
      3. add-sqr-sqrt41.5%

        \[\leadsto x + \frac{\left|x \cdot \frac{y - x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right|}{2} \]
      4. associate-/r*41.6%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    5. Applied egg-rr41.6%

      \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    6. Step-by-step derivation
      1. div-inv41.6%

        \[\leadsto x + \color{blue}{\left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \frac{1}{2}} \]
      2. metadata-eval41.6%

        \[\leadsto x + \left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \color{blue}{0.5} \]
    7. Applied egg-rr71.1%

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

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

        \[\leadsto x - \color{blue}{\frac{x \cdot \left(y + x\right)}{x}} \cdot 0.5 \]
      3. *-commutative56.8%

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

        \[\leadsto x - \color{blue}{\left(\left(y + x\right) \cdot \frac{x}{x}\right)} \cdot 0.5 \]
      5. *-inverses85.6%

        \[\leadsto x - \left(\left(y + x\right) \cdot \color{blue}{1}\right) \cdot 0.5 \]
      6. *-rgt-identity85.6%

        \[\leadsto x - \color{blue}{\left(y + x\right)} \cdot 0.5 \]
      7. *-commutative85.6%

        \[\leadsto x - \color{blue}{0.5 \cdot \left(y + x\right)} \]
      8. +-commutative85.6%

        \[\leadsto x - 0.5 \cdot \color{blue}{\left(x + y\right)} \]
    9. Simplified85.6%

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

    if -4.0000000000000004e-208 < y < 7.4000000000000005e-245

    1. Initial program 99.8%

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

      \[\leadsto x + \frac{\left|\color{blue}{-1 \cdot x}\right|}{2} \]
    4. Step-by-step derivation
      1. neg-mul-191.6%

        \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    5. Simplified91.6%

      \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    6. Taylor expanded in x around 0 91.6%

      \[\leadsto \color{blue}{x + 0.5 \cdot \left|-x\right|} \]
    7. Step-by-step derivation
      1. *-rgt-identity91.6%

        \[\leadsto \color{blue}{x \cdot 1} + 0.5 \cdot \left|-x\right| \]
      2. *-commutative91.6%

        \[\leadsto x \cdot 1 + \color{blue}{\left|-x\right| \cdot 0.5} \]
      3. fabs-neg91.6%

        \[\leadsto x \cdot 1 + \color{blue}{\left|x\right|} \cdot 0.5 \]
      4. rem-square-sqrt66.2%

        \[\leadsto x \cdot 1 + \left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| \cdot 0.5 \]
      5. fabs-sqr66.2%

        \[\leadsto x \cdot 1 + \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot 0.5 \]
      6. rem-square-sqrt71.0%

        \[\leadsto x \cdot 1 + \color{blue}{x} \cdot 0.5 \]
      7. metadata-eval71.0%

        \[\leadsto x \cdot 1 + x \cdot \color{blue}{\left(0.5 \cdot 1\right)} \]
      8. *-inverses71.0%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \color{blue}{\frac{x}{x}}\right) \]
      9. rem-square-sqrt66.2%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      10. fabs-sqr66.2%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|\sqrt{x} \cdot \sqrt{x}\right|}}{x}\right) \]
      11. rem-square-sqrt91.6%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{x}\right|}{x}\right) \]
      12. fabs-neg91.6%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|-x\right|}}{x}\right) \]
      13. distribute-lft-in91.6%

        \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|-x\right|}{x}\right)} \]
      14. fabs-neg91.6%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\left|x\right|}}{x}\right) \]
      15. rem-square-sqrt66.3%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{x}\right) \]
      16. fabs-sqr66.3%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      17. rem-square-sqrt71.0%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{x}}{x}\right) \]
      18. *-inverses71.0%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \color{blue}{1}\right) \]
      19. metadata-eval71.0%

        \[\leadsto x \cdot \left(1 + \color{blue}{0.5}\right) \]
      20. metadata-eval71.0%

        \[\leadsto x \cdot \color{blue}{1.5} \]
    8. Simplified71.0%

      \[\leadsto \color{blue}{x \cdot 1.5} \]

    if 7.4000000000000005e-245 < y

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|y - x\right|}{x}\right)} \]
    4. Step-by-step derivation
      1. +-commutative84.7%

        \[\leadsto x \cdot \color{blue}{\left(0.5 \cdot \frac{\left|y - x\right|}{x} + 1\right)} \]
      2. sub-neg84.7%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{y + \left(-x\right)}\right|}{x} + 1\right) \]
      3. neg-mul-184.7%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|y + \color{blue}{-1 \cdot x}\right|}{x} + 1\right) \]
      4. fma-define84.7%

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{\left|y + -1 \cdot x\right|}{x}, 1\right)} \]
      5. neg-mul-184.7%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{x}, 1\right) \]
      6. sub-neg84.7%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{y - x}\right|}{x}, 1\right) \]
      7. rem-square-sqrt60.9%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{x}, 1\right) \]
      8. fabs-sqr60.9%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{x}, 1\right) \]
      9. rem-square-sqrt65.6%

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

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(0.5, \frac{y - x}{x}, 1\right)} \]
    6. Taylor expanded in x around 0 80.8%

      \[\leadsto \color{blue}{0.5 \cdot x + 0.5 \cdot y} \]
    7. Step-by-step derivation
      1. distribute-lft-out80.8%

        \[\leadsto \color{blue}{0.5 \cdot \left(x + y\right)} \]
      2. +-commutative80.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(y + x\right)} \]
    8. Simplified80.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{-208}:\\ \;\;\;\;x - 0.5 \cdot \left(x + y\right)\\ \mathbf{elif}\;y \leq 7.4 \cdot 10^{-245}:\\ \;\;\;\;x \cdot 1.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 71.5% accurate, 7.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{-207}:\\ \;\;\;\;x - y \cdot 0.5\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-256}:\\ \;\;\;\;x \cdot 1.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.5e-207)
   (- x (* y 0.5))
   (if (<= y 1.2e-256) (* x 1.5) (* 0.5 (+ x y)))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.5e-207) {
		tmp = x - (y * 0.5);
	} else if (y <= 1.2e-256) {
		tmp = x * 1.5;
	} else {
		tmp = 0.5 * (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.5d-207)) then
        tmp = x - (y * 0.5d0)
    else if (y <= 1.2d-256) then
        tmp = x * 1.5d0
    else
        tmp = 0.5d0 * (x + y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.5e-207) {
		tmp = x - (y * 0.5);
	} else if (y <= 1.2e-256) {
		tmp = x * 1.5;
	} else {
		tmp = 0.5 * (x + y);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.5e-207:
		tmp = x - (y * 0.5)
	elif y <= 1.2e-256:
		tmp = x * 1.5
	else:
		tmp = 0.5 * (x + y)
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.5e-207)
		tmp = Float64(x - Float64(y * 0.5));
	elseif (y <= 1.2e-256)
		tmp = Float64(x * 1.5);
	else
		tmp = Float64(0.5 * Float64(x + y));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -2.5e-207)
		tmp = x - (y * 0.5);
	elseif (y <= 1.2e-256)
		tmp = x * 1.5;
	else
		tmp = 0.5 * (x + y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.5e-207], N[(x - N[(y * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.2e-256], N[(x * 1.5), $MachinePrecision], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{-207}:\\
\;\;\;\;x - y \cdot 0.5\\

\mathbf{elif}\;y \leq 1.2 \cdot 10^{-256}:\\
\;\;\;\;x \cdot 1.5\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.50000000000000007e-207

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{x \cdot \left(\frac{y}{x} - 1\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. *-inverses85.5%

        \[\leadsto x + \frac{\left|x \cdot \left(\frac{y}{x} - \color{blue}{\frac{x}{x}}\right)\right|}{2} \]
      2. div-sub85.5%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{y - x}{x}}\right|}{2} \]
      3. add-sqr-sqrt41.5%

        \[\leadsto x + \frac{\left|x \cdot \frac{y - x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right|}{2} \]
      4. associate-/r*41.6%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    5. Applied egg-rr41.6%

      \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    6. Step-by-step derivation
      1. div-inv41.6%

        \[\leadsto x + \color{blue}{\left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \frac{1}{2}} \]
      2. metadata-eval41.6%

        \[\leadsto x + \left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \color{blue}{0.5} \]
    7. Applied egg-rr71.1%

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

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

        \[\leadsto x - \color{blue}{\frac{x \cdot \left(y + x\right)}{x}} \cdot 0.5 \]
      3. *-commutative56.8%

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

        \[\leadsto x - \color{blue}{\left(\left(y + x\right) \cdot \frac{x}{x}\right)} \cdot 0.5 \]
      5. *-inverses85.6%

        \[\leadsto x - \left(\left(y + x\right) \cdot \color{blue}{1}\right) \cdot 0.5 \]
      6. *-rgt-identity85.6%

        \[\leadsto x - \color{blue}{\left(y + x\right)} \cdot 0.5 \]
      7. *-commutative85.6%

        \[\leadsto x - \color{blue}{0.5 \cdot \left(y + x\right)} \]
      8. +-commutative85.6%

        \[\leadsto x - 0.5 \cdot \color{blue}{\left(x + y\right)} \]
    9. Simplified85.6%

      \[\leadsto \color{blue}{x - 0.5 \cdot \left(x + y\right)} \]
    10. Taylor expanded in x around 0 70.2%

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

    if -2.50000000000000007e-207 < y < 1.2e-256

    1. Initial program 99.8%

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

      \[\leadsto x + \frac{\left|\color{blue}{-1 \cdot x}\right|}{2} \]
    4. Step-by-step derivation
      1. neg-mul-191.6%

        \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    5. Simplified91.6%

      \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    6. Taylor expanded in x around 0 91.6%

      \[\leadsto \color{blue}{x + 0.5 \cdot \left|-x\right|} \]
    7. Step-by-step derivation
      1. *-rgt-identity91.6%

        \[\leadsto \color{blue}{x \cdot 1} + 0.5 \cdot \left|-x\right| \]
      2. *-commutative91.6%

        \[\leadsto x \cdot 1 + \color{blue}{\left|-x\right| \cdot 0.5} \]
      3. fabs-neg91.6%

        \[\leadsto x \cdot 1 + \color{blue}{\left|x\right|} \cdot 0.5 \]
      4. rem-square-sqrt66.2%

        \[\leadsto x \cdot 1 + \left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| \cdot 0.5 \]
      5. fabs-sqr66.2%

        \[\leadsto x \cdot 1 + \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot 0.5 \]
      6. rem-square-sqrt71.0%

        \[\leadsto x \cdot 1 + \color{blue}{x} \cdot 0.5 \]
      7. metadata-eval71.0%

        \[\leadsto x \cdot 1 + x \cdot \color{blue}{\left(0.5 \cdot 1\right)} \]
      8. *-inverses71.0%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \color{blue}{\frac{x}{x}}\right) \]
      9. rem-square-sqrt66.2%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      10. fabs-sqr66.2%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|\sqrt{x} \cdot \sqrt{x}\right|}}{x}\right) \]
      11. rem-square-sqrt91.6%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{x}\right|}{x}\right) \]
      12. fabs-neg91.6%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|-x\right|}}{x}\right) \]
      13. distribute-lft-in91.6%

        \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|-x\right|}{x}\right)} \]
      14. fabs-neg91.6%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\left|x\right|}}{x}\right) \]
      15. rem-square-sqrt66.3%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{x}\right) \]
      16. fabs-sqr66.3%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      17. rem-square-sqrt71.0%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{x}}{x}\right) \]
      18. *-inverses71.0%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \color{blue}{1}\right) \]
      19. metadata-eval71.0%

        \[\leadsto x \cdot \left(1 + \color{blue}{0.5}\right) \]
      20. metadata-eval71.0%

        \[\leadsto x \cdot \color{blue}{1.5} \]
    8. Simplified71.0%

      \[\leadsto \color{blue}{x \cdot 1.5} \]

    if 1.2e-256 < y

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|y - x\right|}{x}\right)} \]
    4. Step-by-step derivation
      1. +-commutative84.7%

        \[\leadsto x \cdot \color{blue}{\left(0.5 \cdot \frac{\left|y - x\right|}{x} + 1\right)} \]
      2. sub-neg84.7%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{y + \left(-x\right)}\right|}{x} + 1\right) \]
      3. neg-mul-184.7%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|y + \color{blue}{-1 \cdot x}\right|}{x} + 1\right) \]
      4. fma-define84.7%

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{\left|y + -1 \cdot x\right|}{x}, 1\right)} \]
      5. neg-mul-184.7%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{x}, 1\right) \]
      6. sub-neg84.7%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{y - x}\right|}{x}, 1\right) \]
      7. rem-square-sqrt60.9%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{x}, 1\right) \]
      8. fabs-sqr60.9%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{x}, 1\right) \]
      9. rem-square-sqrt65.6%

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

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(0.5, \frac{y - x}{x}, 1\right)} \]
    6. Taylor expanded in x around 0 80.8%

      \[\leadsto \color{blue}{0.5 \cdot x + 0.5 \cdot y} \]
    7. Step-by-step derivation
      1. distribute-lft-out80.8%

        \[\leadsto \color{blue}{0.5 \cdot \left(x + y\right)} \]
      2. +-commutative80.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(y + x\right)} \]
    8. Simplified80.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification75.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{-207}:\\ \;\;\;\;x - y \cdot 0.5\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-256}:\\ \;\;\;\;x \cdot 1.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 68.9% accurate, 7.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{-195}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 10^{-249}:\\
\;\;\;\;x \cdot 1.5\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x + y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.3e-195

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{x \cdot \left(\frac{y}{x} - 1\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. *-inverses85.2%

        \[\leadsto x + \frac{\left|x \cdot \left(\frac{y}{x} - \color{blue}{\frac{x}{x}}\right)\right|}{2} \]
      2. div-sub85.2%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{y - x}{x}}\right|}{2} \]
      3. add-sqr-sqrt42.3%

        \[\leadsto x + \frac{\left|x \cdot \frac{y - x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right|}{2} \]
      4. associate-/r*42.4%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    5. Applied egg-rr42.4%

      \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    6. Step-by-step derivation
      1. div-inv42.4%

        \[\leadsto x + \color{blue}{\left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \frac{1}{2}} \]
      2. metadata-eval42.4%

        \[\leadsto x + \left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \color{blue}{0.5} \]
    7. Applied egg-rr70.6%

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

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

        \[\leadsto x - \color{blue}{\frac{x \cdot \left(y + x\right)}{x}} \cdot 0.5 \]
      3. *-commutative55.9%

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

        \[\leadsto x - \color{blue}{\left(\left(y + x\right) \cdot \frac{x}{x}\right)} \cdot 0.5 \]
      5. *-inverses85.3%

        \[\leadsto x - \left(\left(y + x\right) \cdot \color{blue}{1}\right) \cdot 0.5 \]
      6. *-rgt-identity85.3%

        \[\leadsto x - \color{blue}{\left(y + x\right)} \cdot 0.5 \]
      7. *-commutative85.3%

        \[\leadsto x - \color{blue}{0.5 \cdot \left(y + x\right)} \]
      8. +-commutative85.3%

        \[\leadsto x - 0.5 \cdot \color{blue}{\left(x + y\right)} \]
    9. Simplified85.3%

      \[\leadsto \color{blue}{x - 0.5 \cdot \left(x + y\right)} \]
    10. Taylor expanded in x around 0 65.6%

      \[\leadsto \color{blue}{-0.5 \cdot y} \]
    11. Step-by-step derivation
      1. *-commutative65.6%

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    12. Simplified65.6%

      \[\leadsto \color{blue}{y \cdot -0.5} \]

    if -3.3e-195 < y < 1.00000000000000005e-249

    1. Initial program 99.8%

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

      \[\leadsto x + \frac{\left|\color{blue}{-1 \cdot x}\right|}{2} \]
    4. Step-by-step derivation
      1. neg-mul-192.1%

        \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    5. Simplified92.1%

      \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    6. Taylor expanded in x around 0 92.1%

      \[\leadsto \color{blue}{x + 0.5 \cdot \left|-x\right|} \]
    7. Step-by-step derivation
      1. *-rgt-identity92.1%

        \[\leadsto \color{blue}{x \cdot 1} + 0.5 \cdot \left|-x\right| \]
      2. *-commutative92.1%

        \[\leadsto x \cdot 1 + \color{blue}{\left|-x\right| \cdot 0.5} \]
      3. fabs-neg92.1%

        \[\leadsto x \cdot 1 + \color{blue}{\left|x\right|} \cdot 0.5 \]
      4. rem-square-sqrt61.8%

        \[\leadsto x \cdot 1 + \left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| \cdot 0.5 \]
      5. fabs-sqr61.8%

        \[\leadsto x \cdot 1 + \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot 0.5 \]
      6. rem-square-sqrt67.4%

        \[\leadsto x \cdot 1 + \color{blue}{x} \cdot 0.5 \]
      7. metadata-eval67.4%

        \[\leadsto x \cdot 1 + x \cdot \color{blue}{\left(0.5 \cdot 1\right)} \]
      8. *-inverses67.4%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \color{blue}{\frac{x}{x}}\right) \]
      9. rem-square-sqrt61.8%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      10. fabs-sqr61.8%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|\sqrt{x} \cdot \sqrt{x}\right|}}{x}\right) \]
      11. rem-square-sqrt92.1%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{x}\right|}{x}\right) \]
      12. fabs-neg92.1%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|-x\right|}}{x}\right) \]
      13. distribute-lft-in92.1%

        \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|-x\right|}{x}\right)} \]
      14. fabs-neg92.1%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\left|x\right|}}{x}\right) \]
      15. rem-square-sqrt61.9%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{x}\right) \]
      16. fabs-sqr61.9%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      17. rem-square-sqrt67.4%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{x}}{x}\right) \]
      18. *-inverses67.4%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \color{blue}{1}\right) \]
      19. metadata-eval67.4%

        \[\leadsto x \cdot \left(1 + \color{blue}{0.5}\right) \]
      20. metadata-eval67.4%

        \[\leadsto x \cdot \color{blue}{1.5} \]
    8. Simplified67.4%

      \[\leadsto \color{blue}{x \cdot 1.5} \]

    if 1.00000000000000005e-249 < y

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|y - x\right|}{x}\right)} \]
    4. Step-by-step derivation
      1. +-commutative84.7%

        \[\leadsto x \cdot \color{blue}{\left(0.5 \cdot \frac{\left|y - x\right|}{x} + 1\right)} \]
      2. sub-neg84.7%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{y + \left(-x\right)}\right|}{x} + 1\right) \]
      3. neg-mul-184.7%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|y + \color{blue}{-1 \cdot x}\right|}{x} + 1\right) \]
      4. fma-define84.7%

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{\left|y + -1 \cdot x\right|}{x}, 1\right)} \]
      5. neg-mul-184.7%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{x}, 1\right) \]
      6. sub-neg84.7%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{y - x}\right|}{x}, 1\right) \]
      7. rem-square-sqrt60.9%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{x}, 1\right) \]
      8. fabs-sqr60.9%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{x}, 1\right) \]
      9. rem-square-sqrt65.6%

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

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(0.5, \frac{y - x}{x}, 1\right)} \]
    6. Taylor expanded in x around 0 80.8%

      \[\leadsto \color{blue}{0.5 \cdot x + 0.5 \cdot y} \]
    7. Step-by-step derivation
      1. distribute-lft-out80.8%

        \[\leadsto \color{blue}{0.5 \cdot \left(x + y\right)} \]
      2. +-commutative80.8%

        \[\leadsto 0.5 \cdot \color{blue}{\left(y + x\right)} \]
    8. Simplified80.8%

      \[\leadsto \color{blue}{0.5 \cdot \left(y + x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification73.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-195}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 10^{-249}:\\ \;\;\;\;x \cdot 1.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 59.1% accurate, 8.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{-195}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq 6.9 \cdot 10^{-77}:\\
\;\;\;\;x \cdot 1.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.3e-195

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{x \cdot \left(\frac{y}{x} - 1\right)}\right|}{2} \]
    4. Step-by-step derivation
      1. *-inverses85.2%

        \[\leadsto x + \frac{\left|x \cdot \left(\frac{y}{x} - \color{blue}{\frac{x}{x}}\right)\right|}{2} \]
      2. div-sub85.2%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{y - x}{x}}\right|}{2} \]
      3. add-sqr-sqrt42.3%

        \[\leadsto x + \frac{\left|x \cdot \frac{y - x}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right|}{2} \]
      4. associate-/r*42.4%

        \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    5. Applied egg-rr42.4%

      \[\leadsto x + \frac{\left|x \cdot \color{blue}{\frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}}\right|}{2} \]
    6. Step-by-step derivation
      1. div-inv42.4%

        \[\leadsto x + \color{blue}{\left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \frac{1}{2}} \]
      2. metadata-eval42.4%

        \[\leadsto x + \left|x \cdot \frac{\frac{y - x}{\sqrt{x}}}{\sqrt{x}}\right| \cdot \color{blue}{0.5} \]
    7. Applied egg-rr70.6%

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

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

        \[\leadsto x - \color{blue}{\frac{x \cdot \left(y + x\right)}{x}} \cdot 0.5 \]
      3. *-commutative55.9%

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

        \[\leadsto x - \color{blue}{\left(\left(y + x\right) \cdot \frac{x}{x}\right)} \cdot 0.5 \]
      5. *-inverses85.3%

        \[\leadsto x - \left(\left(y + x\right) \cdot \color{blue}{1}\right) \cdot 0.5 \]
      6. *-rgt-identity85.3%

        \[\leadsto x - \color{blue}{\left(y + x\right)} \cdot 0.5 \]
      7. *-commutative85.3%

        \[\leadsto x - \color{blue}{0.5 \cdot \left(y + x\right)} \]
      8. +-commutative85.3%

        \[\leadsto x - 0.5 \cdot \color{blue}{\left(x + y\right)} \]
    9. Simplified85.3%

      \[\leadsto \color{blue}{x - 0.5 \cdot \left(x + y\right)} \]
    10. Taylor expanded in x around 0 65.6%

      \[\leadsto \color{blue}{-0.5 \cdot y} \]
    11. Step-by-step derivation
      1. *-commutative65.6%

        \[\leadsto \color{blue}{y \cdot -0.5} \]
    12. Simplified65.6%

      \[\leadsto \color{blue}{y \cdot -0.5} \]

    if -3.3e-195 < y < 6.90000000000000034e-77

    1. Initial program 99.8%

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

      \[\leadsto x + \frac{\left|\color{blue}{-1 \cdot x}\right|}{2} \]
    4. Step-by-step derivation
      1. neg-mul-192.4%

        \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    5. Simplified92.4%

      \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    6. Taylor expanded in x around 0 92.4%

      \[\leadsto \color{blue}{x + 0.5 \cdot \left|-x\right|} \]
    7. Step-by-step derivation
      1. *-rgt-identity92.4%

        \[\leadsto \color{blue}{x \cdot 1} + 0.5 \cdot \left|-x\right| \]
      2. *-commutative92.4%

        \[\leadsto x \cdot 1 + \color{blue}{\left|-x\right| \cdot 0.5} \]
      3. fabs-neg92.4%

        \[\leadsto x \cdot 1 + \color{blue}{\left|x\right|} \cdot 0.5 \]
      4. rem-square-sqrt50.8%

        \[\leadsto x \cdot 1 + \left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| \cdot 0.5 \]
      5. fabs-sqr50.8%

        \[\leadsto x \cdot 1 + \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot 0.5 \]
      6. rem-square-sqrt58.4%

        \[\leadsto x \cdot 1 + \color{blue}{x} \cdot 0.5 \]
      7. metadata-eval58.4%

        \[\leadsto x \cdot 1 + x \cdot \color{blue}{\left(0.5 \cdot 1\right)} \]
      8. *-inverses58.4%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \color{blue}{\frac{x}{x}}\right) \]
      9. rem-square-sqrt50.8%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      10. fabs-sqr50.8%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|\sqrt{x} \cdot \sqrt{x}\right|}}{x}\right) \]
      11. rem-square-sqrt92.4%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{x}\right|}{x}\right) \]
      12. fabs-neg92.4%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|-x\right|}}{x}\right) \]
      13. distribute-lft-in92.4%

        \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|-x\right|}{x}\right)} \]
      14. fabs-neg92.4%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\left|x\right|}}{x}\right) \]
      15. rem-square-sqrt50.9%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{x}\right) \]
      16. fabs-sqr50.9%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      17. rem-square-sqrt58.4%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{x}}{x}\right) \]
      18. *-inverses58.4%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \color{blue}{1}\right) \]
      19. metadata-eval58.4%

        \[\leadsto x \cdot \left(1 + \color{blue}{0.5}\right) \]
      20. metadata-eval58.4%

        \[\leadsto x \cdot \color{blue}{1.5} \]
    8. Simplified58.4%

      \[\leadsto \color{blue}{x \cdot 1.5} \]

    if 6.90000000000000034e-77 < y

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{y}\right|}{2} \]
    4. Taylor expanded in x around 0 73.3%

      \[\leadsto \color{blue}{0.5 \cdot \left|y\right|} \]
    5. Step-by-step derivation
      1. rem-square-sqrt72.7%

        \[\leadsto 0.5 \cdot \left|\color{blue}{\sqrt{y} \cdot \sqrt{y}}\right| \]
      2. fabs-sqr72.7%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \]
      3. rem-square-sqrt73.3%

        \[\leadsto 0.5 \cdot \color{blue}{y} \]
    6. Simplified73.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-195}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 6.9 \cdot 10^{-77}:\\ \;\;\;\;x \cdot 1.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 59.1% accurate, 8.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{-70}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;x \leq 7 \cdot 10^{-71}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;x \cdot 1.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.50000000000000022e-70

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|y - x\right|}{x}\right)} \]
    4. Step-by-step derivation
      1. +-commutative98.7%

        \[\leadsto x \cdot \color{blue}{\left(0.5 \cdot \frac{\left|y - x\right|}{x} + 1\right)} \]
      2. sub-neg98.7%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{y + \left(-x\right)}\right|}{x} + 1\right) \]
      3. neg-mul-198.7%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|y + \color{blue}{-1 \cdot x}\right|}{x} + 1\right) \]
      4. fma-define98.7%

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{\left|y + -1 \cdot x\right|}{x}, 1\right)} \]
      5. neg-mul-198.7%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{x}, 1\right) \]
      6. sub-neg98.7%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{y - x}\right|}{x}, 1\right) \]
      7. rem-square-sqrt79.3%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{x}, 1\right) \]
      8. fabs-sqr79.3%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{x}, 1\right) \]
      9. rem-square-sqrt79.9%

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

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(0.5, \frac{y - x}{x}, 1\right)} \]
    6. Taylor expanded in y around 0 68.5%

      \[\leadsto x \cdot \color{blue}{0.5} \]

    if -4.50000000000000022e-70 < x < 6.9999999999999998e-71

    1. Initial program 100.0%

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

      \[\leadsto x + \frac{\left|\color{blue}{y}\right|}{2} \]
    4. Taylor expanded in x around 0 85.9%

      \[\leadsto \color{blue}{0.5 \cdot \left|y\right|} \]
    5. Step-by-step derivation
      1. rem-square-sqrt46.4%

        \[\leadsto 0.5 \cdot \left|\color{blue}{\sqrt{y} \cdot \sqrt{y}}\right| \]
      2. fabs-sqr46.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \]
      3. rem-square-sqrt47.8%

        \[\leadsto 0.5 \cdot \color{blue}{y} \]
    6. Simplified47.8%

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

    if 6.9999999999999998e-71 < x

    1. Initial program 99.7%

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

      \[\leadsto x + \frac{\left|\color{blue}{-1 \cdot x}\right|}{2} \]
    4. Step-by-step derivation
      1. neg-mul-166.6%

        \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    5. Simplified66.6%

      \[\leadsto x + \frac{\left|\color{blue}{-x}\right|}{2} \]
    6. Taylor expanded in x around 0 66.6%

      \[\leadsto \color{blue}{x + 0.5 \cdot \left|-x\right|} \]
    7. Step-by-step derivation
      1. *-rgt-identity66.6%

        \[\leadsto \color{blue}{x \cdot 1} + 0.5 \cdot \left|-x\right| \]
      2. *-commutative66.6%

        \[\leadsto x \cdot 1 + \color{blue}{\left|-x\right| \cdot 0.5} \]
      3. fabs-neg66.6%

        \[\leadsto x \cdot 1 + \color{blue}{\left|x\right|} \cdot 0.5 \]
      4. rem-square-sqrt66.6%

        \[\leadsto x \cdot 1 + \left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right| \cdot 0.5 \]
      5. fabs-sqr66.6%

        \[\leadsto x \cdot 1 + \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \cdot 0.5 \]
      6. rem-square-sqrt66.6%

        \[\leadsto x \cdot 1 + \color{blue}{x} \cdot 0.5 \]
      7. metadata-eval66.6%

        \[\leadsto x \cdot 1 + x \cdot \color{blue}{\left(0.5 \cdot 1\right)} \]
      8. *-inverses66.6%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \color{blue}{\frac{x}{x}}\right) \]
      9. rem-square-sqrt66.6%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      10. fabs-sqr66.6%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|\sqrt{x} \cdot \sqrt{x}\right|}}{x}\right) \]
      11. rem-square-sqrt66.6%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{x}\right|}{x}\right) \]
      12. fabs-neg66.6%

        \[\leadsto x \cdot 1 + x \cdot \left(0.5 \cdot \frac{\color{blue}{\left|-x\right|}}{x}\right) \]
      13. distribute-lft-in66.6%

        \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|-x\right|}{x}\right)} \]
      14. fabs-neg66.6%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\left|x\right|}}{x}\right) \]
      15. rem-square-sqrt66.6%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\left|\color{blue}{\sqrt{x} \cdot \sqrt{x}}\right|}{x}\right) \]
      16. fabs-sqr66.6%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{x}\right) \]
      17. rem-square-sqrt66.6%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \frac{\color{blue}{x}}{x}\right) \]
      18. *-inverses66.6%

        \[\leadsto x \cdot \left(1 + 0.5 \cdot \color{blue}{1}\right) \]
      19. metadata-eval66.6%

        \[\leadsto x \cdot \left(1 + \color{blue}{0.5}\right) \]
      20. metadata-eval66.6%

        \[\leadsto x \cdot \color{blue}{1.5} \]
    8. Simplified66.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{-70}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-71}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 46.0% accurate, 13.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.88 \cdot 10^{-84}:\\
\;\;\;\;x \cdot 0.5\\

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


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

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{\left|y - x\right|}{x}\right)} \]
    4. Step-by-step derivation
      1. +-commutative91.0%

        \[\leadsto x \cdot \color{blue}{\left(0.5 \cdot \frac{\left|y - x\right|}{x} + 1\right)} \]
      2. sub-neg91.0%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|\color{blue}{y + \left(-x\right)}\right|}{x} + 1\right) \]
      3. neg-mul-191.0%

        \[\leadsto x \cdot \left(0.5 \cdot \frac{\left|y + \color{blue}{-1 \cdot x}\right|}{x} + 1\right) \]
      4. fma-define91.0%

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(0.5, \frac{\left|y + -1 \cdot x\right|}{x}, 1\right)} \]
      5. neg-mul-191.0%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|y + \color{blue}{\left(-x\right)}\right|}{x}, 1\right) \]
      6. sub-neg91.0%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{y - x}\right|}{x}, 1\right) \]
      7. rem-square-sqrt29.2%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\left|\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}\right|}{x}, 1\right) \]
      8. fabs-sqr29.2%

        \[\leadsto x \cdot \mathsf{fma}\left(0.5, \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{x}, 1\right) \]
      9. rem-square-sqrt35.2%

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

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(0.5, \frac{y - x}{x}, 1\right)} \]
    6. Taylor expanded in y around 0 34.7%

      \[\leadsto x \cdot \color{blue}{0.5} \]

    if 1.88000000000000004e-84 < y

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{y}\right|}{2} \]
    4. Taylor expanded in x around 0 72.8%

      \[\leadsto \color{blue}{0.5 \cdot \left|y\right|} \]
    5. Step-by-step derivation
      1. rem-square-sqrt72.2%

        \[\leadsto 0.5 \cdot \left|\color{blue}{\sqrt{y} \cdot \sqrt{y}}\right| \]
      2. fabs-sqr72.2%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \]
      3. rem-square-sqrt72.8%

        \[\leadsto 0.5 \cdot \color{blue}{y} \]
    6. Simplified72.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.88 \cdot 10^{-84}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 30.3% accurate, 13.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.8 \cdot 10^{-86}:\\
\;\;\;\;x\\

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


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

    1. Initial program 99.9%

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

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

    if 8.8000000000000006e-86 < y

    1. Initial program 99.9%

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

      \[\leadsto x + \frac{\left|\color{blue}{y}\right|}{2} \]
    4. Taylor expanded in x around 0 72.8%

      \[\leadsto \color{blue}{0.5 \cdot \left|y\right|} \]
    5. Step-by-step derivation
      1. rem-square-sqrt72.2%

        \[\leadsto 0.5 \cdot \left|\color{blue}{\sqrt{y} \cdot \sqrt{y}}\right| \]
      2. fabs-sqr72.2%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \]
      3. rem-square-sqrt72.8%

        \[\leadsto 0.5 \cdot \color{blue}{y} \]
    6. Simplified72.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 8.8 \cdot 10^{-86}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 11.4% accurate, 107.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 99.9%

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

    \[\leadsto \color{blue}{x} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024170 
(FPCore (x y)
  :name "Graphics.Rendering.Chart.Plot.AreaSpots:renderSpotLegend from Chart-1.5.3"
  :precision binary64
  (+ x (/ (fabs (- y x)) 2.0)))