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

Percentage Accurate: 99.9% → 99.9%
Time: 11.8s
Alternatives: 7
Speedup: 1.7×

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 7 alternatives:

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

Initial Program: 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.7× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\left|x - y\right|, 0.5, x\right) \end{array} \]
(FPCore (x y) :precision binary64 (fma (fabs (- x y)) 0.5 x))
double code(double x, double y) {
	return fma(fabs((x - y)), 0.5, x);
}
function code(x, y)
	return fma(abs(Float64(x - y)), 0.5, x)
end
code[x_, y_] := N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] * 0.5 + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\left|x - y\right|, 0.5, x\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[x + \frac{\left|y - x\right|}{2} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
    2. div-invN/A

      \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
    3. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
    4. fabs-lowering-fabs.f64N/A

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, 0.5, x\right)} \]
  5. Final simplification99.9%

    \[\leadsto \mathsf{fma}\left(\left|x - y\right|, 0.5, x\right) \]
  6. Add Preprocessing

Alternative 2: 55.8% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x + \frac{\left|x - y\right|}{2} \leq -1 \cdot 10^{-238}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left|y\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64))) < -9.9999999999999999e-239

    1. Initial program 100.0%

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

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

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

      if -9.9999999999999999e-239 < (+.f64 x (/.f64 (fabs.f64 (-.f64 y x)) #s(literal 2 binary64)))

      1. Initial program 99.8%

        \[x + \frac{\left|y - x\right|}{2} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
        2. div-invN/A

          \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
        3. accelerator-lowering-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
        4. fabs-lowering-fabs.f64N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left|\color{blue}{y}\right|, \frac{1}{2}, x\right) \]
      6. Step-by-step derivation
        1. Simplified70.7%

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

          \[\leadsto \color{blue}{\frac{1}{2} \cdot \left|y\right|} \]
        3. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto \color{blue}{\frac{1}{2} \cdot \left|y\right|} \]
          2. fabs-lowering-fabs.f6465.5

            \[\leadsto 0.5 \cdot \color{blue}{\left|y\right|} \]
        4. Simplified65.5%

          \[\leadsto \color{blue}{0.5 \cdot \left|y\right|} \]
      7. Recombined 2 regimes into one program.
      8. Final simplification53.7%

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

      Alternative 3: 84.3% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{-75}:\\ \;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\ \mathbf{elif}\;y \leq 8.3 \cdot 10^{-128}:\\ \;\;\;\;\mathsf{fma}\left(\left|x\right|, 0.5, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - x, 0.5, x\right)\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (<= y -1.35e-75)
         (fma (- x y) 0.5 x)
         (if (<= y 8.3e-128) (fma (fabs x) 0.5 x) (fma (- y x) 0.5 x))))
      double code(double x, double y) {
      	double tmp;
      	if (y <= -1.35e-75) {
      		tmp = fma((x - y), 0.5, x);
      	} else if (y <= 8.3e-128) {
      		tmp = fma(fabs(x), 0.5, x);
      	} else {
      		tmp = fma((y - x), 0.5, x);
      	}
      	return tmp;
      }
      
      function code(x, y)
      	tmp = 0.0
      	if (y <= -1.35e-75)
      		tmp = fma(Float64(x - y), 0.5, x);
      	elseif (y <= 8.3e-128)
      		tmp = fma(abs(x), 0.5, x);
      	else
      		tmp = fma(Float64(y - x), 0.5, x);
      	end
      	return tmp
      end
      
      code[x_, y_] := If[LessEqual[y, -1.35e-75], N[(N[(x - y), $MachinePrecision] * 0.5 + x), $MachinePrecision], If[LessEqual[y, 8.3e-128], N[(N[Abs[x], $MachinePrecision] * 0.5 + x), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * 0.5 + x), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y \leq -1.35 \cdot 10^{-75}:\\
      \;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\
      
      \mathbf{elif}\;y \leq 8.3 \cdot 10^{-128}:\\
      \;\;\;\;\mathsf{fma}\left(\left|x\right|, 0.5, x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(y - x, 0.5, x\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y < -1.3499999999999999e-75

        1. Initial program 99.9%

          \[x + \frac{\left|y - x\right|}{2} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
          2. div-invN/A

            \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
          3. accelerator-lowering-fma.f64N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
          4. fabs-lowering-fabs.f64N/A

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, 0.5, x\right)} \]
        5. Step-by-step derivation
          1. flip--N/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}}\right|, \frac{1}{2}, x\right) \]
          2. div-invN/A

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

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{1}{y + x} \cdot \left(y \cdot y - x \cdot x\right)}\right|, \frac{1}{2}, x\right) \]
          4. fabs-mulN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\left|\frac{1}{y + x}\right| \cdot \left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
          5. inv-powN/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{-1}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          6. sqr-powN/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          7. fabs-sqrN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\left({\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          8. sqr-powN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y + x\right)}^{-1}} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          9. inv-powN/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \color{blue}{\left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
          14. difference-of-squaresN/A

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \left|\color{blue}{\left(y - x\right)} \cdot \left(y + x\right)\right|, \frac{1}{2}, x\right) \]
          18. +-lowering-+.f647.5

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{x - y}, 0.5, x\right) \]

        if -1.3499999999999999e-75 < y < 8.30000000000000015e-128

        1. Initial program 99.8%

          \[x + \frac{\left|y - x\right|}{2} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
          2. div-invN/A

            \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
          3. accelerator-lowering-fma.f64N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
          4. fabs-lowering-fabs.f64N/A

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\left|\color{blue}{-1 \cdot x}\right|, \frac{1}{2}, x\right) \]
        6. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\mathsf{neg}\left(x\right)}\right|, \frac{1}{2}, x\right) \]
          2. neg-lowering-neg.f6487.8

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{-x}\right|, 0.5, x\right) \]
        7. Simplified87.8%

          \[\leadsto \mathsf{fma}\left(\left|\color{blue}{-x}\right|, 0.5, x\right) \]

        if 8.30000000000000015e-128 < y

        1. Initial program 99.9%

          \[x + \frac{\left|y - x\right|}{2} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
          2. div-invN/A

            \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
          3. accelerator-lowering-fma.f64N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
          4. fabs-lowering-fabs.f64N/A

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, 0.5, x\right)} \]
        5. Step-by-step derivation
          1. flip--N/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}}\right|, \frac{1}{2}, x\right) \]
          2. div-invN/A

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

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{1}{y + x} \cdot \left(y \cdot y - x \cdot x\right)}\right|, \frac{1}{2}, x\right) \]
          4. fabs-mulN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\left|\frac{1}{y + x}\right| \cdot \left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
          5. inv-powN/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{-1}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          6. sqr-powN/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          7. fabs-sqrN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\left({\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          8. sqr-powN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y + x\right)}^{-1}} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          9. inv-powN/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \color{blue}{\left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
          14. difference-of-squaresN/A

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \left|\color{blue}{\left(y - x\right)} \cdot \left(y + x\right)\right|, \frac{1}{2}, x\right) \]
          18. +-lowering-+.f6447.9

            \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \left|\left(y - x\right) \cdot \color{blue}{\left(y + x\right)}\right|, 0.5, x\right) \]
        6. Applied egg-rr47.9%

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{-75}:\\ \;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\ \mathbf{elif}\;y \leq 8.3 \cdot 10^{-128}:\\ \;\;\;\;\mathsf{fma}\left(\left|x\right|, 0.5, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - x, 0.5, x\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 4: 83.3% accurate, 0.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{-156}:\\ \;\;\;\;\mathsf{fma}\left(y - x, 0.5, x\right)\\ \mathbf{elif}\;x \leq 3.25 \cdot 10^{-124}:\\ \;\;\;\;\mathsf{fma}\left(\left|y\right|, 0.5, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (<= x -3.5e-156)
         (fma (- y x) 0.5 x)
         (if (<= x 3.25e-124) (fma (fabs y) 0.5 x) (fma (- x y) 0.5 x))))
      double code(double x, double y) {
      	double tmp;
      	if (x <= -3.5e-156) {
      		tmp = fma((y - x), 0.5, x);
      	} else if (x <= 3.25e-124) {
      		tmp = fma(fabs(y), 0.5, x);
      	} else {
      		tmp = fma((x - y), 0.5, x);
      	}
      	return tmp;
      }
      
      function code(x, y)
      	tmp = 0.0
      	if (x <= -3.5e-156)
      		tmp = fma(Float64(y - x), 0.5, x);
      	elseif (x <= 3.25e-124)
      		tmp = fma(abs(y), 0.5, x);
      	else
      		tmp = fma(Float64(x - y), 0.5, x);
      	end
      	return tmp
      end
      
      code[x_, y_] := If[LessEqual[x, -3.5e-156], N[(N[(y - x), $MachinePrecision] * 0.5 + x), $MachinePrecision], If[LessEqual[x, 3.25e-124], N[(N[Abs[y], $MachinePrecision] * 0.5 + x), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * 0.5 + x), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -3.5 \cdot 10^{-156}:\\
      \;\;\;\;\mathsf{fma}\left(y - x, 0.5, x\right)\\
      
      \mathbf{elif}\;x \leq 3.25 \cdot 10^{-124}:\\
      \;\;\;\;\mathsf{fma}\left(\left|y\right|, 0.5, x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if x < -3.4999999999999999e-156

        1. Initial program 100.0%

          \[x + \frac{\left|y - x\right|}{2} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
          2. div-invN/A

            \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
          3. accelerator-lowering-fma.f64N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
          4. fabs-lowering-fabs.f64N/A

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, 0.5, x\right)} \]
        5. Step-by-step derivation
          1. flip--N/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}}\right|, \frac{1}{2}, x\right) \]
          2. div-invN/A

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

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{1}{y + x} \cdot \left(y \cdot y - x \cdot x\right)}\right|, \frac{1}{2}, x\right) \]
          4. fabs-mulN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\left|\frac{1}{y + x}\right| \cdot \left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
          5. inv-powN/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{-1}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          6. sqr-powN/A

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          7. fabs-sqrN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{\left({\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          8. sqr-powN/A

            \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y + x\right)}^{-1}} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
          9. inv-powN/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \color{blue}{\left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
          14. difference-of-squaresN/A

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \left|\color{blue}{\left(y - x\right)} \cdot \left(y + x\right)\right|, \frac{1}{2}, x\right) \]
          18. +-lowering-+.f6418.9

            \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \left|\left(y - x\right) \cdot \color{blue}{\left(y + x\right)}\right|, 0.5, x\right) \]
        6. Applied egg-rr18.9%

          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{y + x} \cdot \left|\left(y - x\right) \cdot \left(y + x\right)\right|}, 0.5, x\right) \]
        7. Applied egg-rr88.3%

          \[\leadsto \mathsf{fma}\left(\color{blue}{y - x}, 0.5, x\right) \]

        if -3.4999999999999999e-156 < x < 3.24999999999999994e-124

        1. Initial program 99.9%

          \[x + \frac{\left|y - x\right|}{2} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
          2. div-invN/A

            \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
          3. accelerator-lowering-fma.f64N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
          4. fabs-lowering-fabs.f64N/A

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\left|\color{blue}{y}\right|, \frac{1}{2}, x\right) \]
        6. Step-by-step derivation
          1. Simplified91.7%

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{y}\right|, 0.5, x\right) \]

          if 3.24999999999999994e-124 < x

          1. Initial program 99.7%

            \[x + \frac{\left|y - x\right|}{2} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
            2. div-invN/A

              \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
            3. accelerator-lowering-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
            4. fabs-lowering-fabs.f64N/A

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, 0.5, x\right)} \]
          5. Step-by-step derivation
            1. flip--N/A

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}}\right|, \frac{1}{2}, x\right) \]
            2. div-invN/A

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

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{1}{y + x} \cdot \left(y \cdot y - x \cdot x\right)}\right|, \frac{1}{2}, x\right) \]
            4. fabs-mulN/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\left|\frac{1}{y + x}\right| \cdot \left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
            5. inv-powN/A

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{-1}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
            6. sqr-powN/A

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
            7. fabs-sqrN/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\left({\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
            8. sqr-powN/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y + x\right)}^{-1}} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
            9. inv-powN/A

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \color{blue}{\left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
            14. difference-of-squaresN/A

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \left|\color{blue}{\left(y - x\right)} \cdot \left(y + x\right)\right|, \frac{1}{2}, x\right) \]
            18. +-lowering-+.f6441.9

              \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \left|\left(y - x\right) \cdot \color{blue}{\left(y + x\right)}\right|, 0.5, x\right) \]
          6. Applied egg-rr41.9%

            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{y + x} \cdot \left|\left(y - x\right) \cdot \left(y + x\right)\right|}, 0.5, x\right) \]
          7. Applied egg-rr84.3%

            \[\leadsto \mathsf{fma}\left(\color{blue}{x - y}, 0.5, x\right) \]
        7. Recombined 3 regimes into one program.
        8. Add Preprocessing

        Alternative 5: 72.3% accurate, 1.2× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 2.25 \cdot 10^{-128}:\\ \;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left|y\right|, 0.5, x\right)\\ \end{array} \end{array} \]
        (FPCore (x y)
         :precision binary64
         (if (<= y 2.25e-128) (fma (- x y) 0.5 x) (fma (fabs y) 0.5 x)))
        double code(double x, double y) {
        	double tmp;
        	if (y <= 2.25e-128) {
        		tmp = fma((x - y), 0.5, x);
        	} else {
        		tmp = fma(fabs(y), 0.5, x);
        	}
        	return tmp;
        }
        
        function code(x, y)
        	tmp = 0.0
        	if (y <= 2.25e-128)
        		tmp = fma(Float64(x - y), 0.5, x);
        	else
        		tmp = fma(abs(y), 0.5, x);
        	end
        	return tmp
        end
        
        code[x_, y_] := If[LessEqual[y, 2.25e-128], N[(N[(x - y), $MachinePrecision] * 0.5 + x), $MachinePrecision], N[(N[Abs[y], $MachinePrecision] * 0.5 + x), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;y \leq 2.25 \cdot 10^{-128}:\\
        \;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\mathsf{fma}\left(\left|y\right|, 0.5, x\right)\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < 2.25e-128

          1. Initial program 99.8%

            \[x + \frac{\left|y - x\right|}{2} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
            2. div-invN/A

              \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
            3. accelerator-lowering-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
            4. fabs-lowering-fabs.f64N/A

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, 0.5, x\right)} \]
          5. Step-by-step derivation
            1. flip--N/A

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}}\right|, \frac{1}{2}, x\right) \]
            2. div-invN/A

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

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\frac{1}{y + x} \cdot \left(y \cdot y - x \cdot x\right)}\right|, \frac{1}{2}, x\right) \]
            4. fabs-mulN/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\left|\frac{1}{y + x}\right| \cdot \left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
            5. inv-powN/A

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{-1}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
            6. sqr-powN/A

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{{\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}}\right| \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
            7. fabs-sqrN/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\left({\left(y + x\right)}^{\left(\frac{-1}{2}\right)} \cdot {\left(y + x\right)}^{\left(\frac{-1}{2}\right)}\right)} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
            8. sqr-powN/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y + x\right)}^{-1}} \cdot \left|y \cdot y - x \cdot x\right|, \frac{1}{2}, x\right) \]
            9. inv-powN/A

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \color{blue}{\left|y \cdot y - x \cdot x\right|}, \frac{1}{2}, x\right) \]
            14. difference-of-squaresN/A

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{1}{y + x} \cdot \left|\color{blue}{\left(y - x\right)} \cdot \left(y + x\right)\right|, \frac{1}{2}, x\right) \]
            18. +-lowering-+.f6421.0

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{1}{y + x} \cdot \left|\left(y - x\right) \cdot \left(y + x\right)\right|}, 0.5, x\right) \]
          7. Applied egg-rr72.8%

            \[\leadsto \mathsf{fma}\left(\color{blue}{x - y}, 0.5, x\right) \]

          if 2.25e-128 < y

          1. Initial program 99.9%

            \[x + \frac{\left|y - x\right|}{2} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
            2. div-invN/A

              \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
            3. accelerator-lowering-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
            4. fabs-lowering-fabs.f64N/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{y}\right|, \frac{1}{2}, x\right) \]
          6. Step-by-step derivation
            1. Simplified79.8%

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{y}\right|, 0.5, x\right) \]
          7. Recombined 2 regimes into one program.
          8. Add Preprocessing

          Alternative 6: 59.5% accurate, 2.2× speedup?

          \[\begin{array}{l} \\ \mathsf{fma}\left(\left|y\right|, 0.5, x\right) \end{array} \]
          (FPCore (x y) :precision binary64 (fma (fabs y) 0.5 x))
          double code(double x, double y) {
          	return fma(fabs(y), 0.5, x);
          }
          
          function code(x, y)
          	return fma(abs(y), 0.5, x)
          end
          
          code[x_, y_] := N[(N[Abs[y], $MachinePrecision] * 0.5 + x), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \mathsf{fma}\left(\left|y\right|, 0.5, x\right)
          \end{array}
          
          Derivation
          1. Initial program 99.9%

            \[x + \frac{\left|y - x\right|}{2} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{\left|y - x\right|}{2} + x} \]
            2. div-invN/A

              \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} + x \]
            3. accelerator-lowering-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\left|y - x\right|, \frac{1}{2}, x\right)} \]
            4. fabs-lowering-fabs.f64N/A

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\left|\color{blue}{y}\right|, \frac{1}{2}, x\right) \]
          6. Step-by-step derivation
            1. Simplified57.5%

              \[\leadsto \mathsf{fma}\left(\left|\color{blue}{y}\right|, 0.5, x\right) \]
            2. Add Preprocessing

            Alternative 7: 11.2% accurate, 20.0× speedup?

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

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

              \[\leadsto \color{blue}{x} \]
            4. Step-by-step derivation
              1. Simplified11.3%

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

              Reproduce

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