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

Percentage Accurate: 99.9% → 99.9%
Time: 5.0s
Alternatives: 10
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 10 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: 82.8% accurate, 1.0× speedup?

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

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

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

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


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

    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-sqrt86.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.49999999999999994e-72 < x < 2.8e-147

    1. Initial program 100.0%

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

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

    if 2.8e-147 < x

    1. Initial program 99.8%

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

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

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

        \[\leadsto {\left(\sqrt{\color{blue}{\frac{\left|y - x\right|}{2} + x}}\right)}^{2} \]
      4. div-inv99.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot 0.5 + x} \]
      4. add-sqr-sqrt16.5%

        \[\leadsto \color{blue}{\sqrt{\left(y - x\right) \cdot 0.5} \cdot \sqrt{\left(y - x\right) \cdot 0.5}} + x \]
      5. sqrt-prod16.5%

        \[\leadsto \sqrt{\left(y - x\right) \cdot 0.5} \cdot \color{blue}{\left(\sqrt{y - x} \cdot \sqrt{0.5}\right)} + x \]
      6. associate-*r*16.5%

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - x\right) \cdot 0.5\right)}^{0.5}} \cdot \sqrt{y - x}, \sqrt{0.5}, x\right) \]
      9. pow1/216.5%

        \[\leadsto \mathsf{fma}\left({\left(\left(y - x\right) \cdot 0.5\right)}^{0.5} \cdot \color{blue}{{\left(y - x\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
      10. pow-prod-down61.4%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}, \sqrt{0.5}, x\right)} \]
    6. Step-by-step derivation
      1. unpow1/261.4%

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{-1 \cdot \left(\sqrt{0.5} \cdot y\right) + \sqrt{0.5} \cdot x}, \sqrt{0.5}, x\right) \]
    9. Step-by-step derivation
      1. +-commutative83.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{0.5} \cdot x + -1 \cdot \left(\sqrt{0.5} \cdot y\right)}, \sqrt{0.5}, x\right) \]
      2. mul-1-neg83.0%

        \[\leadsto \mathsf{fma}\left(\sqrt{0.5} \cdot x + \color{blue}{\left(-\sqrt{0.5} \cdot y\right)}, \sqrt{0.5}, x\right) \]
      3. unsub-neg83.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{0.5} \cdot x - \sqrt{0.5} \cdot y}, \sqrt{0.5}, x\right) \]
      4. distribute-lft-out--83.0%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{0.5} \cdot \left(x - y\right)}, \sqrt{0.5}, x\right) \]
    10. Simplified83.0%

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

        \[\leadsto \color{blue}{\left(\sqrt{0.5} \cdot \left(x - y\right)\right) \cdot \sqrt{0.5} + x} \]
      2. *-commutative82.9%

        \[\leadsto \color{blue}{\left(\left(x - y\right) \cdot \sqrt{0.5}\right)} \cdot \sqrt{0.5} + x \]
      3. associate-*l*82.7%

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

        \[\leadsto \left(x - y\right) \cdot \color{blue}{0.5} + x \]
    12. Applied egg-rr83.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-72}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-147}:\\ \;\;\;\;\left|y - x\right| \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x + 0.5 \cdot \left(x - y\right)\\ \end{array} \]

Alternative 3: 82.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{-73}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{-147}:\\ \;\;\;\;\left|y - x\right| \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1.5, x, y \cdot -0.5\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -6.2e-73)
   (* 0.5 (+ x y))
   (if (<= x 4.3e-147) (* (fabs (- y x)) 0.5) (fma 1.5 x (* y -0.5)))))
double code(double x, double y) {
	double tmp;
	if (x <= -6.2e-73) {
		tmp = 0.5 * (x + y);
	} else if (x <= 4.3e-147) {
		tmp = fabs((y - x)) * 0.5;
	} else {
		tmp = fma(1.5, x, (y * -0.5));
	}
	return tmp;
}
function code(x, y)
	tmp = 0.0
	if (x <= -6.2e-73)
		tmp = Float64(0.5 * Float64(x + y));
	elseif (x <= 4.3e-147)
		tmp = Float64(abs(Float64(y - x)) * 0.5);
	else
		tmp = fma(1.5, x, Float64(y * -0.5));
	end
	return tmp
end
code[x_, y_] := If[LessEqual[x, -6.2e-73], N[(0.5 * N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.3e-147], N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[(1.5 * x + N[(y * -0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    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-sqrt86.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.19999999999999938e-73 < x < 4.3000000000000001e-147

    1. Initial program 100.0%

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

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

    if 4.3000000000000001e-147 < x

    1. Initial program 99.8%

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

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

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

        \[\leadsto {\left(\sqrt{\color{blue}{\frac{\left|y - x\right|}{2} + x}}\right)}^{2} \]
      4. div-inv99.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot 0.5 + x} \]
      4. add-sqr-sqrt16.5%

        \[\leadsto \color{blue}{\sqrt{\left(y - x\right) \cdot 0.5} \cdot \sqrt{\left(y - x\right) \cdot 0.5}} + x \]
      5. sqrt-prod16.5%

        \[\leadsto \sqrt{\left(y - x\right) \cdot 0.5} \cdot \color{blue}{\left(\sqrt{y - x} \cdot \sqrt{0.5}\right)} + x \]
      6. associate-*r*16.5%

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - x\right) \cdot 0.5\right)}^{0.5}} \cdot \sqrt{y - x}, \sqrt{0.5}, x\right) \]
      9. pow1/216.5%

        \[\leadsto \mathsf{fma}\left({\left(\left(y - x\right) \cdot 0.5\right)}^{0.5} \cdot \color{blue}{{\left(y - x\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
      10. pow-prod-down61.4%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}, \sqrt{0.5}, x\right)} \]
    6. Step-by-step derivation
      1. unpow1/261.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-y \cdot \color{blue}{0.5}\right) + \left(x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right) \]
      7. distribute-rgt-neg-in83.1%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, -0.5, x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right)} \]
      9. metadata-eval83.1%

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-0.5}, x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right) \]
      10. unpow283.1%

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

        \[\leadsto \mathsf{fma}\left(y, -0.5, x + \color{blue}{0.5} \cdot x\right) \]
      12. distribute-rgt1-in83.3%

        \[\leadsto \mathsf{fma}\left(y, -0.5, \color{blue}{\left(0.5 + 1\right) \cdot x}\right) \]
      13. metadata-eval83.3%

        \[\leadsto \mathsf{fma}\left(y, -0.5, \color{blue}{1.5} \cdot x\right) \]
    10. Simplified83.3%

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

      \[\leadsto \color{blue}{-0.5 \cdot y + 1.5 \cdot x} \]
    12. Step-by-step derivation
      1. +-commutative83.3%

        \[\leadsto \color{blue}{1.5 \cdot x + -0.5 \cdot y} \]
      2. *-commutative83.3%

        \[\leadsto 1.5 \cdot x + \color{blue}{y \cdot -0.5} \]
      3. fma-def83.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1.5, x, y \cdot -0.5\right)} \]
      4. *-commutative83.5%

        \[\leadsto \mathsf{fma}\left(1.5, x, \color{blue}{-0.5 \cdot y}\right) \]
    13. Simplified83.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(1.5, x, -0.5 \cdot y\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{-73}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{-147}:\\ \;\;\;\;\left|y - x\right| \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1.5, x, y \cdot -0.5\right)\\ \end{array} \]

Alternative 4: 58.8% accurate, 9.5× speedup?

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

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

\mathbf{elif}\;x \leq -2.7 \cdot 10^{-237}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{-268}:\\
\;\;\;\;y \cdot 0.5\\

\mathbf{elif}\;x \leq 3.2 \cdot 10^{-114}:\\
\;\;\;\;y \cdot -0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -8.50000000000000008e-72

    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-sqrt86.0%

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

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

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

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

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

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

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

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

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

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

    if -8.50000000000000008e-72 < x < -2.69999999999999984e-237 or 8.50000000000000052e-268 < x < 3.2000000000000002e-114

    1. Initial program 100.0%

      \[x + \frac{\left|y - x\right|}{2} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt87.5%

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

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

        \[\leadsto {\left(\sqrt{\color{blue}{\frac{\left|y - x\right|}{2} + x}}\right)}^{2} \]
      4. div-inv87.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot 0.5 + x} \]
      4. add-sqr-sqrt40.8%

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

        \[\leadsto \sqrt{\left(y - x\right) \cdot 0.5} \cdot \color{blue}{\left(\sqrt{y - x} \cdot \sqrt{0.5}\right)} + x \]
      6. associate-*r*40.9%

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - x\right) \cdot 0.5\right)}^{0.5}} \cdot \sqrt{y - x}, \sqrt{0.5}, x\right) \]
      9. pow1/240.9%

        \[\leadsto \mathsf{fma}\left({\left(\left(y - x\right) \cdot 0.5\right)}^{0.5} \cdot \color{blue}{{\left(y - x\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
      10. pow-prod-down63.6%

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
    5. Applied egg-rr63.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}, \sqrt{0.5}, x\right)} \]
    6. Step-by-step derivation
      1. unpow1/263.6%

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

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

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot {\left(\sqrt{0.5}\right)}^{2}\right) \cdot y} \]
      2. *-commutative51.9%

        \[\leadsto \color{blue}{y \cdot \left(-1 \cdot {\left(\sqrt{0.5}\right)}^{2}\right)} \]
      3. unpow251.9%

        \[\leadsto y \cdot \left(-1 \cdot \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right)}\right) \]
      4. rem-square-sqrt52.9%

        \[\leadsto y \cdot \left(-1 \cdot \color{blue}{0.5}\right) \]
      5. metadata-eval52.9%

        \[\leadsto y \cdot \color{blue}{-0.5} \]
    10. Simplified52.9%

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

    if -2.69999999999999984e-237 < x < 8.50000000000000052e-268

    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-sqrt57.9%

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

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

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

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

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

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

    if 3.2000000000000002e-114 < x

    1. Initial program 99.8%

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

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

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

        \[\leadsto {\left(\sqrt{\color{blue}{\frac{\left|y - x\right|}{2} + x}}\right)}^{2} \]
      4. div-inv99.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot 0.5 + x} \]
      4. add-sqr-sqrt15.9%

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

        \[\leadsto \sqrt{\left(y - x\right) \cdot 0.5} \cdot \color{blue}{\left(\sqrt{y - x} \cdot \sqrt{0.5}\right)} + x \]
      6. associate-*r*15.9%

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - x\right) \cdot 0.5\right)}^{0.5}} \cdot \sqrt{y - x}, \sqrt{0.5}, x\right) \]
      9. pow1/215.9%

        \[\leadsto \mathsf{fma}\left({\left(\left(y - x\right) \cdot 0.5\right)}^{0.5} \cdot \color{blue}{{\left(y - x\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
      10. pow-prod-down58.3%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}, \sqrt{0.5}, x\right)} \]
    6. Step-by-step derivation
      1. unpow1/258.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-y \cdot \color{blue}{0.5}\right) + \left(x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right) \]
      7. distribute-rgt-neg-in83.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, -0.5, x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right)} \]
      9. metadata-eval83.6%

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-0.5}, x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right) \]
      10. unpow283.6%

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

        \[\leadsto \mathsf{fma}\left(y, -0.5, x + \color{blue}{0.5} \cdot x\right) \]
      12. distribute-rgt1-in83.9%

        \[\leadsto \mathsf{fma}\left(y, -0.5, \color{blue}{\left(0.5 + 1\right) \cdot x}\right) \]
      13. metadata-eval83.9%

        \[\leadsto \mathsf{fma}\left(y, -0.5, \color{blue}{1.5} \cdot x\right) \]
    10. Simplified83.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{-72}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq -2.7 \cdot 10^{-237}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-268}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-114}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.5\\ \end{array} \]

Alternative 5: 69.4% accurate, 9.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+25}:\\
\;\;\;\;y \cdot -0.5\\

\mathbf{elif}\;y \leq -1.6 \cdot 10^{-35}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq -1.55 \cdot 10^{-89}:\\
\;\;\;\;y \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 < -6.99999999999999999e25 or -1.5999999999999999e-35 < y < -1.54999999999999998e-89

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y - x, 0.5, x\right)} \cdot \sqrt{\mathsf{fma}\left(y - x, 0.5, x\right)}} \]
      2. add-sqr-sqrt12.5%

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot 0.5 + x} \]
      4. add-sqr-sqrt9.4%

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

        \[\leadsto \sqrt{\left(y - x\right) \cdot 0.5} \cdot \color{blue}{\left(\sqrt{y - x} \cdot \sqrt{0.5}\right)} + x \]
      6. associate-*r*9.4%

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - x\right) \cdot 0.5\right)}^{0.5}} \cdot \sqrt{y - x}, \sqrt{0.5}, x\right) \]
      9. pow1/29.4%

        \[\leadsto \mathsf{fma}\left({\left(\left(y - x\right) \cdot 0.5\right)}^{0.5} \cdot \color{blue}{{\left(y - x\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
      10. pow-prod-down61.8%

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
    5. Applied egg-rr61.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}, \sqrt{0.5}, x\right)} \]
    6. Step-by-step derivation
      1. unpow1/261.8%

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

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

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

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

        \[\leadsto \color{blue}{\left(-1 \cdot {\left(\sqrt{0.5}\right)}^{2}\right) \cdot y} \]
      2. *-commutative74.7%

        \[\leadsto \color{blue}{y \cdot \left(-1 \cdot {\left(\sqrt{0.5}\right)}^{2}\right)} \]
      3. unpow274.7%

        \[\leadsto y \cdot \left(-1 \cdot \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right)}\right) \]
      4. rem-square-sqrt76.2%

        \[\leadsto y \cdot \left(-1 \cdot \color{blue}{0.5}\right) \]
      5. metadata-eval76.2%

        \[\leadsto y \cdot \color{blue}{-0.5} \]
    10. Simplified76.2%

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

    if -6.99999999999999999e25 < y < -1.5999999999999999e-35

    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-sqrt52.1%

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999998e-89 < 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-sqrt67.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+25}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{-35}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{-89}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(x + y\right)\\ \end{array} \]

Alternative 6: 79.3% accurate, 11.8× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

        \[\leadsto {\left(\sqrt{\color{blue}{\frac{\left|y - x\right|}{2} + x}}\right)}^{2} \]
      4. div-inv72.9%

        \[\leadsto {\left(\sqrt{\color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x}\right)}^{2} \]
      5. fma-def72.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y - x, 0.5, x\right)} \cdot \sqrt{\mathsf{fma}\left(y - x, 0.5, x\right)}} \]
      2. add-sqr-sqrt31.5%

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot 0.5 + x} \]
      4. add-sqr-sqrt26.2%

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

        \[\leadsto \sqrt{\left(y - x\right) \cdot 0.5} \cdot \color{blue}{\left(\sqrt{y - x} \cdot \sqrt{0.5}\right)} + x \]
      6. associate-*r*26.2%

        \[\leadsto \color{blue}{\left(\sqrt{\left(y - x\right) \cdot 0.5} \cdot \sqrt{y - x}\right) \cdot \sqrt{0.5}} + x \]
      7. fma-def26.2%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - x\right) \cdot 0.5\right)}^{0.5}} \cdot \sqrt{y - x}, \sqrt{0.5}, x\right) \]
      9. pow1/226.2%

        \[\leadsto \mathsf{fma}\left({\left(\left(y - x\right) \cdot 0.5\right)}^{0.5} \cdot \color{blue}{{\left(y - x\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
      10. pow-prod-down61.4%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}, \sqrt{0.5}, x\right)} \]
    6. Step-by-step derivation
      1. unpow1/261.4%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{0.5} \cdot x + \color{blue}{\left(-\sqrt{0.5} \cdot y\right)}, \sqrt{0.5}, x\right) \]
      3. unsub-neg77.5%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{0.5} \cdot x - \sqrt{0.5} \cdot y}, \sqrt{0.5}, x\right) \]
      4. distribute-lft-out--77.5%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{0.5} \cdot \left(x - y\right)}, \sqrt{0.5}, x\right) \]
    10. Simplified77.5%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{0.5} \cdot \left(x - y\right)}, \sqrt{0.5}, x\right) \]
    11. Step-by-step derivation
      1. fma-udef77.5%

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

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

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

        \[\leadsto \left(x - y\right) \cdot \color{blue}{0.5} + x \]
    12. Applied egg-rr78.2%

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

    if 1.3999999999999999e-282 < 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-sqrt77.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 58.5% accurate, 15.0× speedup?

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

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

\mathbf{elif}\;x \leq 3.3 \cdot 10^{-120}:\\
\;\;\;\;y \cdot 0.5\\

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


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

    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-sqrt82.8%

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

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

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

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

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

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

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

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

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

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

    if -3.00000000000000019e-106 < x < 3.29999999999999967e-120

    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-sqrt45.5%

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

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

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

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

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

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

    if 3.29999999999999967e-120 < x

    1. Initial program 99.8%

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

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

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

        \[\leadsto {\left(\sqrt{\color{blue}{\frac{\left|y - x\right|}{2} + x}}\right)}^{2} \]
      4. div-inv99.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot 0.5 + x} \]
      4. add-sqr-sqrt15.7%

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

        \[\leadsto \sqrt{\left(y - x\right) \cdot 0.5} \cdot \color{blue}{\left(\sqrt{y - x} \cdot \sqrt{0.5}\right)} + x \]
      6. associate-*r*15.7%

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - x\right) \cdot 0.5\right)}^{0.5}} \cdot \sqrt{y - x}, \sqrt{0.5}, x\right) \]
      9. pow1/215.7%

        \[\leadsto \mathsf{fma}\left({\left(\left(y - x\right) \cdot 0.5\right)}^{0.5} \cdot \color{blue}{{\left(y - x\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
      10. pow-prod-down58.8%

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
    5. Applied egg-rr58.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}, \sqrt{0.5}, x\right)} \]
    6. Step-by-step derivation
      1. unpow1/258.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-y \cdot \color{blue}{0.5}\right) + \left(x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right) \]
      7. distribute-rgt-neg-in83.8%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, -0.5, x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right)} \]
      9. metadata-eval83.8%

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-0.5}, x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right) \]
      10. unpow283.8%

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

        \[\leadsto \mathsf{fma}\left(y, -0.5, x + \color{blue}{0.5} \cdot x\right) \]
      12. distribute-rgt1-in84.1%

        \[\leadsto \mathsf{fma}\left(y, -0.5, \color{blue}{\left(0.5 + 1\right) \cdot x}\right) \]
      13. metadata-eval84.1%

        \[\leadsto \mathsf{fma}\left(y, -0.5, \color{blue}{1.5} \cdot x\right) \]
    10. Simplified84.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-106}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-120}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.5\\ \end{array} \]

Alternative 8: 31.8% accurate, 21.1× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

    if 1.3e-199 < 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-sqrt78.5%

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

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

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

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

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

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

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

Alternative 9: 46.0% accurate, 21.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{-92}:\\
\;\;\;\;x \cdot 1.5\\

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


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

    1. Initial program 99.9%

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

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

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

        \[\leadsto {\left(\sqrt{\color{blue}{\frac{\left|y - x\right|}{2} + x}}\right)}^{2} \]
      4. div-inv69.9%

        \[\leadsto {\left(\sqrt{\color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x}\right)}^{2} \]
      5. fma-def69.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y - x, 0.5, x\right)} \cdot \sqrt{\mathsf{fma}\left(y - x, 0.5, x\right)}} \]
      2. add-sqr-sqrt37.5%

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot 0.5 + x} \]
      4. add-sqr-sqrt31.6%

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

        \[\leadsto \sqrt{\left(y - x\right) \cdot 0.5} \cdot \color{blue}{\left(\sqrt{y - x} \cdot \sqrt{0.5}\right)} + x \]
      6. associate-*r*31.5%

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - x\right) \cdot 0.5\right)}^{0.5}} \cdot \sqrt{y - x}, \sqrt{0.5}, x\right) \]
      9. pow1/231.5%

        \[\leadsto \mathsf{fma}\left({\left(\left(y - x\right) \cdot 0.5\right)}^{0.5} \cdot \color{blue}{{\left(y - x\right)}^{0.5}}, \sqrt{0.5}, x\right) \]
      10. pow-prod-down61.7%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left({\left(\left(\left(y - x\right) \cdot 0.5\right) \cdot \left(y - x\right)\right)}^{0.5}, \sqrt{0.5}, x\right)} \]
    6. Step-by-step derivation
      1. unpow1/261.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-y \cdot \color{blue}{0.5}\right) + \left(x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right) \]
      7. distribute-rgt-neg-in73.3%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, -0.5, x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right)} \]
      9. metadata-eval73.3%

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-0.5}, x + {\left(\sqrt{0.5}\right)}^{2} \cdot x\right) \]
      10. unpow273.3%

        \[\leadsto \mathsf{fma}\left(y, -0.5, x + \color{blue}{\left(\sqrt{0.5} \cdot \sqrt{0.5}\right)} \cdot x\right) \]
      11. rem-square-sqrt73.4%

        \[\leadsto \mathsf{fma}\left(y, -0.5, x + \color{blue}{0.5} \cdot x\right) \]
      12. distribute-rgt1-in73.4%

        \[\leadsto \mathsf{fma}\left(y, -0.5, \color{blue}{\left(0.5 + 1\right) \cdot x}\right) \]
      13. metadata-eval73.4%

        \[\leadsto \mathsf{fma}\left(y, -0.5, \color{blue}{1.5} \cdot x\right) \]
    10. Simplified73.4%

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

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

    if 2.1e-92 < 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-sqrt86.2%

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

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

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

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

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

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

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

Alternative 10: 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.2%

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

    \[\leadsto x \]

Reproduce

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