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

Percentage Accurate: 99.9% → 99.9%
Time: 5.3s
Alternatives: 8
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 8 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|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}
Derivation
  1. Initial program 99.9%

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

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

Alternative 2: 69.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(y - x\right) \cdot 0.5\\ \mathbf{if}\;x \leq -4.4 \cdot 10^{-253}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-158} \lor \neg \left(x \leq 7.5 \cdot 10^{+144}\right):\\ \;\;\;\;\left|y - x\right| \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0 \cdot t_0 - x \cdot x}{y \cdot -0.5 + x \cdot -0.5}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (- y x) 0.5)))
   (if (<= x -4.4e-253)
     (* 0.5 (+ x y))
     (if (or (<= x 3.1e-158) (not (<= x 7.5e+144)))
       (* (fabs (- y x)) 0.5)
       (/ (- (* t_0 t_0) (* x x)) (+ (* y -0.5) (* x -0.5)))))))
double code(double x, double y) {
	double t_0 = (y - x) * 0.5;
	double tmp;
	if (x <= -4.4e-253) {
		tmp = 0.5 * (x + y);
	} else if ((x <= 3.1e-158) || !(x <= 7.5e+144)) {
		tmp = fabs((y - x)) * 0.5;
	} else {
		tmp = ((t_0 * t_0) - (x * x)) / ((y * -0.5) + (x * -0.5));
	}
	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 = (y - x) * 0.5d0
    if (x <= (-4.4d-253)) then
        tmp = 0.5d0 * (x + y)
    else if ((x <= 3.1d-158) .or. (.not. (x <= 7.5d+144))) then
        tmp = abs((y - x)) * 0.5d0
    else
        tmp = ((t_0 * t_0) - (x * x)) / ((y * (-0.5d0)) + (x * (-0.5d0)))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = (y - x) * 0.5;
	double tmp;
	if (x <= -4.4e-253) {
		tmp = 0.5 * (x + y);
	} else if ((x <= 3.1e-158) || !(x <= 7.5e+144)) {
		tmp = Math.abs((y - x)) * 0.5;
	} else {
		tmp = ((t_0 * t_0) - (x * x)) / ((y * -0.5) + (x * -0.5));
	}
	return tmp;
}
def code(x, y):
	t_0 = (y - x) * 0.5
	tmp = 0
	if x <= -4.4e-253:
		tmp = 0.5 * (x + y)
	elif (x <= 3.1e-158) or not (x <= 7.5e+144):
		tmp = math.fabs((y - x)) * 0.5
	else:
		tmp = ((t_0 * t_0) - (x * x)) / ((y * -0.5) + (x * -0.5))
	return tmp
function code(x, y)
	t_0 = Float64(Float64(y - x) * 0.5)
	tmp = 0.0
	if (x <= -4.4e-253)
		tmp = Float64(0.5 * Float64(x + y));
	elseif ((x <= 3.1e-158) || !(x <= 7.5e+144))
		tmp = Float64(abs(Float64(y - x)) * 0.5);
	else
		tmp = Float64(Float64(Float64(t_0 * t_0) - Float64(x * x)) / Float64(Float64(y * -0.5) + Float64(x * -0.5)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (y - x) * 0.5;
	tmp = 0.0;
	if (x <= -4.4e-253)
		tmp = 0.5 * (x + y);
	elseif ((x <= 3.1e-158) || ~((x <= 7.5e+144)))
		tmp = abs((y - x)) * 0.5;
	else
		tmp = ((t_0 * t_0) - (x * x)) / ((y * -0.5) + (x * -0.5));
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(y - x), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[x, -4.4e-253], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 3.1e-158], N[Not[LessEqual[x, 7.5e+144]], $MachinePrecision]], N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(N[(y * -0.5), $MachinePrecision] + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 3.1 \cdot 10^{-158} \lor \neg \left(x \leq 7.5 \cdot 10^{+144}\right):\\
\;\;\;\;\left|y - x\right| \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0 \cdot t_0 - x \cdot x}{y \cdot -0.5 + x \cdot -0.5}\\


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

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
      2. div-inv100.0%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt80.4%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt81.2%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval81.2%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr81.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Taylor expanded in y around 0 81.2%

      \[\leadsto \color{blue}{-0.5 \cdot x + \left(0.5 \cdot y + x\right)} \]
    5. Step-by-step derivation
      1. +-commutative81.2%

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot x + x\right) + 0.5 \cdot y} \]
      3. distribute-lft1-in81.2%

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

        \[\leadsto \color{blue}{0.5} \cdot x + 0.5 \cdot y \]
      5. distribute-lft-out81.2%

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

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

    if -4.39999999999999992e-253 < x < 3.10000000000000018e-158 or 7.5000000000000006e144 < x

    1. Initial program 99.9%

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

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

    if 3.10000000000000018e-158 < x < 7.5000000000000006e144

    1. Initial program 99.8%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
      2. div-inv99.8%

        \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
      3. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt12.6%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt24.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval24.0%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr24.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Step-by-step derivation
      1. fma-udef24.0%

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

        \[\leadsto \color{blue}{\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y - x\right) \cdot 0.5 - x}} \]
    5. Applied egg-rr16.6%

      \[\leadsto \color{blue}{\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y - x\right) \cdot 0.5 - x}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt5.3%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(y - x\right) \cdot 0.5} \cdot \sqrt{\left(y - x\right) \cdot 0.5}} - x} \]
      2. sqrt-prod84.6%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right)}} - x} \]
      3. associate-*r*84.5%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\sqrt{\color{blue}{\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right) \cdot 0.5}} - x} \]
      4. sqrt-prod84.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)} \cdot \sqrt{0.5}} - x} \]
      5. fma-neg84.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\mathsf{fma}\left(\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)}, \sqrt{0.5}, -x\right)}} \]
      6. *-commutative84.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{\color{blue}{\left(0.5 \cdot \left(y - x\right)\right)} \cdot \left(y - x\right)}, \sqrt{0.5}, -x\right)} \]
      7. associate-*l*84.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{\color{blue}{0.5 \cdot \left(\left(y - x\right) \cdot \left(y - x\right)\right)}}, \sqrt{0.5}, -x\right)} \]
      8. pow284.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{0.5 \cdot \color{blue}{{\left(y - x\right)}^{2}}}, \sqrt{0.5}, -x\right)} \]
    7. Applied egg-rr84.4%

      \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\mathsf{fma}\left(\sqrt{0.5 \cdot {\left(y - x\right)}^{2}}, \sqrt{0.5}, -x\right)}} \]
    8. Taylor expanded in y around -inf 79.4%

      \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\left({\left(\sqrt{0.5}\right)}^{2} \cdot x + -1 \cdot \left({\left(\sqrt{0.5}\right)}^{2} \cdot y\right)\right) - x}} \]
    9. Step-by-step derivation
      1. sub-neg79.4%

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

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

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

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

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

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y \cdot \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right)}\right) \cdot -1 + \left({\left(\sqrt{0.5}\right)}^{2} \cdot x + \left(-x\right)\right)} \]
      7. rem-square-sqrt79.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y \cdot \color{blue}{0.5}\right) \cdot -1 + \left({\left(\sqrt{0.5}\right)}^{2} \cdot x + \left(-x\right)\right)} \]
      8. associate-*l*79.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{y \cdot \left(0.5 \cdot -1\right)} + \left({\left(\sqrt{0.5}\right)}^{2} \cdot x + \left(-x\right)\right)} \]
      9. metadata-eval79.7%

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

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

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{y \cdot -0.5 + \left(\color{blue}{0.5} \cdot x + \left(-x\right)\right)} \]
      12. neg-mul-180.3%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{y \cdot -0.5 + \left(0.5 \cdot x + \color{blue}{-1 \cdot x}\right)} \]
      13. distribute-rgt-out80.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{-253}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-158} \lor \neg \left(x \leq 7.5 \cdot 10^{+144}\right):\\ \;\;\;\;\left|y - x\right| \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{y \cdot -0.5 + x \cdot -0.5}\\ \end{array} \]

Alternative 3: 71.5% accurate, 3.9× speedup?

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

\\
\begin{array}{l}
t_0 := \left(y - x\right) \cdot 0.5\\
\mathbf{if}\;y \leq -1 \cdot 10^{+42}:\\
\;\;\;\;\frac{y \cdot -0.25}{0.5}\\

\mathbf{elif}\;y \leq -1.6 \cdot 10^{-239}:\\
\;\;\;\;\frac{t_0 \cdot t_0 - x \cdot x}{y \cdot -0.5 + x \cdot -0.5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.00000000000000004e42

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
      2. div-inv100.0%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt15.8%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt17.1%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval17.1%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr17.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Step-by-step derivation
      1. fma-udef17.1%

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

        \[\leadsto \color{blue}{\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y - x\right) \cdot 0.5 - x}} \]
    5. Applied egg-rr0.3%

      \[\leadsto \color{blue}{\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y - x\right) \cdot 0.5 - x}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(y - x\right) \cdot 0.5} \cdot \sqrt{\left(y - x\right) \cdot 0.5}} - x} \]
      2. sqrt-prod32.0%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right)}} - x} \]
      3. associate-*r*32.0%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\sqrt{\color{blue}{\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right) \cdot 0.5}} - x} \]
      4. sqrt-prod31.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)} \cdot \sqrt{0.5}} - x} \]
      5. fma-neg31.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\mathsf{fma}\left(\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)}, \sqrt{0.5}, -x\right)}} \]
      6. *-commutative31.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{\color{blue}{\left(0.5 \cdot \left(y - x\right)\right)} \cdot \left(y - x\right)}, \sqrt{0.5}, -x\right)} \]
      7. associate-*l*31.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{\color{blue}{0.5 \cdot \left(\left(y - x\right) \cdot \left(y - x\right)\right)}}, \sqrt{0.5}, -x\right)} \]
      8. pow231.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{0.5 \cdot \color{blue}{{\left(y - x\right)}^{2}}}, \sqrt{0.5}, -x\right)} \]
    7. Applied egg-rr31.7%

      \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\mathsf{fma}\left(\sqrt{0.5 \cdot {\left(y - x\right)}^{2}}, \sqrt{0.5}, -x\right)}} \]
    8. Taylor expanded in y around -inf 78.7%

      \[\leadsto \color{blue}{-0.25 \cdot \frac{y}{{\left(\sqrt{0.5}\right)}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*r/78.7%

        \[\leadsto \color{blue}{\frac{-0.25 \cdot y}{{\left(\sqrt{0.5}\right)}^{2}}} \]
      2. unpow278.7%

        \[\leadsto \frac{-0.25 \cdot y}{\color{blue}{\sqrt{0.5} \cdot \sqrt{0.5}}} \]
      3. rem-square-sqrt80.4%

        \[\leadsto \frac{-0.25 \cdot y}{\color{blue}{0.5}} \]
    10. Simplified80.4%

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

    if -1.00000000000000004e42 < y < -1.6e-239

    1. Initial program 99.8%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
      2. div-inv99.8%

        \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
      3. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt22.6%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt30.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval30.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr30.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Step-by-step derivation
      1. fma-udef30.9%

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

        \[\leadsto \color{blue}{\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y - x\right) \cdot 0.5 - x}} \]
    5. Applied egg-rr16.6%

      \[\leadsto \color{blue}{\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y - x\right) \cdot 0.5 - x}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt10.4%

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

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right)}} - x} \]
      3. associate-*r*66.2%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\sqrt{\color{blue}{\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right) \cdot 0.5}} - x} \]
      4. sqrt-prod66.1%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)} \cdot \sqrt{0.5}} - x} \]
      5. fma-neg66.1%

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

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{\color{blue}{\left(0.5 \cdot \left(y - x\right)\right)} \cdot \left(y - x\right)}, \sqrt{0.5}, -x\right)} \]
      7. associate-*l*66.1%

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

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{0.5 \cdot \color{blue}{{\left(y - x\right)}^{2}}}, \sqrt{0.5}, -x\right)} \]
    7. Applied egg-rr66.1%

      \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\mathsf{fma}\left(\sqrt{0.5 \cdot {\left(y - x\right)}^{2}}, \sqrt{0.5}, -x\right)}} \]
    8. Taylor expanded in y around -inf 56.8%

      \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\left({\left(\sqrt{0.5}\right)}^{2} \cdot x + -1 \cdot \left({\left(\sqrt{0.5}\right)}^{2} \cdot y\right)\right) - x}} \]
    9. Step-by-step derivation
      1. sub-neg56.8%

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

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

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

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

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\left(y \cdot {\left(\sqrt{0.5}\right)}^{2}\right)} \cdot -1 + \left({\left(\sqrt{0.5}\right)}^{2} \cdot x + \left(-x\right)\right)} \]
      6. unpow256.8%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y \cdot \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right)}\right) \cdot -1 + \left({\left(\sqrt{0.5}\right)}^{2} \cdot x + \left(-x\right)\right)} \]
      7. rem-square-sqrt57.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y \cdot \color{blue}{0.5}\right) \cdot -1 + \left({\left(\sqrt{0.5}\right)}^{2} \cdot x + \left(-x\right)\right)} \]
      8. associate-*l*57.4%

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

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{y \cdot \color{blue}{-0.5} + \left({\left(\sqrt{0.5}\right)}^{2} \cdot x + \left(-x\right)\right)} \]
      10. unpow257.4%

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

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{y \cdot -0.5 + \left(\color{blue}{0.5} \cdot x + \left(-x\right)\right)} \]
      12. neg-mul-157.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{y \cdot -0.5 + \left(0.5 \cdot x + \color{blue}{-1 \cdot x}\right)} \]
      13. distribute-rgt-out57.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{y \cdot -0.5 + \color{blue}{x \cdot \left(0.5 + -1\right)}} \]
      14. metadata-eval57.7%

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

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

    if -1.6e-239 < y

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
      2. div-inv100.0%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt71.9%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt77.2%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval77.2%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr77.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Taylor expanded in y around 0 77.2%

      \[\leadsto \color{blue}{-0.5 \cdot x + \left(0.5 \cdot y + x\right)} \]
    5. Step-by-step derivation
      1. +-commutative77.2%

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot x + x\right) + 0.5 \cdot y} \]
      3. distribute-lft1-in77.2%

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

        \[\leadsto \color{blue}{0.5} \cdot x + 0.5 \cdot y \]
      5. distribute-lft-out77.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+42}:\\ \;\;\;\;\frac{y \cdot -0.25}{0.5}\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{-239}:\\ \;\;\;\;\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{y \cdot -0.5 + x \cdot -0.5}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \]

Alternative 4: 70.1% accurate, 15.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.02 \cdot 10^{-122}:\\
\;\;\;\;\frac{y \cdot -0.25}{0.5}\\

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


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

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative99.9%

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

        \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
      3. fma-def99.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt18.9%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt22.4%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval22.4%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr22.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Step-by-step derivation
      1. fma-udef22.4%

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

        \[\leadsto \color{blue}{\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y - x\right) \cdot 0.5 - x}} \]
    5. Applied egg-rr6.5%

      \[\leadsto \color{blue}{\frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\left(y - x\right) \cdot 0.5 - x}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt4.7%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(y - x\right) \cdot 0.5} \cdot \sqrt{\left(y - x\right) \cdot 0.5}} - x} \]
      2. sqrt-prod48.6%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right)}} - x} \]
      3. associate-*r*48.6%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\sqrt{\color{blue}{\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right) \cdot 0.5}} - x} \]
      4. sqrt-prod48.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)} \cdot \sqrt{0.5}} - x} \]
      5. fma-neg48.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\mathsf{fma}\left(\sqrt{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)}, \sqrt{0.5}, -x\right)}} \]
      6. *-commutative48.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{\color{blue}{\left(0.5 \cdot \left(y - x\right)\right)} \cdot \left(y - x\right)}, \sqrt{0.5}, -x\right)} \]
      7. associate-*l*48.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{\color{blue}{0.5 \cdot \left(\left(y - x\right) \cdot \left(y - x\right)\right)}}, \sqrt{0.5}, -x\right)} \]
      8. pow248.4%

        \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\mathsf{fma}\left(\sqrt{0.5 \cdot \color{blue}{{\left(y - x\right)}^{2}}}, \sqrt{0.5}, -x\right)} \]
    7. Applied egg-rr48.4%

      \[\leadsto \frac{\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(\left(y - x\right) \cdot 0.5\right) - x \cdot x}{\color{blue}{\mathsf{fma}\left(\sqrt{0.5 \cdot {\left(y - x\right)}^{2}}, \sqrt{0.5}, -x\right)}} \]
    8. Taylor expanded in y around -inf 65.0%

      \[\leadsto \color{blue}{-0.25 \cdot \frac{y}{{\left(\sqrt{0.5}\right)}^{2}}} \]
    9. Step-by-step derivation
      1. associate-*r/65.0%

        \[\leadsto \color{blue}{\frac{-0.25 \cdot y}{{\left(\sqrt{0.5}\right)}^{2}}} \]
      2. unpow265.0%

        \[\leadsto \frac{-0.25 \cdot y}{\color{blue}{\sqrt{0.5} \cdot \sqrt{0.5}}} \]
      3. rem-square-sqrt66.3%

        \[\leadsto \frac{-0.25 \cdot y}{\color{blue}{0.5}} \]
    10. Simplified66.3%

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

    if -1.02000000000000002e-122 < y

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative99.9%

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

        \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
      3. fma-def99.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt65.2%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt71.1%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval71.1%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr71.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Taylor expanded in y around 0 71.1%

      \[\leadsto \color{blue}{-0.5 \cdot x + \left(0.5 \cdot y + x\right)} \]
    5. Step-by-step derivation
      1. +-commutative71.1%

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot x + x\right) + 0.5 \cdot y} \]
      3. distribute-lft1-in71.1%

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

        \[\leadsto \color{blue}{0.5} \cdot x + 0.5 \cdot y \]
      5. distribute-lft-out71.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{-122}:\\ \;\;\;\;\frac{y \cdot -0.25}{0.5}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \]

Alternative 5: 31.8% accurate, 21.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 3.4 \cdot 10^{-185}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= y 3.4e-185) x (* y 0.5)))
double code(double x, double y) {
	double tmp;
	if (y <= 3.4e-185) {
		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 <= 3.4d-185) 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 <= 3.4e-185) {
		tmp = x;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 3.4e-185:
		tmp = x
	else:
		tmp = y * 0.5
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 3.4e-185)
		tmp = x;
	else
		tmp = Float64(y * 0.5);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= 3.4e-185)
		tmp = x;
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 3.4e-185], x, N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 99.9%

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

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

    if 3.3999999999999998e-185 < y

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
      2. div-inv100.0%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt83.9%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt87.3%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval87.3%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr87.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Taylor expanded in y around inf 62.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.4 \cdot 10^{-185}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 6: 45.7% accurate, 21.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 2.6 \cdot 10^{-101}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= y 2.6e-101) (* x 0.5) (* y 0.5)))
double code(double x, double y) {
	double tmp;
	if (y <= 2.6e-101) {
		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 <= 2.6d-101) 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 <= 2.6e-101) {
		tmp = x * 0.5;
	} else {
		tmp = y * 0.5;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= 2.6e-101:
		tmp = x * 0.5
	else:
		tmp = y * 0.5
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= 2.6e-101)
		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 <= 2.6e-101)
		tmp = x * 0.5;
	else
		tmp = y * 0.5;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, 2.6e-101], N[(x * 0.5), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 99.9%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative99.9%

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

        \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
      3. fma-def99.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt35.0%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt41.2%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval41.2%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr41.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Taylor expanded in y around 0 38.1%

      \[\leadsto \color{blue}{-0.5 \cdot x + x} \]
    5. Step-by-step derivation
      1. distribute-lft1-in38.1%

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

        \[\leadsto \color{blue}{0.5} \cdot x \]
      3. *-commutative38.1%

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    6. Simplified38.1%

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

    if 2.6000000000000001e-101 < y

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
      2. div-inv100.0%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
      4. add-sqr-sqrt88.2%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
      6. add-sqr-sqrt90.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
      7. metadata-eval90.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
    3. Applied egg-rr90.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
    4. Taylor expanded in y around inf 72.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.6 \cdot 10^{-101}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]

Alternative 7: 54.7% accurate, 21.4× speedup?

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

\\
0.5 \cdot \left(x + y\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[x + \frac{\left|y - x\right|}{2} \]
  2. Step-by-step derivation
    1. +-commutative99.9%

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

      \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
    3. fma-def99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
    4. add-sqr-sqrt50.0%

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}, \frac{1}{2}, x\right) \]
    6. add-sqr-sqrt55.1%

      \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, \frac{1}{2}, x\right) \]
    7. metadata-eval55.1%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.5}, x\right) \]
  3. Applied egg-rr55.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 0.5, x\right)} \]
  4. Taylor expanded in y around 0 55.1%

    \[\leadsto \color{blue}{-0.5 \cdot x + \left(0.5 \cdot y + x\right)} \]
  5. Step-by-step derivation
    1. +-commutative55.1%

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

      \[\leadsto \color{blue}{\left(-0.5 \cdot x + x\right) + 0.5 \cdot y} \]
    3. distribute-lft1-in55.1%

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

      \[\leadsto \color{blue}{0.5} \cdot x + 0.5 \cdot y \]
    5. distribute-lft-out55.1%

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

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

    \[\leadsto 0.5 \cdot \left(x + y\right) \]

Alternative 8: 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. Taylor expanded in x around inf 11.7%

    \[\leadsto \color{blue}{x} \]
  3. Final simplification11.7%

    \[\leadsto x \]

Reproduce

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