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

Percentage Accurate: 99.9% → 99.9%
Time: 4.2s
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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y)
use fmin_fmax_functions
    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(0.5, \left|y - x\right|, x\right) \end{array} \]
(FPCore (x y) :precision binary64 (fma 0.5 (fabs (- y x)) x))
double code(double x, double y) {
	return fma(0.5, fabs((y - x)), x);
}
function code(x, y)
	return fma(0.5, abs(Float64(y - x)), x)
end
code[x_, y_] := N[(0.5 * N[Abs[N[(y - x), $MachinePrecision]], $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(0.5, \left|y - x\right|, 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. Applied rewrites99.9%

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

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

    Alternative 2: 80.6% accurate, 1.0× speedup?

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

      1. Initial program 100.0%

        \[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. Applied rewrites100.0%

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

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

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

          if -8.7999999999999996e-101 < y < 2.1500000000000002e-115

          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. Applied rewrites99.9%

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

              \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \left|x\right|, x\right) \]
            3. Step-by-step derivation
              1. Applied rewrites86.4%

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

              if 2.1500000000000002e-115 < y

              1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{\frac{\left|y - x\right| \cdot \color{blue}{\left|y - x\right|}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                11. sqr-abs-revN/A

                  \[\leadsto \frac{\frac{\color{blue}{\left(y - x\right) \cdot \left(y - x\right)}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                12. lower-/.f64N/A

                  \[\leadsto \frac{\color{blue}{\frac{\left(y - x\right) \cdot \left(y - x\right)}{2 \cdot 2}} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                13. pow2N/A

                  \[\leadsto \frac{\frac{\color{blue}{{\left(y - x\right)}^{2}}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                14. lower-pow.f64N/A

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

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

                  \[\leadsto \frac{\frac{{\left(y - x\right)}^{2}}{4} - \color{blue}{x \cdot x}}{\frac{\left|y - x\right|}{2} - x} \]
                17. lower--.f6451.4

                  \[\leadsto \frac{\frac{{\left(y - x\right)}^{2}}{4} - x \cdot x}{\color{blue}{\frac{\left|y - x\right|}{2} - x}} \]
              4. Applied rewrites51.4%

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

                \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{y}^{2}}{\left|x - y\right|}} \]
              6. Step-by-step derivation
                1. Applied rewrites42.0%

                  \[\leadsto \color{blue}{\frac{\left(0.5 \cdot y\right) \cdot y}{\left|y - x\right|}} \]
                2. Step-by-step derivation
                  1. Applied rewrites41.5%

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

                    \[\leadsto \frac{1}{2} \cdot x + \color{blue}{\frac{1}{2} \cdot y} \]
                  3. Step-by-step derivation
                    1. Applied rewrites90.3%

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

                  Alternative 3: 80.2% accurate, 1.0× speedup?

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

                    1. Initial program 100.0%

                      \[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. Applied rewrites80.0%

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

                      if -2.35000000000000022e-16 < y < 2.1500000000000002e-115

                      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. Applied rewrites99.9%

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

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

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

                          if 2.1500000000000002e-115 < y

                          1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                              \[\leadsto \frac{\frac{\left|y - x\right| \cdot \color{blue}{\left|y - x\right|}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                            11. sqr-abs-revN/A

                              \[\leadsto \frac{\frac{\color{blue}{\left(y - x\right) \cdot \left(y - x\right)}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                            12. lower-/.f64N/A

                              \[\leadsto \frac{\color{blue}{\frac{\left(y - x\right) \cdot \left(y - x\right)}{2 \cdot 2}} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                            13. pow2N/A

                              \[\leadsto \frac{\frac{\color{blue}{{\left(y - x\right)}^{2}}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                            14. lower-pow.f64N/A

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

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

                              \[\leadsto \frac{\frac{{\left(y - x\right)}^{2}}{4} - \color{blue}{x \cdot x}}{\frac{\left|y - x\right|}{2} - x} \]
                            17. lower--.f6451.4

                              \[\leadsto \frac{\frac{{\left(y - x\right)}^{2}}{4} - x \cdot x}{\color{blue}{\frac{\left|y - x\right|}{2} - x}} \]
                          4. Applied rewrites51.4%

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

                            \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{y}^{2}}{\left|x - y\right|}} \]
                          6. Step-by-step derivation
                            1. Applied rewrites42.0%

                              \[\leadsto \color{blue}{\frac{\left(0.5 \cdot y\right) \cdot y}{\left|y - x\right|}} \]
                            2. Step-by-step derivation
                              1. Applied rewrites41.5%

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

                                \[\leadsto \frac{1}{2} \cdot x + \color{blue}{\frac{1}{2} \cdot y} \]
                              3. Step-by-step derivation
                                1. Applied rewrites90.3%

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

                                \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.35 \cdot 10^{-16}:\\ \;\;\;\;0.5 \cdot \left|y - x\right|\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{-115}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \left|x\right|, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) \cdot 0.5\\ \end{array} \]
                              6. Add Preprocessing

                              Alternative 4: 79.8% accurate, 1.0× speedup?

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

                                1. Initial program 100.0%

                                  \[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. Applied rewrites80.0%

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

                                    \[\leadsto \frac{1}{2} \cdot \left|-1 \cdot y\right| \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites78.4%

                                      \[\leadsto 0.5 \cdot \left|-y\right| \]

                                    if -2.5999999999999998e-16 < y < 2.1500000000000002e-115

                                    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. Applied rewrites99.9%

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

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

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

                                        if 2.1500000000000002e-115 < y

                                        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                                            \[\leadsto \frac{\frac{\left|y - x\right| \cdot \color{blue}{\left|y - x\right|}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                                          11. sqr-abs-revN/A

                                            \[\leadsto \frac{\frac{\color{blue}{\left(y - x\right) \cdot \left(y - x\right)}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                                          12. lower-/.f64N/A

                                            \[\leadsto \frac{\color{blue}{\frac{\left(y - x\right) \cdot \left(y - x\right)}{2 \cdot 2}} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                                          13. pow2N/A

                                            \[\leadsto \frac{\frac{\color{blue}{{\left(y - x\right)}^{2}}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                                          14. lower-pow.f64N/A

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

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

                                            \[\leadsto \frac{\frac{{\left(y - x\right)}^{2}}{4} - \color{blue}{x \cdot x}}{\frac{\left|y - x\right|}{2} - x} \]
                                          17. lower--.f6451.4

                                            \[\leadsto \frac{\frac{{\left(y - x\right)}^{2}}{4} - x \cdot x}{\color{blue}{\frac{\left|y - x\right|}{2} - x}} \]
                                        4. Applied rewrites51.4%

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

                                          \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{y}^{2}}{\left|x - y\right|}} \]
                                        6. Step-by-step derivation
                                          1. Applied rewrites42.0%

                                            \[\leadsto \color{blue}{\frac{\left(0.5 \cdot y\right) \cdot y}{\left|y - x\right|}} \]
                                          2. Step-by-step derivation
                                            1. Applied rewrites41.5%

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

                                              \[\leadsto \frac{1}{2} \cdot x + \color{blue}{\frac{1}{2} \cdot y} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites90.3%

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

                                            Alternative 5: 68.6% accurate, 1.3× speedup?

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

                                              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. Applied rewrites99.9%

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

                                                  \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \left|x\right|, x\right) \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites59.9%

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

                                                  if 2.1500000000000002e-115 < y

                                                  1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

                                                      \[\leadsto \frac{\frac{\left|y - x\right| \cdot \color{blue}{\left|y - x\right|}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                                                    11. sqr-abs-revN/A

                                                      \[\leadsto \frac{\frac{\color{blue}{\left(y - x\right) \cdot \left(y - x\right)}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                                                    12. lower-/.f64N/A

                                                      \[\leadsto \frac{\color{blue}{\frac{\left(y - x\right) \cdot \left(y - x\right)}{2 \cdot 2}} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                                                    13. pow2N/A

                                                      \[\leadsto \frac{\frac{\color{blue}{{\left(y - x\right)}^{2}}}{2 \cdot 2} - x \cdot x}{\frac{\left|y - x\right|}{2} - x} \]
                                                    14. lower-pow.f64N/A

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

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

                                                      \[\leadsto \frac{\frac{{\left(y - x\right)}^{2}}{4} - \color{blue}{x \cdot x}}{\frac{\left|y - x\right|}{2} - x} \]
                                                    17. lower--.f6451.4

                                                      \[\leadsto \frac{\frac{{\left(y - x\right)}^{2}}{4} - x \cdot x}{\color{blue}{\frac{\left|y - x\right|}{2} - x}} \]
                                                  4. Applied rewrites51.4%

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

                                                    \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{y}^{2}}{\left|x - y\right|}} \]
                                                  6. Step-by-step derivation
                                                    1. Applied rewrites42.0%

                                                      \[\leadsto \color{blue}{\frac{\left(0.5 \cdot y\right) \cdot y}{\left|y - x\right|}} \]
                                                    2. Step-by-step derivation
                                                      1. Applied rewrites41.5%

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

                                                        \[\leadsto \frac{1}{2} \cdot x + \color{blue}{\frac{1}{2} \cdot y} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites90.3%

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

                                                      Alternative 6: 63.5% accurate, 1.3× speedup?

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

                                                        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. Applied rewrites99.9%

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

                                                            \[\leadsto \mathsf{fma}\left(\frac{1}{2}, \left|x\right|, x\right) \]
                                                          3. Step-by-step derivation
                                                            1. Applied rewrites59.3%

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

                                                            if 1.7e16 < y

                                                            1. Initial program 100.0%

                                                              \[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. Applied rewrites80.0%

                                                                \[\leadsto \color{blue}{0.5 \cdot \left|x - y\right|} \]
                                                              2. Step-by-step derivation
                                                                1. Applied rewrites78.7%

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

                                                                  \[\leadsto y \cdot \frac{1}{2} \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites79.2%

                                                                    \[\leadsto y \cdot 0.5 \]
                                                                4. Recombined 2 regimes into one program.
                                                                5. Add Preprocessing

                                                                Alternative 7: 31.2% accurate, 1.7× speedup?

                                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 6.2 \cdot 10^{-183}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \end{array} \]
                                                                (FPCore (x y) :precision binary64 (if (<= y 6.2e-183) x (* y 0.5)))
                                                                double code(double x, double y) {
                                                                	double tmp;
                                                                	if (y <= 6.2e-183) {
                                                                		tmp = x;
                                                                	} else {
                                                                		tmp = y * 0.5;
                                                                	}
                                                                	return tmp;
                                                                }
                                                                
                                                                module fmin_fmax_functions
                                                                    implicit none
                                                                    private
                                                                    public fmax
                                                                    public fmin
                                                                
                                                                    interface fmax
                                                                        module procedure fmax88
                                                                        module procedure fmax44
                                                                        module procedure fmax84
                                                                        module procedure fmax48
                                                                    end interface
                                                                    interface fmin
                                                                        module procedure fmin88
                                                                        module procedure fmin44
                                                                        module procedure fmin84
                                                                        module procedure fmin48
                                                                    end interface
                                                                contains
                                                                    real(8) function fmax88(x, y) result (res)
                                                                        real(8), intent (in) :: x
                                                                        real(8), intent (in) :: y
                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                    end function
                                                                    real(4) function fmax44(x, y) result (res)
                                                                        real(4), intent (in) :: x
                                                                        real(4), intent (in) :: y
                                                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmax84(x, y) result(res)
                                                                        real(8), intent (in) :: x
                                                                        real(4), intent (in) :: y
                                                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmax48(x, y) result(res)
                                                                        real(4), intent (in) :: x
                                                                        real(8), intent (in) :: y
                                                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmin88(x, y) result (res)
                                                                        real(8), intent (in) :: x
                                                                        real(8), intent (in) :: y
                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                    end function
                                                                    real(4) function fmin44(x, y) result (res)
                                                                        real(4), intent (in) :: x
                                                                        real(4), intent (in) :: y
                                                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmin84(x, y) result(res)
                                                                        real(8), intent (in) :: x
                                                                        real(4), intent (in) :: y
                                                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                    end function
                                                                    real(8) function fmin48(x, y) result(res)
                                                                        real(4), intent (in) :: x
                                                                        real(8), intent (in) :: y
                                                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                    end function
                                                                end module
                                                                
                                                                real(8) function code(x, y)
                                                                use fmin_fmax_functions
                                                                    real(8), intent (in) :: x
                                                                    real(8), intent (in) :: y
                                                                    real(8) :: tmp
                                                                    if (y <= 6.2d-183) then
                                                                        tmp = x
                                                                    else
                                                                        tmp = y * 0.5d0
                                                                    end if
                                                                    code = tmp
                                                                end function
                                                                
                                                                public static double code(double x, double y) {
                                                                	double tmp;
                                                                	if (y <= 6.2e-183) {
                                                                		tmp = x;
                                                                	} else {
                                                                		tmp = y * 0.5;
                                                                	}
                                                                	return tmp;
                                                                }
                                                                
                                                                def code(x, y):
                                                                	tmp = 0
                                                                	if y <= 6.2e-183:
                                                                		tmp = x
                                                                	else:
                                                                		tmp = y * 0.5
                                                                	return tmp
                                                                
                                                                function code(x, y)
                                                                	tmp = 0.0
                                                                	if (y <= 6.2e-183)
                                                                		tmp = x;
                                                                	else
                                                                		tmp = Float64(y * 0.5);
                                                                	end
                                                                	return tmp
                                                                end
                                                                
                                                                function tmp_2 = code(x, y)
                                                                	tmp = 0.0;
                                                                	if (y <= 6.2e-183)
                                                                		tmp = x;
                                                                	else
                                                                		tmp = y * 0.5;
                                                                	end
                                                                	tmp_2 = tmp;
                                                                end
                                                                
                                                                code[x_, y_] := If[LessEqual[y, 6.2e-183], x, N[(y * 0.5), $MachinePrecision]]
                                                                
                                                                \begin{array}{l}
                                                                
                                                                \\
                                                                \begin{array}{l}
                                                                \mathbf{if}\;y \leq 6.2 \cdot 10^{-183}:\\
                                                                \;\;\;\;x\\
                                                                
                                                                \mathbf{else}:\\
                                                                \;\;\;\;y \cdot 0.5\\
                                                                
                                                                
                                                                \end{array}
                                                                \end{array}
                                                                
                                                                Derivation
                                                                1. Split input into 2 regimes
                                                                2. if y < 6.19999999999999999e-183

                                                                  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. Applied rewrites12.7%

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

                                                                    if 6.19999999999999999e-183 < y

                                                                    1. Initial program 100.0%

                                                                      \[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. Applied rewrites66.7%

                                                                        \[\leadsto \color{blue}{0.5 \cdot \left|x - y\right|} \]
                                                                      2. Step-by-step derivation
                                                                        1. Applied rewrites64.3%

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

                                                                          \[\leadsto y \cdot \frac{1}{2} \]
                                                                        3. Step-by-step derivation
                                                                          1. Applied rewrites65.2%

                                                                            \[\leadsto y \cdot 0.5 \]
                                                                        4. Recombined 2 regimes into one program.
                                                                        5. Add Preprocessing

                                                                        Alternative 8: 11.5% accurate, 20.0× speedup?

                                                                        \[\begin{array}{l} \\ x \end{array} \]
                                                                        (FPCore (x y) :precision binary64 x)
                                                                        double code(double x, double y) {
                                                                        	return x;
                                                                        }
                                                                        
                                                                        module fmin_fmax_functions
                                                                            implicit none
                                                                            private
                                                                            public fmax
                                                                            public fmin
                                                                        
                                                                            interface fmax
                                                                                module procedure fmax88
                                                                                module procedure fmax44
                                                                                module procedure fmax84
                                                                                module procedure fmax48
                                                                            end interface
                                                                            interface fmin
                                                                                module procedure fmin88
                                                                                module procedure fmin44
                                                                                module procedure fmin84
                                                                                module procedure fmin48
                                                                            end interface
                                                                        contains
                                                                            real(8) function fmax88(x, y) result (res)
                                                                                real(8), intent (in) :: x
                                                                                real(8), intent (in) :: y
                                                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                            end function
                                                                            real(4) function fmax44(x, y) result (res)
                                                                                real(4), intent (in) :: x
                                                                                real(4), intent (in) :: y
                                                                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmax84(x, y) result(res)
                                                                                real(8), intent (in) :: x
                                                                                real(4), intent (in) :: y
                                                                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmax48(x, y) result(res)
                                                                                real(4), intent (in) :: x
                                                                                real(8), intent (in) :: y
                                                                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmin88(x, y) result (res)
                                                                                real(8), intent (in) :: x
                                                                                real(8), intent (in) :: y
                                                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                            end function
                                                                            real(4) function fmin44(x, y) result (res)
                                                                                real(4), intent (in) :: x
                                                                                real(4), intent (in) :: y
                                                                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmin84(x, y) result(res)
                                                                                real(8), intent (in) :: x
                                                                                real(4), intent (in) :: y
                                                                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                                                            end function
                                                                            real(8) function fmin48(x, y) result(res)
                                                                                real(4), intent (in) :: x
                                                                                real(8), intent (in) :: y
                                                                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                                                            end function
                                                                        end module
                                                                        
                                                                        real(8) function code(x, y)
                                                                        use fmin_fmax_functions
                                                                            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. Applied rewrites11.2%

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

                                                                          Reproduce

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