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

Percentage Accurate: 99.9% → 99.9%
Time: 6.9s
Alternatives: 10
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 10 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(\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. Applied rewrites99.9%

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

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

Alternative 2: 61.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-99}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-205}:\\ \;\;\;\;1.5 \cdot x\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-59}:\\ \;\;\;\;0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.7e-99)
   (* -0.5 y)
   (if (<= y 4.4e-205) (* 1.5 x) (if (<= y 3.5e-59) (* 0.5 x) (* 0.5 y)))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.7e-99) {
		tmp = -0.5 * y;
	} else if (y <= 4.4e-205) {
		tmp = 1.5 * x;
	} else if (y <= 3.5e-59) {
		tmp = 0.5 * x;
	} else {
		tmp = 0.5 * y;
	}
	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 <= (-2.7d-99)) then
        tmp = (-0.5d0) * y
    else if (y <= 4.4d-205) then
        tmp = 1.5d0 * x
    else if (y <= 3.5d-59) 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 (y <= -2.7e-99) {
		tmp = -0.5 * y;
	} else if (y <= 4.4e-205) {
		tmp = 1.5 * x;
	} else if (y <= 3.5e-59) {
		tmp = 0.5 * x;
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.7e-99:
		tmp = -0.5 * y
	elif y <= 4.4e-205:
		tmp = 1.5 * x
	elif y <= 3.5e-59:
		tmp = 0.5 * x
	else:
		tmp = 0.5 * y
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.7e-99)
		tmp = Float64(-0.5 * y);
	elseif (y <= 4.4e-205)
		tmp = Float64(1.5 * x);
	elseif (y <= 3.5e-59)
		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 (y <= -2.7e-99)
		tmp = -0.5 * y;
	elseif (y <= 4.4e-205)
		tmp = 1.5 * x;
	elseif (y <= 3.5e-59)
		tmp = 0.5 * x;
	else
		tmp = 0.5 * y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.7e-99], N[(-0.5 * y), $MachinePrecision], If[LessEqual[y, 4.4e-205], N[(1.5 * x), $MachinePrecision], If[LessEqual[y, 3.5e-59], N[(0.5 * x), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-99}:\\
\;\;\;\;-0.5 \cdot y\\

\mathbf{elif}\;y \leq 4.4 \cdot 10^{-205}:\\
\;\;\;\;1.5 \cdot x\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{-59}:\\
\;\;\;\;0.5 \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.7e-99

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left|x - y\right|, 0.5, x\right)} \]
    5. Step-by-step derivation
      1. Applied rewrites78.4%

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

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

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

        if -2.7e-99 < y < 4.40000000000000018e-205

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

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

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

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

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

            if 4.40000000000000018e-205 < y < 3.5000000000000001e-59

            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. sqrt-prodN/A

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

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

                \[\leadsto x + \frac{\color{blue}{\sqrt{y - x}} \cdot \sqrt{y - x}}{2} \]
              6. lower-sqrt.f6472.0

                \[\leadsto x + \frac{\sqrt{y - x} \cdot \color{blue}{\sqrt{y - x}}}{2} \]
            4. Applied rewrites72.0%

              \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
            5. Taylor expanded in x around inf

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

                \[\leadsto \color{blue}{0.5 \cdot x} \]
            7. Applied rewrites66.1%

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

            if 3.5000000000000001e-59 < 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. sqrt-prodN/A

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

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

                \[\leadsto x + \frac{\color{blue}{\sqrt{y - x}} \cdot \sqrt{y - x}}{2} \]
              6. lower-sqrt.f6484.2

                \[\leadsto x + \frac{\sqrt{y - x} \cdot \color{blue}{\sqrt{y - x}}}{2} \]
            4. Applied rewrites84.2%

              \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
            5. Taylor expanded in x around 0

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

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

              \[\leadsto \color{blue}{0.5 \cdot y} \]
          4. Recombined 4 regimes into one program.
          5. Final simplification70.1%

            \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-99}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-205}:\\ \;\;\;\;1.5 \cdot x\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-59}:\\ \;\;\;\;0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]
          6. Add Preprocessing

          Alternative 3: 82.2% accurate, 0.8× speedup?

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

            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. sqrt-prodN/A

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

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

                \[\leadsto x + \frac{\color{blue}{\sqrt{y - x}} \cdot \sqrt{y - x}}{2} \]
              6. lower-sqrt.f6492.3

                \[\leadsto x + \frac{\sqrt{y - x} \cdot \color{blue}{\sqrt{y - x}}}{2} \]
            4. Applied rewrites92.3%

              \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
            5. Taylor expanded in x around 0

              \[\leadsto \color{blue}{\frac{1}{2} \cdot x + \frac{1}{2} \cdot y} \]
            6. Step-by-step derivation
              1. distribute-lft-outN/A

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

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

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

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

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

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

            if -3.5e9 < x < 3.49999999999999983e-178

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

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

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

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

              if 3.49999999999999983e-178 < x

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\left|x - y\right|, 0.5, x\right)} \]
              5. Step-by-step derivation
                1. Applied rewrites82.7%

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

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

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

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

                Alternative 4: 79.6% accurate, 0.9× speedup?

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

                  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. sqrt-prodN/A

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

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

                      \[\leadsto x + \frac{\color{blue}{\sqrt{y - x}} \cdot \sqrt{y - x}}{2} \]
                    6. lower-sqrt.f6492.3

                      \[\leadsto x + \frac{\sqrt{y - x} \cdot \color{blue}{\sqrt{y - x}}}{2} \]
                  4. Applied rewrites92.3%

                    \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
                  5. Taylor expanded in x around 0

                    \[\leadsto \color{blue}{\frac{1}{2} \cdot x + \frac{1}{2} \cdot y} \]
                  6. Step-by-step derivation
                    1. distribute-lft-outN/A

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

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

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

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

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

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

                  if -3.5e9 < x < 5.2e14

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

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

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

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

                    if 5.2e14 < x

                    1. Initial program 99.8%

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

                      \[\leadsto \color{blue}{\mathsf{fma}\left(\left|x - y\right|, 0.5, x\right)} \]
                    5. Step-by-step derivation
                      1. Applied rewrites87.8%

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

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

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

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

                      Alternative 5: 78.3% accurate, 0.9× speedup?

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

                        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. sqrt-prodN/A

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

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

                            \[\leadsto x + \frac{\color{blue}{\sqrt{y - x}} \cdot \sqrt{y - x}}{2} \]
                          6. lower-sqrt.f6492.3

                            \[\leadsto x + \frac{\sqrt{y - x} \cdot \color{blue}{\sqrt{y - x}}}{2} \]
                        4. Applied rewrites92.3%

                          \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
                        5. Taylor expanded in x around 0

                          \[\leadsto \color{blue}{\frac{1}{2} \cdot x + \frac{1}{2} \cdot y} \]
                        6. Step-by-step derivation
                          1. distribute-lft-outN/A

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

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

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

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

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

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

                        if -1.35e9 < x < 5.2e14

                        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}} \]
                        5. Applied rewrites73.5%

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

                        if 5.2e14 < x

                        1. Initial program 99.8%

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

                          \[\leadsto \color{blue}{\mathsf{fma}\left(\left|x - y\right|, 0.5, x\right)} \]
                        5. Step-by-step derivation
                          1. Applied rewrites87.8%

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

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

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

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

                          Alternative 6: 77.6% accurate, 0.9× speedup?

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

                            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. sqrt-prodN/A

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

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

                                \[\leadsto x + \frac{\color{blue}{\sqrt{y - x}} \cdot \sqrt{y - x}}{2} \]
                              6. lower-sqrt.f6492.3

                                \[\leadsto x + \frac{\sqrt{y - x} \cdot \color{blue}{\sqrt{y - x}}}{2} \]
                            4. Applied rewrites92.3%

                              \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
                            5. Taylor expanded in x around 0

                              \[\leadsto \color{blue}{\frac{1}{2} \cdot x + \frac{1}{2} \cdot y} \]
                            6. Step-by-step derivation
                              1. distribute-lft-outN/A

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

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

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

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

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

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

                            if -1.35e9 < x < 1.95e14

                            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}} \]
                            5. Applied rewrites73.5%

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

                              \[\leadsto \left|-1 \cdot y\right| \cdot \frac{1}{2} \]
                            7. Step-by-step derivation
                              1. Applied rewrites71.9%

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

                              if 1.95e14 < x

                              1. Initial program 99.8%

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

                                \[\leadsto \color{blue}{\mathsf{fma}\left(\left|x - y\right|, 0.5, x\right)} \]
                              5. Step-by-step derivation
                                1. Applied rewrites87.8%

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

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

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

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

                                Alternative 7: 70.4% accurate, 1.0× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-99}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-246}:\\ \;\;\;\;1.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) \cdot 0.5\\ \end{array} \end{array} \]
                                (FPCore (x y)
                                 :precision binary64
                                 (if (<= y -2.7e-99)
                                   (* -0.5 y)
                                   (if (<= y 5.6e-246) (* 1.5 x) (* (+ y x) 0.5))))
                                double code(double x, double y) {
                                	double tmp;
                                	if (y <= -2.7e-99) {
                                		tmp = -0.5 * y;
                                	} else if (y <= 5.6e-246) {
                                		tmp = 1.5 * x;
                                	} else {
                                		tmp = (y + x) * 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 <= (-2.7d-99)) then
                                        tmp = (-0.5d0) * y
                                    else if (y <= 5.6d-246) then
                                        tmp = 1.5d0 * x
                                    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.7e-99) {
                                		tmp = -0.5 * y;
                                	} else if (y <= 5.6e-246) {
                                		tmp = 1.5 * x;
                                	} else {
                                		tmp = (y + x) * 0.5;
                                	}
                                	return tmp;
                                }
                                
                                def code(x, y):
                                	tmp = 0
                                	if y <= -2.7e-99:
                                		tmp = -0.5 * y
                                	elif y <= 5.6e-246:
                                		tmp = 1.5 * x
                                	else:
                                		tmp = (y + x) * 0.5
                                	return tmp
                                
                                function code(x, y)
                                	tmp = 0.0
                                	if (y <= -2.7e-99)
                                		tmp = Float64(-0.5 * y);
                                	elseif (y <= 5.6e-246)
                                		tmp = Float64(1.5 * x);
                                	else
                                		tmp = Float64(Float64(y + x) * 0.5);
                                	end
                                	return tmp
                                end
                                
                                function tmp_2 = code(x, y)
                                	tmp = 0.0;
                                	if (y <= -2.7e-99)
                                		tmp = -0.5 * y;
                                	elseif (y <= 5.6e-246)
                                		tmp = 1.5 * x;
                                	else
                                		tmp = (y + x) * 0.5;
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                code[x_, y_] := If[LessEqual[y, -2.7e-99], N[(-0.5 * y), $MachinePrecision], If[LessEqual[y, 5.6e-246], N[(1.5 * x), $MachinePrecision], N[(N[(y + x), $MachinePrecision] * 0.5), $MachinePrecision]]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;y \leq -2.7 \cdot 10^{-99}:\\
                                \;\;\;\;-0.5 \cdot y\\
                                
                                \mathbf{elif}\;y \leq 5.6 \cdot 10^{-246}:\\
                                \;\;\;\;1.5 \cdot x\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;\left(y + x\right) \cdot 0.5\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 3 regimes
                                2. if y < -2.7e-99

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

                                    \[\leadsto \color{blue}{\mathsf{fma}\left(\left|x - y\right|, 0.5, x\right)} \]
                                  5. Step-by-step derivation
                                    1. Applied rewrites78.4%

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

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

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

                                      if -2.7e-99 < y < 5.5999999999999999e-246

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

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

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

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

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

                                          if 5.5999999999999999e-246 < 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. sqrt-prodN/A

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

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

                                              \[\leadsto x + \frac{\color{blue}{\sqrt{y - x}} \cdot \sqrt{y - x}}{2} \]
                                            6. lower-sqrt.f6477.0

                                              \[\leadsto x + \frac{\sqrt{y - x} \cdot \color{blue}{\sqrt{y - x}}}{2} \]
                                          4. Applied rewrites77.0%

                                            \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
                                          5. Taylor expanded in x around 0

                                            \[\leadsto \color{blue}{\frac{1}{2} \cdot x + \frac{1}{2} \cdot y} \]
                                          6. Step-by-step derivation
                                            1. distribute-lft-outN/A

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

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

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

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

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

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

                                          \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-99}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-246}:\\ \;\;\;\;1.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) \cdot 0.5\\ \end{array} \]
                                        6. Add Preprocessing

                                        Alternative 8: 57.5% accurate, 1.1× speedup?

                                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1350000000:\\ \;\;\;\;0.5 \cdot x\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-147}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;1.5 \cdot x\\ \end{array} \end{array} \]
                                        (FPCore (x y)
                                         :precision binary64
                                         (if (<= x -1350000000.0) (* 0.5 x) (if (<= x 7.2e-147) (* -0.5 y) (* 1.5 x))))
                                        double code(double x, double y) {
                                        	double tmp;
                                        	if (x <= -1350000000.0) {
                                        		tmp = 0.5 * x;
                                        	} else if (x <= 7.2e-147) {
                                        		tmp = -0.5 * y;
                                        	} else {
                                        		tmp = 1.5 * x;
                                        	}
                                        	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 (x <= (-1350000000.0d0)) then
                                                tmp = 0.5d0 * x
                                            else if (x <= 7.2d-147) then
                                                tmp = (-0.5d0) * y
                                            else
                                                tmp = 1.5d0 * x
                                            end if
                                            code = tmp
                                        end function
                                        
                                        public static double code(double x, double y) {
                                        	double tmp;
                                        	if (x <= -1350000000.0) {
                                        		tmp = 0.5 * x;
                                        	} else if (x <= 7.2e-147) {
                                        		tmp = -0.5 * y;
                                        	} else {
                                        		tmp = 1.5 * x;
                                        	}
                                        	return tmp;
                                        }
                                        
                                        def code(x, y):
                                        	tmp = 0
                                        	if x <= -1350000000.0:
                                        		tmp = 0.5 * x
                                        	elif x <= 7.2e-147:
                                        		tmp = -0.5 * y
                                        	else:
                                        		tmp = 1.5 * x
                                        	return tmp
                                        
                                        function code(x, y)
                                        	tmp = 0.0
                                        	if (x <= -1350000000.0)
                                        		tmp = Float64(0.5 * x);
                                        	elseif (x <= 7.2e-147)
                                        		tmp = Float64(-0.5 * y);
                                        	else
                                        		tmp = Float64(1.5 * x);
                                        	end
                                        	return tmp
                                        end
                                        
                                        function tmp_2 = code(x, y)
                                        	tmp = 0.0;
                                        	if (x <= -1350000000.0)
                                        		tmp = 0.5 * x;
                                        	elseif (x <= 7.2e-147)
                                        		tmp = -0.5 * y;
                                        	else
                                        		tmp = 1.5 * x;
                                        	end
                                        	tmp_2 = tmp;
                                        end
                                        
                                        code[x_, y_] := If[LessEqual[x, -1350000000.0], N[(0.5 * x), $MachinePrecision], If[LessEqual[x, 7.2e-147], N[(-0.5 * y), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]]
                                        
                                        \begin{array}{l}
                                        
                                        \\
                                        \begin{array}{l}
                                        \mathbf{if}\;x \leq -1350000000:\\
                                        \;\;\;\;0.5 \cdot x\\
                                        
                                        \mathbf{elif}\;x \leq 7.2 \cdot 10^{-147}:\\
                                        \;\;\;\;-0.5 \cdot y\\
                                        
                                        \mathbf{else}:\\
                                        \;\;\;\;1.5 \cdot x\\
                                        
                                        
                                        \end{array}
                                        \end{array}
                                        
                                        Derivation
                                        1. Split input into 3 regimes
                                        2. if x < -1.35e9

                                          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. sqrt-prodN/A

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

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

                                              \[\leadsto x + \frac{\color{blue}{\sqrt{y - x}} \cdot \sqrt{y - x}}{2} \]
                                            6. lower-sqrt.f6492.3

                                              \[\leadsto x + \frac{\sqrt{y - x} \cdot \color{blue}{\sqrt{y - x}}}{2} \]
                                          4. Applied rewrites92.3%

                                            \[\leadsto x + \frac{\color{blue}{\sqrt{y - x} \cdot \sqrt{y - x}}}{2} \]
                                          5. Taylor expanded in x around inf

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

                                              \[\leadsto \color{blue}{0.5 \cdot x} \]
                                          7. Applied rewrites83.6%

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

                                          if -1.35e9 < x < 7.20000000000000023e-147

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

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

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

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

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

                                              if 7.20000000000000023e-147 < x

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

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

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

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

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

                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1350000000:\\ \;\;\;\;0.5 \cdot x\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-147}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;1.5 \cdot x\\ \end{array} \]
                                                6. Add Preprocessing

                                                Alternative 9: 46.2% accurate, 1.7× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-99}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{else}:\\ \;\;\;\;1.5 \cdot x\\ \end{array} \end{array} \]
                                                (FPCore (x y) :precision binary64 (if (<= y -2.7e-99) (* -0.5 y) (* 1.5 x)))
                                                double code(double x, double y) {
                                                	double tmp;
                                                	if (y <= -2.7e-99) {
                                                		tmp = -0.5 * y;
                                                	} else {
                                                		tmp = 1.5 * x;
                                                	}
                                                	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 <= (-2.7d-99)) then
                                                        tmp = (-0.5d0) * y
                                                    else
                                                        tmp = 1.5d0 * x
                                                    end if
                                                    code = tmp
                                                end function
                                                
                                                public static double code(double x, double y) {
                                                	double tmp;
                                                	if (y <= -2.7e-99) {
                                                		tmp = -0.5 * y;
                                                	} else {
                                                		tmp = 1.5 * x;
                                                	}
                                                	return tmp;
                                                }
                                                
                                                def code(x, y):
                                                	tmp = 0
                                                	if y <= -2.7e-99:
                                                		tmp = -0.5 * y
                                                	else:
                                                		tmp = 1.5 * x
                                                	return tmp
                                                
                                                function code(x, y)
                                                	tmp = 0.0
                                                	if (y <= -2.7e-99)
                                                		tmp = Float64(-0.5 * y);
                                                	else
                                                		tmp = Float64(1.5 * x);
                                                	end
                                                	return tmp
                                                end
                                                
                                                function tmp_2 = code(x, y)
                                                	tmp = 0.0;
                                                	if (y <= -2.7e-99)
                                                		tmp = -0.5 * y;
                                                	else
                                                		tmp = 1.5 * x;
                                                	end
                                                	tmp_2 = tmp;
                                                end
                                                
                                                code[x_, y_] := If[LessEqual[y, -2.7e-99], N[(-0.5 * y), $MachinePrecision], N[(1.5 * x), $MachinePrecision]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;y \leq -2.7 \cdot 10^{-99}:\\
                                                \;\;\;\;-0.5 \cdot y\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;1.5 \cdot x\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if y < -2.7e-99

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

                                                    \[\leadsto \color{blue}{\mathsf{fma}\left(\left|x - y\right|, 0.5, x\right)} \]
                                                  5. Step-by-step derivation
                                                    1. Applied rewrites78.4%

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

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

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

                                                      if -2.7e-99 < y

                                                      1. Initial program 99.9%

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

                                                        \[\leadsto \color{blue}{x + \frac{1}{2} \cdot \left|y - x\right|} \]
                                                      4. Applied rewrites99.9%

                                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\left|x - y\right|, 0.5, x\right)} \]
                                                      5. Step-by-step derivation
                                                        1. Applied rewrites35.9%

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

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

                                                            \[\leadsto 1.5 \cdot \color{blue}{x} \]
                                                        4. Recombined 2 regimes into one program.
                                                        5. Add Preprocessing

                                                        Alternative 10: 26.6% accurate, 3.3× speedup?

                                                        \[\begin{array}{l} \\ -0.5 \cdot y \end{array} \]
                                                        (FPCore (x y) :precision binary64 (* -0.5 y))
                                                        double code(double x, double y) {
                                                        	return -0.5 * y;
                                                        }
                                                        
                                                        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 = (-0.5d0) * y
                                                        end function
                                                        
                                                        public static double code(double x, double y) {
                                                        	return -0.5 * y;
                                                        }
                                                        
                                                        def code(x, y):
                                                        	return -0.5 * y
                                                        
                                                        function code(x, y)
                                                        	return Float64(-0.5 * y)
                                                        end
                                                        
                                                        function tmp = code(x, y)
                                                        	tmp = -0.5 * y;
                                                        end
                                                        
                                                        code[x_, y_] := N[(-0.5 * y), $MachinePrecision]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        -0.5 \cdot y
                                                        \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. Applied rewrites99.9%

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

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

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

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

                                                            Reproduce

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