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

Percentage Accurate: 99.9% → 99.9%
Time: 8.2s
Alternatives: 7
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 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.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. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 55.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{-127}:\\
\;\;\;\;0.5 \cdot \left|y - x\right|\\

\mathbf{else}:\\
\;\;\;\;x \cdot 0.75 + y \cdot 0.5\\


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

    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. sub-negN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left|y + \left(\mathsf{neg}\left(x\right)\right)\right|\right)\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left|y - x\right|\right)\right) \]
      6. fabs-subN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left|x - y\right|\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left|x + \left(\mathsf{neg}\left(y\right)\right)\right|\right)\right) \]
      8. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left|x + -1 \cdot y\right|\right)\right) \]
      9. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{fabs.f64}\left(\left(x + -1 \cdot y\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{fabs.f64}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)\right) \]
      11. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{fabs.f64}\left(\left(x - y\right)\right)\right) \]
      12. --lowering--.f6470.3%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(x, y\right)\right)\right) \]
    5. Simplified70.3%

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

    if -6.40000000000000035e-127 < 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 \frac{\left|y - x\right|}{2} + \color{blue}{x} \]
      2. flip-+N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{\left|y - x\right|}{2} \cdot \frac{\left|y - x\right|}{2}\right), \left(x \cdot x\right)\right), \left(\color{blue}{\frac{\left|y - x\right|}{2}} - x\right)\right) \]
      5. frac-timesN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{\left|y - x\right| \cdot \left|y - x\right|}{2 \cdot 2}\right), \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\left|y - x\right|}}{2} - x\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left|y - x\right| \cdot \left|y - x\right|\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\left|y - x\right|}}{2} - x\right)\right) \]
      7. sqr-absN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left(y - x\right) \cdot \left(y - x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|\color{blue}{y - x}\right|}{2} - x\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(y - x\right), \left(y - x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|\color{blue}{y - x}\right|}{2} - x\right)\right) \]
      9. --lowering--.f64N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|y - \color{blue}{x}\right|}{2} - x\right)\right) \]
      11. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \left(x \cdot x\right)\right), \left(\frac{\left|y - x\right|}{2} - x\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\frac{\left|y - x\right|}{\color{blue}{2}} - x\right)\right) \]
      13. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\left(\frac{\left|y - x\right|}{2}\right), \color{blue}{x}\right)\right) \]
      14. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left|y - x\right|\right), 2\right), x\right)\right) \]
      15. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\left(y - x\right)\right), 2\right), x\right)\right) \]
      16. --lowering--.f6450.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(y, x\right)\right), 2\right), x\right)\right) \]
    4. Applied egg-rr50.6%

      \[\leadsto \color{blue}{\frac{\frac{\left(y - x\right) \cdot \left(y - x\right)}{4} - x \cdot x}{\frac{\left|y - x\right|}{2} - x}} \]
    5. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \color{blue}{\left(-1 \cdot x\right)}\right) \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\mathsf{neg}\left(x\right)\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(0 - \color{blue}{x}\right)\right) \]
      3. --lowering--.f647.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(0, \color{blue}{x}\right)\right) \]
    7. Simplified7.3%

      \[\leadsto \frac{\frac{\left(y - x\right) \cdot \left(y - x\right)}{4} - x \cdot x}{\color{blue}{0 - x}} \]
    8. Taylor expanded in y around 0

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

        \[\leadsto \frac{\frac{1}{4} \cdot {x}^{2} - {x}^{2}}{x} \cdot -1 + \color{blue}{\frac{1}{2}} \cdot y \]
    10. Simplified47.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{-127}:\\ \;\;\;\;0.5 \cdot \left|y - x\right|\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.75 + y \cdot 0.5\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 54.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{-127}:\\
\;\;\;\;\left|y\right| \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;x \cdot 0.75 + y \cdot 0.5\\


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

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{+.f64}\left(x, \mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\color{blue}{y}\right), 2\right)\right) \]
    4. Step-by-step derivation
      1. Simplified73.6%

        \[\leadsto x + \frac{\left|\color{blue}{y}\right|}{2} \]
      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 \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\left|y\right|\right)}\right) \]
        2. fabs-lowering-fabs.f6468.3%

          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{fabs.f64}\left(y\right)\right) \]
      4. Simplified68.3%

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

      if -6.40000000000000035e-127 < 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 \frac{\left|y - x\right|}{2} + \color{blue}{x} \]
        2. flip-+N/A

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{\left|y - x\right|}{2} \cdot \frac{\left|y - x\right|}{2}\right), \left(x \cdot x\right)\right), \left(\color{blue}{\frac{\left|y - x\right|}{2}} - x\right)\right) \]
        5. frac-timesN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{\left|y - x\right| \cdot \left|y - x\right|}{2 \cdot 2}\right), \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\left|y - x\right|}}{2} - x\right)\right) \]
        6. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left|y - x\right| \cdot \left|y - x\right|\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\left|y - x\right|}}{2} - x\right)\right) \]
        7. sqr-absN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left(y - x\right) \cdot \left(y - x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|\color{blue}{y - x}\right|}{2} - x\right)\right) \]
        8. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(y - x\right), \left(y - x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|\color{blue}{y - x}\right|}{2} - x\right)\right) \]
        9. --lowering--.f64N/A

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|y - \color{blue}{x}\right|}{2} - x\right)\right) \]
        11. metadata-evalN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \left(x \cdot x\right)\right), \left(\frac{\left|y - x\right|}{2} - x\right)\right) \]
        12. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\frac{\left|y - x\right|}{\color{blue}{2}} - x\right)\right) \]
        13. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\left(\frac{\left|y - x\right|}{2}\right), \color{blue}{x}\right)\right) \]
        14. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left|y - x\right|\right), 2\right), x\right)\right) \]
        15. fabs-lowering-fabs.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\left(y - x\right)\right), 2\right), x\right)\right) \]
        16. --lowering--.f6450.6%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(y, x\right)\right), 2\right), x\right)\right) \]
      4. Applied egg-rr50.6%

        \[\leadsto \color{blue}{\frac{\frac{\left(y - x\right) \cdot \left(y - x\right)}{4} - x \cdot x}{\frac{\left|y - x\right|}{2} - x}} \]
      5. Taylor expanded in x around inf

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \color{blue}{\left(-1 \cdot x\right)}\right) \]
      6. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\mathsf{neg}\left(x\right)\right)\right) \]
        2. neg-sub0N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(0 - \color{blue}{x}\right)\right) \]
        3. --lowering--.f647.3%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(0, \color{blue}{x}\right)\right) \]
      7. Simplified7.3%

        \[\leadsto \frac{\frac{\left(y - x\right) \cdot \left(y - x\right)}{4} - x \cdot x}{\color{blue}{0 - x}} \]
      8. Taylor expanded in y around 0

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

          \[\leadsto \frac{\frac{1}{4} \cdot {x}^{2} - {x}^{2}}{x} \cdot -1 + \color{blue}{\frac{1}{2}} \cdot y \]
      10. Simplified47.7%

        \[\leadsto \color{blue}{x \cdot 0.75 + y \cdot 0.5} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification55.1%

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.4 \cdot 10^{-127}:\\ \;\;\;\;\left|y\right| \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.75 + y \cdot 0.5\\ \end{array} \]
    7. Add Preprocessing

    Alternative 4: 58.5% accurate, 1.0× speedup?

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

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

      \[\leadsto \mathsf{+.f64}\left(x, \mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\color{blue}{y}\right), 2\right)\right) \]
    4. Step-by-step derivation
      1. Simplified57.4%

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

      Alternative 5: 34.5% accurate, 15.3× speedup?

      \[\begin{array}{l} \\ x \cdot 0.75 + y \cdot 0.5 \end{array} \]
      (FPCore (x y) :precision binary64 (+ (* x 0.75) (* y 0.5)))
      double code(double x, double y) {
      	return (x * 0.75) + (y * 0.5);
      }
      
      real(8) function code(x, y)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          code = (x * 0.75d0) + (y * 0.5d0)
      end function
      
      public static double code(double x, double y) {
      	return (x * 0.75) + (y * 0.5);
      }
      
      def code(x, y):
      	return (x * 0.75) + (y * 0.5)
      
      function code(x, y)
      	return Float64(Float64(x * 0.75) + Float64(y * 0.5))
      end
      
      function tmp = code(x, y)
      	tmp = (x * 0.75) + (y * 0.5);
      end
      
      code[x_, y_] := N[(N[(x * 0.75), $MachinePrecision] + N[(y * 0.5), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      x \cdot 0.75 + y \cdot 0.5
      \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 \frac{\left|y - x\right|}{2} + \color{blue}{x} \]
        2. flip-+N/A

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{\left|y - x\right|}{2} \cdot \frac{\left|y - x\right|}{2}\right), \left(x \cdot x\right)\right), \left(\color{blue}{\frac{\left|y - x\right|}{2}} - x\right)\right) \]
        5. frac-timesN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{\left|y - x\right| \cdot \left|y - x\right|}{2 \cdot 2}\right), \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\left|y - x\right|}}{2} - x\right)\right) \]
        6. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left|y - x\right| \cdot \left|y - x\right|\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\left|y - x\right|}}{2} - x\right)\right) \]
        7. sqr-absN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left(y - x\right) \cdot \left(y - x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|\color{blue}{y - x}\right|}{2} - x\right)\right) \]
        8. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(y - x\right), \left(y - x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|\color{blue}{y - x}\right|}{2} - x\right)\right) \]
        9. --lowering--.f64N/A

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|y - \color{blue}{x}\right|}{2} - x\right)\right) \]
        11. metadata-evalN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \left(x \cdot x\right)\right), \left(\frac{\left|y - x\right|}{2} - x\right)\right) \]
        12. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\frac{\left|y - x\right|}{\color{blue}{2}} - x\right)\right) \]
        13. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\left(\frac{\left|y - x\right|}{2}\right), \color{blue}{x}\right)\right) \]
        14. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left|y - x\right|\right), 2\right), x\right)\right) \]
        15. fabs-lowering-fabs.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\left(y - x\right)\right), 2\right), x\right)\right) \]
        16. --lowering--.f6448.4%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(y, x\right)\right), 2\right), x\right)\right) \]
      4. Applied egg-rr48.4%

        \[\leadsto \color{blue}{\frac{\frac{\left(y - x\right) \cdot \left(y - x\right)}{4} - x \cdot x}{\frac{\left|y - x\right|}{2} - x}} \]
      5. Taylor expanded in x around inf

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \color{blue}{\left(-1 \cdot x\right)}\right) \]
      6. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\mathsf{neg}\left(x\right)\right)\right) \]
        2. neg-sub0N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(0 - \color{blue}{x}\right)\right) \]
        3. --lowering--.f646.4%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(0, \color{blue}{x}\right)\right) \]
      7. Simplified6.4%

        \[\leadsto \frac{\frac{\left(y - x\right) \cdot \left(y - x\right)}{4} - x \cdot x}{\color{blue}{0 - x}} \]
      8. Taylor expanded in y around 0

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

          \[\leadsto \frac{\frac{1}{4} \cdot {x}^{2} - {x}^{2}}{x} \cdot -1 + \color{blue}{\frac{1}{2}} \cdot y \]
      10. Simplified33.0%

        \[\leadsto \color{blue}{x \cdot 0.75 + y \cdot 0.5} \]
      11. Add Preprocessing

      Alternative 6: 11.4% accurate, 35.7× speedup?

      \[\begin{array}{l} \\ x \cdot 0.75 \end{array} \]
      (FPCore (x y) :precision binary64 (* x 0.75))
      double code(double x, double y) {
      	return x * 0.75;
      }
      
      real(8) function code(x, y)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          code = x * 0.75d0
      end function
      
      public static double code(double x, double y) {
      	return x * 0.75;
      }
      
      def code(x, y):
      	return x * 0.75
      
      function code(x, y)
      	return Float64(x * 0.75)
      end
      
      function tmp = code(x, y)
      	tmp = x * 0.75;
      end
      
      code[x_, y_] := N[(x * 0.75), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      x \cdot 0.75
      \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 \frac{\left|y - x\right|}{2} + \color{blue}{x} \]
        2. flip-+N/A

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{\left|y - x\right|}{2} \cdot \frac{\left|y - x\right|}{2}\right), \left(x \cdot x\right)\right), \left(\color{blue}{\frac{\left|y - x\right|}{2}} - x\right)\right) \]
        5. frac-timesN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{\left|y - x\right| \cdot \left|y - x\right|}{2 \cdot 2}\right), \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\left|y - x\right|}}{2} - x\right)\right) \]
        6. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left|y - x\right| \cdot \left|y - x\right|\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\color{blue}{\left|y - x\right|}}{2} - x\right)\right) \]
        7. sqr-absN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left(y - x\right) \cdot \left(y - x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|\color{blue}{y - x}\right|}{2} - x\right)\right) \]
        8. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(y - x\right), \left(y - x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|\color{blue}{y - x}\right|}{2} - x\right)\right) \]
        9. --lowering--.f64N/A

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), \left(2 \cdot 2\right)\right), \left(x \cdot x\right)\right), \left(\frac{\left|y - \color{blue}{x}\right|}{2} - x\right)\right) \]
        11. metadata-evalN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \left(x \cdot x\right)\right), \left(\frac{\left|y - x\right|}{2} - x\right)\right) \]
        12. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \left(\frac{\left|y - x\right|}{\color{blue}{2}} - x\right)\right) \]
        13. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\left(\frac{\left|y - x\right|}{2}\right), \color{blue}{x}\right)\right) \]
        14. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\left(\left|y - x\right|\right), 2\right), x\right)\right) \]
        15. fabs-lowering-fabs.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\left(y - x\right)\right), 2\right), x\right)\right) \]
        16. --lowering--.f6448.4%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, x\right)\right), 4\right), \mathsf{*.f64}\left(x, x\right)\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(y, x\right)\right), 2\right), x\right)\right) \]
      4. Applied egg-rr48.4%

        \[\leadsto \color{blue}{\frac{\frac{\left(y - x\right) \cdot \left(y - x\right)}{4} - x \cdot x}{\frac{\left|y - x\right|}{2} - x}} \]
      5. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{3}{4} \cdot x} \]
      6. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto x \cdot \color{blue}{\frac{3}{4}} \]
        2. *-lowering-*.f6411.5%

          \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\frac{3}{4}}\right) \]
      7. Simplified11.5%

        \[\leadsto \color{blue}{x \cdot 0.75} \]
      8. Add Preprocessing

      Alternative 7: 11.4% accurate, 107.0× speedup?

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

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

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

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

        Reproduce

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