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

Percentage Accurate: 99.9% → 99.9%
Time: 8.9s
Alternatives: 5
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 5 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|y - x\right|, 0.5, x\right) \end{array} \]
(FPCore (x y) :precision binary64 (fma (fabs (- y x)) 0.5 x))
double code(double x, double y) {
	return fma(fabs((y - x)), 0.5, x);
}
function code(x, y)
	return fma(abs(Float64(y - x)), 0.5, x)
end
code[x_, y_] := N[(N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] * 0.5 + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\left|y - x\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. lift-+.f64N/A

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left|\mathsf{neg}\left(\color{blue}{\left(y - x\right)}\right)\right|, \frac{1}{2}, x\right) \]
    10. sub-negN/A

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

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

      \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right)}\right|, \frac{1}{2}, x\right) \]
    13. remove-double-negN/A

      \[\leadsto \mathsf{fma}\left(\left|\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right|, \frac{1}{2}, x\right) \]
    14. sub-negN/A

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

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

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

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

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

Alternative 2: 71.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 4.1 \cdot 10^{-69}:\\ \;\;\;\;\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 4.1e-69) (fma (fabs (- y)) 0.5 x) (fma (- x y) 0.5 x)))
double code(double x, double y) {
	double tmp;
	if (x <= 4.1e-69) {
		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 <= 4.1e-69)
		tmp = fma(abs(Float64(-y)), 0.5, x);
	else
		tmp = fma(Float64(x - y), 0.5, x);
	end
	return tmp
end
code[x_, y_] := If[LessEqual[x, 4.1e-69], 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 4.1 \cdot 10^{-69}:\\
\;\;\;\;\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 2 regimes
  2. if x < 4.0999999999999999e-69

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left|\mathsf{neg}\left(\color{blue}{\left(y - x\right)}\right)\right|, \frac{1}{2}, x\right) \]
      10. sub-negN/A

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

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

        \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right)}\right|, \frac{1}{2}, x\right) \]
      13. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(\left|\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right|, \frac{1}{2}, x\right) \]
      14. sub-negN/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left|\color{blue}{-1 \cdot y}\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(y\right)}\right|, \frac{1}{2}, x\right) \]
      2. lower-neg.f6467.4

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

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

    if 4.0999999999999999e-69 < x

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left|\mathsf{neg}\left(\color{blue}{\left(y - x\right)}\right)\right|, \frac{1}{2}, x\right) \]
      10. sub-negN/A

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

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

        \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right)}\right|, \frac{1}{2}, x\right) \]
      13. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(\left|\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right|, \frac{1}{2}, x\right) \]
      14. sub-negN/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left({\left(\left|x - y\right|\right)}^{\color{blue}{\left(\frac{1}{2} + \frac{1}{2}\right)}}, \frac{1}{2}, x\right) \]
      3. pow-prod-upN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{\color{blue}{\left|y - x\right|}} \cdot {\left(\left|x - y\right|\right)}^{\frac{1}{2}}, \frac{1}{2}, x\right) \]
      12. unpow1/2N/A

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

        \[\leadsto \mathsf{fma}\left(\sqrt{\left|y - x\right|} \cdot \color{blue}{\sqrt{\left|x - y\right|}}, 0.5, x\right) \]
      14. lift-fabs.f64N/A

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

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

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

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

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

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

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

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

Alternative 3: 70.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{-41}:\\
\;\;\;\;\mathsf{fma}\left(x - y, 0.5, x\right)\\

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left|\mathsf{neg}\left(\color{blue}{\left(y - x\right)}\right)\right|, \frac{1}{2}, x\right) \]
      10. sub-negN/A

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

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

        \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right)}\right|, \frac{1}{2}, x\right) \]
      13. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(\left|\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right|, \frac{1}{2}, x\right) \]
      14. sub-negN/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left({\left(\left|x - y\right|\right)}^{\color{blue}{\left(\frac{1}{2} + \frac{1}{2}\right)}}, \frac{1}{2}, x\right) \]
      3. pow-prod-upN/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{\color{blue}{\left|y - x\right|}} \cdot {\left(\left|x - y\right|\right)}^{\frac{1}{2}}, \frac{1}{2}, x\right) \]
      12. unpow1/2N/A

        \[\leadsto \mathsf{fma}\left(\sqrt{\left|y - x\right|} \cdot \color{blue}{\sqrt{\left|x - y\right|}}, \frac{1}{2}, x\right) \]
      13. lower-sqrt.f6499.3

        \[\leadsto \mathsf{fma}\left(\sqrt{\left|y - x\right|} \cdot \color{blue}{\sqrt{\left|x - y\right|}}, 0.5, x\right) \]
      14. lift-fabs.f64N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{\left|y - x\right|} \cdot \sqrt{\left|\color{blue}{y - x}\right|}, \frac{1}{2}, x\right) \]
      18. lift-fabs.f6499.3

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

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

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

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

    if 2.8000000000000002e-41 < y

    1. Initial program 99.9%

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

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

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

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

        \[\leadsto \left|y + \color{blue}{-1 \cdot x}\right| \cdot \frac{1}{2} \]
      4. lower-*.f64N/A

        \[\leadsto \color{blue}{\left|y + -1 \cdot x\right| \cdot \frac{1}{2}} \]
      5. mul-1-negN/A

        \[\leadsto \left|y + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right| \cdot \frac{1}{2} \]
      6. remove-double-negN/A

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

        \[\leadsto \left|\left(\mathsf{neg}\left(\color{blue}{-1 \cdot y}\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right| \cdot \frac{1}{2} \]
      8. distribute-neg-inN/A

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

        \[\leadsto \left|\mathsf{neg}\left(\color{blue}{\left(x + -1 \cdot y\right)}\right)\right| \cdot \frac{1}{2} \]
      10. lower-fabs.f64N/A

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

        \[\leadsto \left|\mathsf{neg}\left(\color{blue}{\left(-1 \cdot y + x\right)}\right)\right| \cdot \frac{1}{2} \]
      12. distribute-neg-inN/A

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

        \[\leadsto \left|\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right| \cdot \frac{1}{2} \]
      14. remove-double-negN/A

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

        \[\leadsto \left|\color{blue}{y - x}\right| \cdot \frac{1}{2} \]
      16. lower--.f6469.4

        \[\leadsto \left|\color{blue}{y - x}\right| \cdot 0.5 \]
    5. Applied rewrites69.4%

      \[\leadsto \color{blue}{\left|y - x\right| \cdot 0.5} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 54.7% accurate, 2.0× speedup?

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

\\
\mathsf{fma}\left(x - y, 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. lift-+.f64N/A

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left|\mathsf{neg}\left(\color{blue}{\left(y - x\right)}\right)\right|, \frac{1}{2}, x\right) \]
    10. sub-negN/A

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

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

      \[\leadsto \mathsf{fma}\left(\left|\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right)}\right|, \frac{1}{2}, x\right) \]
    13. remove-double-negN/A

      \[\leadsto \mathsf{fma}\left(\left|\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right|, \frac{1}{2}, x\right) \]
    14. sub-negN/A

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left({\left(\left|x - y\right|\right)}^{\color{blue}{\left(\frac{1}{2} + \frac{1}{2}\right)}}, \frac{1}{2}, x\right) \]
    3. pow-prod-upN/A

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\sqrt{\color{blue}{\left|y - x\right|}} \cdot {\left(\left|x - y\right|\right)}^{\frac{1}{2}}, \frac{1}{2}, x\right) \]
    12. unpow1/2N/A

      \[\leadsto \mathsf{fma}\left(\sqrt{\left|y - x\right|} \cdot \color{blue}{\sqrt{\left|x - y\right|}}, \frac{1}{2}, x\right) \]
    13. lower-sqrt.f6499.3

      \[\leadsto \mathsf{fma}\left(\sqrt{\left|y - x\right|} \cdot \color{blue}{\sqrt{\left|x - y\right|}}, 0.5, x\right) \]
    14. lift-fabs.f64N/A

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

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

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

      \[\leadsto \mathsf{fma}\left(\sqrt{\left|y - x\right|} \cdot \sqrt{\left|\color{blue}{y - x}\right|}, \frac{1}{2}, x\right) \]
    18. lift-fabs.f6499.3

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

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

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

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

Alternative 5: 7.1% accurate, 2.0× speedup?

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

\\
\left|-x\right| \cdot 0.5
\end{array}
Derivation
  1. Initial program 99.9%

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

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

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

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

      \[\leadsto \left|y + \color{blue}{-1 \cdot x}\right| \cdot \frac{1}{2} \]
    4. lower-*.f64N/A

      \[\leadsto \color{blue}{\left|y + -1 \cdot x\right| \cdot \frac{1}{2}} \]
    5. mul-1-negN/A

      \[\leadsto \left|y + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right| \cdot \frac{1}{2} \]
    6. remove-double-negN/A

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

      \[\leadsto \left|\left(\mathsf{neg}\left(\color{blue}{-1 \cdot y}\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right| \cdot \frac{1}{2} \]
    8. distribute-neg-inN/A

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

      \[\leadsto \left|\mathsf{neg}\left(\color{blue}{\left(x + -1 \cdot y\right)}\right)\right| \cdot \frac{1}{2} \]
    10. lower-fabs.f64N/A

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

      \[\leadsto \left|\mathsf{neg}\left(\color{blue}{\left(-1 \cdot y + x\right)}\right)\right| \cdot \frac{1}{2} \]
    12. distribute-neg-inN/A

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

      \[\leadsto \left|\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right| \cdot \frac{1}{2} \]
    14. remove-double-negN/A

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

      \[\leadsto \left|\color{blue}{y - x}\right| \cdot \frac{1}{2} \]
    16. lower--.f6452.9

      \[\leadsto \left|\color{blue}{y - x}\right| \cdot 0.5 \]
  5. Applied rewrites52.9%

    \[\leadsto \color{blue}{\left|y - x\right| \cdot 0.5} \]
  6. Taylor expanded in y around 0

    \[\leadsto \left|-1 \cdot x\right| \cdot \frac{1}{2} \]
  7. Step-by-step derivation
    1. Applied rewrites7.4%

      \[\leadsto \left|-x\right| \cdot 0.5 \]
    2. Add Preprocessing

    Reproduce

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