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

Percentage Accurate: 99.9% → 99.9%
Time: 7.8s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

\\
x + \frac{\left|y - x\right|}{2}
\end{array}

Alternative 1: 99.9% accurate, 1.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. Taylor expanded in x around 0

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left|x - \left(\mathsf{neg}\left(-1\right)\right) \cdot y\right|}, \frac{1}{2}, x\right) \]
    7. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

Alternative 2: 49.2% accurate, 0.6× speedup?

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

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

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


\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))) < 5.00000000000000008e-252

    1. Initial program 100.0%

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

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

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

        \[\leadsto x + \frac{\sqrt{\color{blue}{\left(y - x\right)} \cdot \left(y - x\right)}}{2} \]
      4. flip--N/A

        \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \cdot \left(y - x\right)}}{2} \]
      5. lift--.f64N/A

        \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\left(y - x\right)}}}{2} \]
      6. flip3--N/A

        \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\frac{{y}^{3} - {x}^{3}}{y \cdot y + \left(x \cdot x + y \cdot x\right)}}}}{2} \]
      7. frac-timesN/A

        \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
      8. sqrt-divN/A

        \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
      9. lower-/.f64N/A

        \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
    4. Applied rewrites0.0%

      \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(\left(y + x\right) \cdot \left(y - x\right)\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \mathsf{fma}\left(y + x, x, y \cdot y\right)}}}}{2} \]
    5. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
    6. Step-by-step derivation
      1. lower-*.f643.8

        \[\leadsto \color{blue}{0.5 \cdot y} \]
    7. Applied rewrites3.8%

      \[\leadsto \color{blue}{0.5 \cdot y} \]
    8. Taylor expanded in x around 0

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

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

        \[\leadsto \color{blue}{\left(1 + \frac{1}{4} \cdot \frac{-1 \cdot y - y}{y}\right) \cdot x} + \frac{1}{2} \cdot y \]
      3. div-subN/A

        \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{\left(\frac{-1 \cdot y}{y} - \frac{y}{y}\right)}\right) \cdot x + \frac{1}{2} \cdot y \]
      4. associate-/l*N/A

        \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1 \cdot \frac{y}{y}} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
      5. *-inversesN/A

        \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 \cdot \color{blue}{1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
      6. metadata-evalN/A

        \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
      7. *-inversesN/A

        \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 - \color{blue}{1}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
      8. metadata-evalN/A

        \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{-2}\right) \cdot x + \frac{1}{2} \cdot y \]
      9. metadata-evalN/A

        \[\leadsto \left(1 + \color{blue}{\frac{-1}{2}}\right) \cdot x + \frac{1}{2} \cdot y \]
      10. metadata-evalN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, x, \frac{1}{2} \cdot y\right)} \]
      12. lower-*.f6493.9

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

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

      \[\leadsto \frac{1}{2} \cdot \color{blue}{x} \]
    12. Step-by-step derivation
      1. Applied rewrites92.8%

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

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

      1. Initial program 99.9%

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

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

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

          \[\leadsto x + \frac{\sqrt{\color{blue}{\left(y - x\right)} \cdot \left(y - x\right)}}{2} \]
        4. flip--N/A

          \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \cdot \left(y - x\right)}}{2} \]
        5. lift--.f64N/A

          \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\left(y - x\right)}}}{2} \]
        6. flip3--N/A

          \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\frac{{y}^{3} - {x}^{3}}{y \cdot y + \left(x \cdot x + y \cdot x\right)}}}}{2} \]
        7. frac-timesN/A

          \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
        8. sqrt-divN/A

          \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
        9. lower-/.f64N/A

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

        \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(\left(y + x\right) \cdot \left(y - x\right)\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \mathsf{fma}\left(y + x, x, y \cdot y\right)}}}}{2} \]
      5. Taylor expanded in x around 0

        \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
      6. Step-by-step derivation
        1. lower-*.f6433.5

          \[\leadsto \color{blue}{0.5 \cdot y} \]
      7. Applied rewrites33.5%

        \[\leadsto \color{blue}{0.5 \cdot y} \]
    13. Recombined 2 regimes into one program.
    14. Add Preprocessing

    Alternative 3: 81.5% accurate, 0.9× speedup?

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

      1. Initial program 100.0%

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

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

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

          \[\leadsto x + \frac{\sqrt{\color{blue}{\left(y - x\right)} \cdot \left(y - x\right)}}{2} \]
        4. flip--N/A

          \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \cdot \left(y - x\right)}}{2} \]
        5. lift--.f64N/A

          \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\left(y - x\right)}}}{2} \]
        6. flip3--N/A

          \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\frac{{y}^{3} - {x}^{3}}{y \cdot y + \left(x \cdot x + y \cdot x\right)}}}}{2} \]
        7. frac-timesN/A

          \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
        8. sqrt-divN/A

          \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
        9. lower-/.f64N/A

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

        \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(\left(y + x\right) \cdot \left(y - x\right)\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \mathsf{fma}\left(y + x, x, y \cdot y\right)}}}}{2} \]
      5. Taylor expanded in x around 0

        \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
      6. Step-by-step derivation
        1. lower-*.f6418.1

          \[\leadsto \color{blue}{0.5 \cdot y} \]
      7. Applied rewrites18.1%

        \[\leadsto \color{blue}{0.5 \cdot y} \]
      8. Taylor expanded in x around 0

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

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

          \[\leadsto \color{blue}{\left(1 + \frac{1}{4} \cdot \frac{-1 \cdot y - y}{y}\right) \cdot x} + \frac{1}{2} \cdot y \]
        3. div-subN/A

          \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{\left(\frac{-1 \cdot y}{y} - \frac{y}{y}\right)}\right) \cdot x + \frac{1}{2} \cdot y \]
        4. associate-/l*N/A

          \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1 \cdot \frac{y}{y}} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
        5. *-inversesN/A

          \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 \cdot \color{blue}{1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
        6. metadata-evalN/A

          \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
        7. *-inversesN/A

          \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 - \color{blue}{1}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
        8. metadata-evalN/A

          \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{-2}\right) \cdot x + \frac{1}{2} \cdot y \]
        9. metadata-evalN/A

          \[\leadsto \left(1 + \color{blue}{\frac{-1}{2}}\right) \cdot x + \frac{1}{2} \cdot y \]
        10. metadata-evalN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, x, \frac{1}{2} \cdot y\right)} \]
        12. lower-*.f6485.6

          \[\leadsto \mathsf{fma}\left(0.5, x, \color{blue}{0.5 \cdot y}\right) \]
      10. Applied rewrites85.6%

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

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

          \[\leadsto \frac{1}{2} \cdot y + \color{blue}{\left(1 + \frac{1}{4} \cdot \frac{-1 \cdot y - y}{y}\right) \cdot x} \]
        2. div-subN/A

          \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \color{blue}{\left(\frac{-1 \cdot y}{y} - \frac{y}{y}\right)}\right) \cdot x \]
        3. *-inversesN/A

          \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(\frac{-1 \cdot y}{y} - \color{blue}{1}\right)\right) \cdot x \]
        4. associate-/l*N/A

          \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1 \cdot \frac{y}{y}} - 1\right)\right) \cdot x \]
        5. *-inversesN/A

          \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(-1 \cdot \color{blue}{1} - 1\right)\right) \cdot x \]
        6. metadata-evalN/A

          \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1} - 1\right)\right) \cdot x \]
        7. metadata-evalN/A

          \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \color{blue}{-2}\right) \cdot x \]
        8. metadata-evalN/A

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

          \[\leadsto \frac{1}{2} \cdot y + \color{blue}{\frac{1}{2}} \cdot x \]
        10. distribute-lft-outN/A

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

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

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

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

          \[\leadsto \color{blue}{\left(y + x\right)} \cdot \frac{1}{2} \]
        15. lower-+.f6485.6

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

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

      if -1.3499999999999999e-91 < x < 5.09999999999999997e-10

      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}{x + \frac{1}{2} \cdot \left|y - x\right|} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{\left|x - \left(\mathsf{neg}\left(-1\right)\right) \cdot y\right|}, \frac{1}{2}, x\right) \]
        7. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left|-1 \cdot y\right|, \frac{1}{2}, x\right) \]
      7. Step-by-step derivation
        1. Applied rewrites77.5%

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

        if 5.09999999999999997e-10 < x

        1. Initial program 99.8%

          \[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. unpow1N/A

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

            \[\leadsto {\left(\frac{\left|y - x\right|}{2}\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} + x \]
          5. sqrt-pow1N/A

            \[\leadsto \color{blue}{\sqrt{{\left(\frac{\left|y - x\right|}{2}\right)}^{2}}} + x \]
          6. pow2N/A

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\frac{\left|y - x\right|}{2}}, \sqrt{\frac{\left|y - x\right|}{2}}, x\right)} \]
        4. Applied rewrites84.4%

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

          \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)} \]
        6. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto x \cdot \color{blue}{\left(-1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2} + 1\right)} \]
          2. mul-1-negN/A

            \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left({\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)\right)} + 1\right) \]
          3. unpow2N/A

            \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\sqrt{\frac{-1}{2}} \cdot \sqrt{\frac{-1}{2}}}\right)\right) + 1\right) \]
          4. rem-square-sqrtN/A

            \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\frac{-1}{2}}\right)\right) + 1\right) \]
          5. metadata-evalN/A

            \[\leadsto x \cdot \left(\color{blue}{\frac{1}{2}} + 1\right) \]
          6. metadata-evalN/A

            \[\leadsto x \cdot \color{blue}{\frac{3}{2}} \]
          7. lower-*.f6472.9

            \[\leadsto \color{blue}{x \cdot 1.5} \]
        7. Applied rewrites72.9%

          \[\leadsto \color{blue}{x \cdot 1.5} \]
      8. Recombined 3 regimes into one program.
      9. Add Preprocessing

      Alternative 4: 80.9% accurate, 0.9× speedup?

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

        1. Initial program 100.0%

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

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

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

            \[\leadsto x + \frac{\sqrt{\color{blue}{\left(y - x\right)} \cdot \left(y - x\right)}}{2} \]
          4. flip--N/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \cdot \left(y - x\right)}}{2} \]
          5. lift--.f64N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\left(y - x\right)}}}{2} \]
          6. flip3--N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\frac{{y}^{3} - {x}^{3}}{y \cdot y + \left(x \cdot x + y \cdot x\right)}}}}{2} \]
          7. frac-timesN/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          8. sqrt-divN/A

            \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          9. lower-/.f64N/A

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

          \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(\left(y + x\right) \cdot \left(y - x\right)\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \mathsf{fma}\left(y + x, x, y \cdot y\right)}}}}{2} \]
        5. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
        6. Step-by-step derivation
          1. lower-*.f6418.1

            \[\leadsto \color{blue}{0.5 \cdot y} \]
        7. Applied rewrites18.1%

          \[\leadsto \color{blue}{0.5 \cdot y} \]
        8. Taylor expanded in x around 0

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

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

            \[\leadsto \color{blue}{\left(1 + \frac{1}{4} \cdot \frac{-1 \cdot y - y}{y}\right) \cdot x} + \frac{1}{2} \cdot y \]
          3. div-subN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{\left(\frac{-1 \cdot y}{y} - \frac{y}{y}\right)}\right) \cdot x + \frac{1}{2} \cdot y \]
          4. associate-/l*N/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1 \cdot \frac{y}{y}} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          5. *-inversesN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 \cdot \color{blue}{1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          6. metadata-evalN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          7. *-inversesN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 - \color{blue}{1}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          8. metadata-evalN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{-2}\right) \cdot x + \frac{1}{2} \cdot y \]
          9. metadata-evalN/A

            \[\leadsto \left(1 + \color{blue}{\frac{-1}{2}}\right) \cdot x + \frac{1}{2} \cdot y \]
          10. metadata-evalN/A

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, x, \frac{1}{2} \cdot y\right)} \]
          12. lower-*.f6485.6

            \[\leadsto \mathsf{fma}\left(0.5, x, \color{blue}{0.5 \cdot y}\right) \]
        10. Applied rewrites85.6%

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

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

            \[\leadsto \frac{1}{2} \cdot y + \color{blue}{\left(1 + \frac{1}{4} \cdot \frac{-1 \cdot y - y}{y}\right) \cdot x} \]
          2. div-subN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \color{blue}{\left(\frac{-1 \cdot y}{y} - \frac{y}{y}\right)}\right) \cdot x \]
          3. *-inversesN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(\frac{-1 \cdot y}{y} - \color{blue}{1}\right)\right) \cdot x \]
          4. associate-/l*N/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1 \cdot \frac{y}{y}} - 1\right)\right) \cdot x \]
          5. *-inversesN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(-1 \cdot \color{blue}{1} - 1\right)\right) \cdot x \]
          6. metadata-evalN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1} - 1\right)\right) \cdot x \]
          7. metadata-evalN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \color{blue}{-2}\right) \cdot x \]
          8. metadata-evalN/A

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

            \[\leadsto \frac{1}{2} \cdot y + \color{blue}{\frac{1}{2}} \cdot x \]
          10. distribute-lft-outN/A

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

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

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

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

            \[\leadsto \color{blue}{\left(y + x\right)} \cdot \frac{1}{2} \]
          15. lower-+.f6485.6

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

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

        if -4.8e-94 < x < 5.09999999999999997e-10

        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. lower-*.f64N/A

            \[\leadsto \color{blue}{\left|y - x\right| \cdot \frac{1}{2}} \]
          3. *-lft-identityN/A

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

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

            \[\leadsto \color{blue}{\left|x - \left(\mathsf{neg}\left(-1\right)\right) \cdot y\right|} \cdot \frac{1}{2} \]
          6. fp-cancel-sign-sub-invN/A

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

            \[\leadsto \color{blue}{\left|x + -1 \cdot y\right|} \cdot \frac{1}{2} \]
          8. fp-cancel-sign-sub-invN/A

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

            \[\leadsto \left|x - \color{blue}{1} \cdot y\right| \cdot \frac{1}{2} \]
          10. *-lft-identityN/A

            \[\leadsto \left|x - \color{blue}{y}\right| \cdot \frac{1}{2} \]
          11. lower--.f6476.5

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

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

        if 5.09999999999999997e-10 < x

        1. Initial program 99.8%

          \[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. unpow1N/A

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

            \[\leadsto {\left(\frac{\left|y - x\right|}{2}\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} + x \]
          5. sqrt-pow1N/A

            \[\leadsto \color{blue}{\sqrt{{\left(\frac{\left|y - x\right|}{2}\right)}^{2}}} + x \]
          6. pow2N/A

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\frac{\left|y - x\right|}{2}}, \sqrt{\frac{\left|y - x\right|}{2}}, x\right)} \]
        4. Applied rewrites84.4%

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

          \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)} \]
        6. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto x \cdot \color{blue}{\left(-1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2} + 1\right)} \]
          2. mul-1-negN/A

            \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left({\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)\right)} + 1\right) \]
          3. unpow2N/A

            \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\sqrt{\frac{-1}{2}} \cdot \sqrt{\frac{-1}{2}}}\right)\right) + 1\right) \]
          4. rem-square-sqrtN/A

            \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\frac{-1}{2}}\right)\right) + 1\right) \]
          5. metadata-evalN/A

            \[\leadsto x \cdot \left(\color{blue}{\frac{1}{2}} + 1\right) \]
          6. metadata-evalN/A

            \[\leadsto x \cdot \color{blue}{\frac{3}{2}} \]
          7. lower-*.f6472.9

            \[\leadsto \color{blue}{x \cdot 1.5} \]
        7. Applied rewrites72.9%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-94}:\\ \;\;\;\;\left(y + x\right) \cdot 0.5\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-10}:\\ \;\;\;\;\left|y - x\right| \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.5\\ \end{array} \]
      5. Add Preprocessing

      Alternative 5: 69.7% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.4 \cdot 10^{-124}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{-252}:\\ \;\;\;\;x \cdot 1.5\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) \cdot 0.5\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (<= y -2.4e-124)
         (* y -0.5)
         (if (<= y 3.9e-252) (* x 1.5) (* (+ y x) 0.5))))
      double code(double x, double y) {
      	double tmp;
      	if (y <= -2.4e-124) {
      		tmp = y * -0.5;
      	} else if (y <= 3.9e-252) {
      		tmp = x * 1.5;
      	} else {
      		tmp = (y + x) * 0.5;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8) :: tmp
          if (y <= (-2.4d-124)) then
              tmp = y * (-0.5d0)
          else if (y <= 3.9d-252) then
              tmp = x * 1.5d0
          else
              tmp = (y + x) * 0.5d0
          end if
          code = tmp
      end function
      
      public static double code(double x, double y) {
      	double tmp;
      	if (y <= -2.4e-124) {
      		tmp = y * -0.5;
      	} else if (y <= 3.9e-252) {
      		tmp = x * 1.5;
      	} else {
      		tmp = (y + x) * 0.5;
      	}
      	return tmp;
      }
      
      def code(x, y):
      	tmp = 0
      	if y <= -2.4e-124:
      		tmp = y * -0.5
      	elif y <= 3.9e-252:
      		tmp = x * 1.5
      	else:
      		tmp = (y + x) * 0.5
      	return tmp
      
      function code(x, y)
      	tmp = 0.0
      	if (y <= -2.4e-124)
      		tmp = Float64(y * -0.5);
      	elseif (y <= 3.9e-252)
      		tmp = Float64(x * 1.5);
      	else
      		tmp = Float64(Float64(y + x) * 0.5);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y)
      	tmp = 0.0;
      	if (y <= -2.4e-124)
      		tmp = y * -0.5;
      	elseif (y <= 3.9e-252)
      		tmp = x * 1.5;
      	else
      		tmp = (y + x) * 0.5;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_] := If[LessEqual[y, -2.4e-124], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 3.9e-252], N[(x * 1.5), $MachinePrecision], N[(N[(y + x), $MachinePrecision] * 0.5), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y \leq -2.4 \cdot 10^{-124}:\\
      \;\;\;\;y \cdot -0.5\\
      
      \mathbf{elif}\;y \leq 3.9 \cdot 10^{-252}:\\
      \;\;\;\;x \cdot 1.5\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(y + x\right) \cdot 0.5\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y < -2.39999999999999992e-124

        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. unpow1N/A

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

            \[\leadsto {\left(\frac{\left|y - x\right|}{2}\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} + x \]
          5. sqrt-pow1N/A

            \[\leadsto \color{blue}{\sqrt{{\left(\frac{\left|y - x\right|}{2}\right)}^{2}}} + x \]
          6. pow2N/A

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

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

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

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

          \[\leadsto \color{blue}{y \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2}} \]
        6. Step-by-step derivation
          1. unpow2N/A

            \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{-1}{2}} \cdot \sqrt{\frac{-1}{2}}\right)} \]
          2. rem-square-sqrtN/A

            \[\leadsto y \cdot \color{blue}{\frac{-1}{2}} \]
          3. lower-*.f6465.1

            \[\leadsto \color{blue}{y \cdot -0.5} \]
        7. Applied rewrites65.1%

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

        if -2.39999999999999992e-124 < y < 3.8999999999999999e-252

        1. Initial program 99.8%

          \[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. unpow1N/A

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

            \[\leadsto {\left(\frac{\left|y - x\right|}{2}\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} + x \]
          5. sqrt-pow1N/A

            \[\leadsto \color{blue}{\sqrt{{\left(\frac{\left|y - x\right|}{2}\right)}^{2}}} + x \]
          6. pow2N/A

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

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

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

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

          \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)} \]
        6. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto x \cdot \color{blue}{\left(-1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2} + 1\right)} \]
          2. mul-1-negN/A

            \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left({\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)\right)} + 1\right) \]
          3. unpow2N/A

            \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\sqrt{\frac{-1}{2}} \cdot \sqrt{\frac{-1}{2}}}\right)\right) + 1\right) \]
          4. rem-square-sqrtN/A

            \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\frac{-1}{2}}\right)\right) + 1\right) \]
          5. metadata-evalN/A

            \[\leadsto x \cdot \left(\color{blue}{\frac{1}{2}} + 1\right) \]
          6. metadata-evalN/A

            \[\leadsto x \cdot \color{blue}{\frac{3}{2}} \]
          7. lower-*.f6466.5

            \[\leadsto \color{blue}{x \cdot 1.5} \]
        7. Applied rewrites66.5%

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

        if 3.8999999999999999e-252 < y

        1. Initial program 99.9%

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

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

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

            \[\leadsto x + \frac{\sqrt{\color{blue}{\left(y - x\right)} \cdot \left(y - x\right)}}{2} \]
          4. flip--N/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \cdot \left(y - x\right)}}{2} \]
          5. lift--.f64N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\left(y - x\right)}}}{2} \]
          6. flip3--N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\frac{{y}^{3} - {x}^{3}}{y \cdot y + \left(x \cdot x + y \cdot x\right)}}}}{2} \]
          7. frac-timesN/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          8. sqrt-divN/A

            \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          9. lower-/.f64N/A

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

          \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(\left(y + x\right) \cdot \left(y - x\right)\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \mathsf{fma}\left(y + x, x, y \cdot y\right)}}}}{2} \]
        5. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
        6. Step-by-step derivation
          1. lower-*.f6464.7

            \[\leadsto \color{blue}{0.5 \cdot y} \]
        7. Applied rewrites64.7%

          \[\leadsto \color{blue}{0.5 \cdot y} \]
        8. Taylor expanded in x around 0

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

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

            \[\leadsto \color{blue}{\left(1 + \frac{1}{4} \cdot \frac{-1 \cdot y - y}{y}\right) \cdot x} + \frac{1}{2} \cdot y \]
          3. div-subN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{\left(\frac{-1 \cdot y}{y} - \frac{y}{y}\right)}\right) \cdot x + \frac{1}{2} \cdot y \]
          4. associate-/l*N/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1 \cdot \frac{y}{y}} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          5. *-inversesN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 \cdot \color{blue}{1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          6. metadata-evalN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          7. *-inversesN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 - \color{blue}{1}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          8. metadata-evalN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{-2}\right) \cdot x + \frac{1}{2} \cdot y \]
          9. metadata-evalN/A

            \[\leadsto \left(1 + \color{blue}{\frac{-1}{2}}\right) \cdot x + \frac{1}{2} \cdot y \]
          10. metadata-evalN/A

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, x, \frac{1}{2} \cdot y\right)} \]
          12. lower-*.f6483.7

            \[\leadsto \mathsf{fma}\left(0.5, x, \color{blue}{0.5 \cdot y}\right) \]
        10. Applied rewrites83.7%

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

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

            \[\leadsto \frac{1}{2} \cdot y + \color{blue}{\left(1 + \frac{1}{4} \cdot \frac{-1 \cdot y - y}{y}\right) \cdot x} \]
          2. div-subN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \color{blue}{\left(\frac{-1 \cdot y}{y} - \frac{y}{y}\right)}\right) \cdot x \]
          3. *-inversesN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(\frac{-1 \cdot y}{y} - \color{blue}{1}\right)\right) \cdot x \]
          4. associate-/l*N/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1 \cdot \frac{y}{y}} - 1\right)\right) \cdot x \]
          5. *-inversesN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(-1 \cdot \color{blue}{1} - 1\right)\right) \cdot x \]
          6. metadata-evalN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1} - 1\right)\right) \cdot x \]
          7. metadata-evalN/A

            \[\leadsto \frac{1}{2} \cdot y + \left(1 + \frac{1}{4} \cdot \color{blue}{-2}\right) \cdot x \]
          8. metadata-evalN/A

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

            \[\leadsto \frac{1}{2} \cdot y + \color{blue}{\frac{1}{2}} \cdot x \]
          10. distribute-lft-outN/A

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

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

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

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

            \[\leadsto \color{blue}{\left(y + x\right)} \cdot \frac{1}{2} \]
          15. lower-+.f6483.7

            \[\leadsto \color{blue}{\left(y + x\right)} \cdot 0.5 \]
        13. Applied rewrites83.7%

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

      Alternative 6: 60.3% accurate, 1.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.4 \cdot 10^{-124}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-18}:\\ \;\;\;\;x \cdot 1.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (<= y -2.4e-124) (* y -0.5) (if (<= y 1.7e-18) (* x 1.5) (* 0.5 y))))
      double code(double x, double y) {
      	double tmp;
      	if (y <= -2.4e-124) {
      		tmp = y * -0.5;
      	} else if (y <= 1.7e-18) {
      		tmp = x * 1.5;
      	} else {
      		tmp = 0.5 * y;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8) :: tmp
          if (y <= (-2.4d-124)) then
              tmp = y * (-0.5d0)
          else if (y <= 1.7d-18) then
              tmp = x * 1.5d0
          else
              tmp = 0.5d0 * y
          end if
          code = tmp
      end function
      
      public static double code(double x, double y) {
      	double tmp;
      	if (y <= -2.4e-124) {
      		tmp = y * -0.5;
      	} else if (y <= 1.7e-18) {
      		tmp = x * 1.5;
      	} else {
      		tmp = 0.5 * y;
      	}
      	return tmp;
      }
      
      def code(x, y):
      	tmp = 0
      	if y <= -2.4e-124:
      		tmp = y * -0.5
      	elif y <= 1.7e-18:
      		tmp = x * 1.5
      	else:
      		tmp = 0.5 * y
      	return tmp
      
      function code(x, y)
      	tmp = 0.0
      	if (y <= -2.4e-124)
      		tmp = Float64(y * -0.5);
      	elseif (y <= 1.7e-18)
      		tmp = Float64(x * 1.5);
      	else
      		tmp = Float64(0.5 * y);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y)
      	tmp = 0.0;
      	if (y <= -2.4e-124)
      		tmp = y * -0.5;
      	elseif (y <= 1.7e-18)
      		tmp = x * 1.5;
      	else
      		tmp = 0.5 * y;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_] := If[LessEqual[y, -2.4e-124], N[(y * -0.5), $MachinePrecision], If[LessEqual[y, 1.7e-18], N[(x * 1.5), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y \leq -2.4 \cdot 10^{-124}:\\
      \;\;\;\;y \cdot -0.5\\
      
      \mathbf{elif}\;y \leq 1.7 \cdot 10^{-18}:\\
      \;\;\;\;x \cdot 1.5\\
      
      \mathbf{else}:\\
      \;\;\;\;0.5 \cdot y\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y < -2.39999999999999992e-124

        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. unpow1N/A

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

            \[\leadsto {\left(\frac{\left|y - x\right|}{2}\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} + x \]
          5. sqrt-pow1N/A

            \[\leadsto \color{blue}{\sqrt{{\left(\frac{\left|y - x\right|}{2}\right)}^{2}}} + x \]
          6. pow2N/A

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

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

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

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

          \[\leadsto \color{blue}{y \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2}} \]
        6. Step-by-step derivation
          1. unpow2N/A

            \[\leadsto y \cdot \color{blue}{\left(\sqrt{\frac{-1}{2}} \cdot \sqrt{\frac{-1}{2}}\right)} \]
          2. rem-square-sqrtN/A

            \[\leadsto y \cdot \color{blue}{\frac{-1}{2}} \]
          3. lower-*.f6465.1

            \[\leadsto \color{blue}{y \cdot -0.5} \]
        7. Applied rewrites65.1%

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

        if -2.39999999999999992e-124 < y < 1.70000000000000001e-18

        1. Initial program 99.8%

          \[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. unpow1N/A

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

            \[\leadsto {\left(\frac{\left|y - x\right|}{2}\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} + x \]
          5. sqrt-pow1N/A

            \[\leadsto \color{blue}{\sqrt{{\left(\frac{\left|y - x\right|}{2}\right)}^{2}}} + x \]
          6. pow2N/A

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\frac{\left|y - x\right|}{2}}, \sqrt{\frac{\left|y - x\right|}{2}}, x\right)} \]
        4. Applied rewrites57.6%

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

          \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)} \]
        6. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto x \cdot \color{blue}{\left(-1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2} + 1\right)} \]
          2. mul-1-negN/A

            \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left({\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)\right)} + 1\right) \]
          3. unpow2N/A

            \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\sqrt{\frac{-1}{2}} \cdot \sqrt{\frac{-1}{2}}}\right)\right) + 1\right) \]
          4. rem-square-sqrtN/A

            \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\frac{-1}{2}}\right)\right) + 1\right) \]
          5. metadata-evalN/A

            \[\leadsto x \cdot \left(\color{blue}{\frac{1}{2}} + 1\right) \]
          6. metadata-evalN/A

            \[\leadsto x \cdot \color{blue}{\frac{3}{2}} \]
          7. lower-*.f6458.0

            \[\leadsto \color{blue}{x \cdot 1.5} \]
        7. Applied rewrites58.0%

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

        if 1.70000000000000001e-18 < y

        1. Initial program 100.0%

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

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

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

            \[\leadsto x + \frac{\sqrt{\color{blue}{\left(y - x\right)} \cdot \left(y - x\right)}}{2} \]
          4. flip--N/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \cdot \left(y - x\right)}}{2} \]
          5. lift--.f64N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\left(y - x\right)}}}{2} \]
          6. flip3--N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\frac{{y}^{3} - {x}^{3}}{y \cdot y + \left(x \cdot x + y \cdot x\right)}}}}{2} \]
          7. frac-timesN/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          8. sqrt-divN/A

            \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          9. lower-/.f64N/A

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

          \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(\left(y + x\right) \cdot \left(y - x\right)\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \mathsf{fma}\left(y + x, x, y \cdot y\right)}}}}{2} \]
        5. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
        6. Step-by-step derivation
          1. lower-*.f6477.6

            \[\leadsto \color{blue}{0.5 \cdot y} \]
        7. Applied rewrites77.6%

          \[\leadsto \color{blue}{0.5 \cdot y} \]
      3. Recombined 3 regimes into one program.
      4. Add Preprocessing

      Alternative 7: 58.4% accurate, 1.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-73}:\\ \;\;\;\;0.5 \cdot x\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-160}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.5\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (<= x -7.2e-73) (* 0.5 x) (if (<= x 9.2e-160) (* 0.5 y) (* x 1.5))))
      double code(double x, double y) {
      	double tmp;
      	if (x <= -7.2e-73) {
      		tmp = 0.5 * x;
      	} else if (x <= 9.2e-160) {
      		tmp = 0.5 * y;
      	} else {
      		tmp = x * 1.5;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8) :: tmp
          if (x <= (-7.2d-73)) then
              tmp = 0.5d0 * x
          else if (x <= 9.2d-160) then
              tmp = 0.5d0 * y
          else
              tmp = x * 1.5d0
          end if
          code = tmp
      end function
      
      public static double code(double x, double y) {
      	double tmp;
      	if (x <= -7.2e-73) {
      		tmp = 0.5 * x;
      	} else if (x <= 9.2e-160) {
      		tmp = 0.5 * y;
      	} else {
      		tmp = x * 1.5;
      	}
      	return tmp;
      }
      
      def code(x, y):
      	tmp = 0
      	if x <= -7.2e-73:
      		tmp = 0.5 * x
      	elif x <= 9.2e-160:
      		tmp = 0.5 * y
      	else:
      		tmp = x * 1.5
      	return tmp
      
      function code(x, y)
      	tmp = 0.0
      	if (x <= -7.2e-73)
      		tmp = Float64(0.5 * x);
      	elseif (x <= 9.2e-160)
      		tmp = Float64(0.5 * y);
      	else
      		tmp = Float64(x * 1.5);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y)
      	tmp = 0.0;
      	if (x <= -7.2e-73)
      		tmp = 0.5 * x;
      	elseif (x <= 9.2e-160)
      		tmp = 0.5 * y;
      	else
      		tmp = x * 1.5;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_] := If[LessEqual[x, -7.2e-73], N[(0.5 * x), $MachinePrecision], If[LessEqual[x, 9.2e-160], N[(0.5 * y), $MachinePrecision], N[(x * 1.5), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -7.2 \cdot 10^{-73}:\\
      \;\;\;\;0.5 \cdot x\\
      
      \mathbf{elif}\;x \leq 9.2 \cdot 10^{-160}:\\
      \;\;\;\;0.5 \cdot y\\
      
      \mathbf{else}:\\
      \;\;\;\;x \cdot 1.5\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if x < -7.1999999999999999e-73

        1. Initial program 100.0%

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

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

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

            \[\leadsto x + \frac{\sqrt{\color{blue}{\left(y - x\right)} \cdot \left(y - x\right)}}{2} \]
          4. flip--N/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \cdot \left(y - x\right)}}{2} \]
          5. lift--.f64N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\left(y - x\right)}}}{2} \]
          6. flip3--N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\frac{{y}^{3} - {x}^{3}}{y \cdot y + \left(x \cdot x + y \cdot x\right)}}}}{2} \]
          7. frac-timesN/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          8. sqrt-divN/A

            \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          9. lower-/.f64N/A

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

          \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(\left(y + x\right) \cdot \left(y - x\right)\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \mathsf{fma}\left(y + x, x, y \cdot y\right)}}}}{2} \]
        5. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
        6. Step-by-step derivation
          1. lower-*.f6416.1

            \[\leadsto \color{blue}{0.5 \cdot y} \]
        7. Applied rewrites16.1%

          \[\leadsto \color{blue}{0.5 \cdot y} \]
        8. Taylor expanded in x around 0

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

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

            \[\leadsto \color{blue}{\left(1 + \frac{1}{4} \cdot \frac{-1 \cdot y - y}{y}\right) \cdot x} + \frac{1}{2} \cdot y \]
          3. div-subN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{\left(\frac{-1 \cdot y}{y} - \frac{y}{y}\right)}\right) \cdot x + \frac{1}{2} \cdot y \]
          4. associate-/l*N/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1 \cdot \frac{y}{y}} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          5. *-inversesN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 \cdot \color{blue}{1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          6. metadata-evalN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          7. *-inversesN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 - \color{blue}{1}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          8. metadata-evalN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{-2}\right) \cdot x + \frac{1}{2} \cdot y \]
          9. metadata-evalN/A

            \[\leadsto \left(1 + \color{blue}{\frac{-1}{2}}\right) \cdot x + \frac{1}{2} \cdot y \]
          10. metadata-evalN/A

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, x, \frac{1}{2} \cdot y\right)} \]
          12. lower-*.f6484.7

            \[\leadsto \mathsf{fma}\left(0.5, x, \color{blue}{0.5 \cdot y}\right) \]
        10. Applied rewrites84.7%

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

          \[\leadsto \frac{1}{2} \cdot \color{blue}{x} \]
        12. Step-by-step derivation
          1. Applied rewrites70.2%

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

          if -7.1999999999999999e-73 < x < 9.19999999999999939e-160

          1. Initial program 100.0%

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

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

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

              \[\leadsto x + \frac{\sqrt{\color{blue}{\left(y - x\right)} \cdot \left(y - x\right)}}{2} \]
            4. flip--N/A

              \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \cdot \left(y - x\right)}}{2} \]
            5. lift--.f64N/A

              \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\left(y - x\right)}}}{2} \]
            6. flip3--N/A

              \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\frac{{y}^{3} - {x}^{3}}{y \cdot y + \left(x \cdot x + y \cdot x\right)}}}}{2} \]
            7. frac-timesN/A

              \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
            8. sqrt-divN/A

              \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
            9. lower-/.f64N/A

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

            \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(\left(y + x\right) \cdot \left(y - x\right)\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \mathsf{fma}\left(y + x, x, y \cdot y\right)}}}}{2} \]
          5. Taylor expanded in x around 0

            \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
          6. Step-by-step derivation
            1. lower-*.f6441.9

              \[\leadsto \color{blue}{0.5 \cdot y} \]
          7. Applied rewrites41.9%

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

          if 9.19999999999999939e-160 < x

          1. Initial program 99.8%

            \[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. unpow1N/A

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

              \[\leadsto {\left(\frac{\left|y - x\right|}{2}\right)}^{\color{blue}{\left(\frac{2}{2}\right)}} + x \]
            5. sqrt-pow1N/A

              \[\leadsto \color{blue}{\sqrt{{\left(\frac{\left|y - x\right|}{2}\right)}^{2}}} + x \]
            6. pow2N/A

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

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

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

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

            \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)} \]
          6. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto x \cdot \color{blue}{\left(-1 \cdot {\left(\sqrt{\frac{-1}{2}}\right)}^{2} + 1\right)} \]
            2. mul-1-negN/A

              \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left({\left(\sqrt{\frac{-1}{2}}\right)}^{2}\right)\right)} + 1\right) \]
            3. unpow2N/A

              \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\sqrt{\frac{-1}{2}} \cdot \sqrt{\frac{-1}{2}}}\right)\right) + 1\right) \]
            4. rem-square-sqrtN/A

              \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\frac{-1}{2}}\right)\right) + 1\right) \]
            5. metadata-evalN/A

              \[\leadsto x \cdot \left(\color{blue}{\frac{1}{2}} + 1\right) \]
            6. metadata-evalN/A

              \[\leadsto x \cdot \color{blue}{\frac{3}{2}} \]
            7. lower-*.f6463.2

              \[\leadsto \color{blue}{x \cdot 1.5} \]
          7. Applied rewrites63.2%

            \[\leadsto \color{blue}{x \cdot 1.5} \]
        13. Recombined 3 regimes into one program.
        14. Add Preprocessing

        Alternative 8: 30.2% accurate, 3.3× speedup?

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

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

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

            \[\leadsto x + \frac{\sqrt{\color{blue}{\left(y - x\right)} \cdot \left(y - x\right)}}{2} \]
          4. flip--N/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \cdot \left(y - x\right)}}{2} \]
          5. lift--.f64N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\left(y - x\right)}}}{2} \]
          6. flip3--N/A

            \[\leadsto x + \frac{\sqrt{\frac{y \cdot y - x \cdot x}{y + x} \cdot \color{blue}{\frac{{y}^{3} - {x}^{3}}{y \cdot y + \left(x \cdot x + y \cdot x\right)}}}}{2} \]
          7. frac-timesN/A

            \[\leadsto x + \frac{\sqrt{\color{blue}{\frac{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          8. sqrt-divN/A

            \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
          9. lower-/.f64N/A

            \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(y \cdot y - x \cdot x\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \left(y \cdot y + \left(x \cdot x + y \cdot x\right)\right)}}}}{2} \]
        4. Applied rewrites11.7%

          \[\leadsto x + \frac{\color{blue}{\frac{\sqrt{\left(\left(y + x\right) \cdot \left(y - x\right)\right) \cdot \left({y}^{3} - {x}^{3}\right)}}{\sqrt{\left(y + x\right) \cdot \mathsf{fma}\left(y + x, x, y \cdot y\right)}}}}{2} \]
        5. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\frac{1}{2} \cdot y} \]
        6. Step-by-step derivation
          1. lower-*.f6427.0

            \[\leadsto \color{blue}{0.5 \cdot y} \]
        7. Applied rewrites27.0%

          \[\leadsto \color{blue}{0.5 \cdot y} \]
        8. Taylor expanded in x around 0

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

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

            \[\leadsto \color{blue}{\left(1 + \frac{1}{4} \cdot \frac{-1 \cdot y - y}{y}\right) \cdot x} + \frac{1}{2} \cdot y \]
          3. div-subN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{\left(\frac{-1 \cdot y}{y} - \frac{y}{y}\right)}\right) \cdot x + \frac{1}{2} \cdot y \]
          4. associate-/l*N/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1 \cdot \frac{y}{y}} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          5. *-inversesN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 \cdot \color{blue}{1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          6. metadata-evalN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(\color{blue}{-1} - \frac{y}{y}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          7. *-inversesN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \left(-1 - \color{blue}{1}\right)\right) \cdot x + \frac{1}{2} \cdot y \]
          8. metadata-evalN/A

            \[\leadsto \left(1 + \frac{1}{4} \cdot \color{blue}{-2}\right) \cdot x + \frac{1}{2} \cdot y \]
          9. metadata-evalN/A

            \[\leadsto \left(1 + \color{blue}{\frac{-1}{2}}\right) \cdot x + \frac{1}{2} \cdot y \]
          10. metadata-evalN/A

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, x, \frac{1}{2} \cdot y\right)} \]
          12. lower-*.f6451.6

            \[\leadsto \mathsf{fma}\left(0.5, x, \color{blue}{0.5 \cdot y}\right) \]
        10. Applied rewrites51.6%

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

          \[\leadsto \frac{1}{2} \cdot \color{blue}{x} \]
        12. Step-by-step derivation
          1. Applied rewrites27.0%

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

          Reproduce

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