Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3

Percentage Accurate: 77.8% → 100.0%
Time: 5.6s
Alternatives: 8
Speedup: 1.5×

Specification

?
\[\begin{array}{l} \\ x + \left(1 - x\right) \cdot \left(1 - y\right) \end{array} \]
(FPCore (x y) :precision binary64 (+ x (* (- 1.0 x) (- 1.0 y))))
double code(double x, double y) {
	return x + ((1.0 - x) * (1.0 - 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 = x + ((1.0d0 - x) * (1.0d0 - y))
end function
public static double code(double x, double y) {
	return x + ((1.0 - x) * (1.0 - y));
}
def code(x, y):
	return x + ((1.0 - x) * (1.0 - y))
function code(x, y)
	return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y)))
end
function tmp = code(x, y)
	tmp = x + ((1.0 - x) * (1.0 - y));
end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(1 - x\right) \cdot \left(1 - y\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 77.8% accurate, 1.0× speedup?

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

\\
x + \left(1 - x\right) \cdot \left(1 - y\right)
\end{array}

Alternative 1: 100.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ 1 - \left(y - y \cdot x\right) \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (- y (* y x))))
double code(double x, double y) {
	return 1.0 - (y - (y * x));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0 - (y - (y * x))
end function
public static double code(double x, double y) {
	return 1.0 - (y - (y * x));
}
def code(x, y):
	return 1.0 - (y - (y * x))
function code(x, y)
	return Float64(1.0 - Float64(y - Float64(y * x)))
end
function tmp = code(x, y)
	tmp = 1.0 - (y - (y * x));
end
code[x_, y_] := N[(1.0 - N[(y - N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \left(y - y \cdot x\right)
\end{array}
Derivation
  1. Initial program 81.1%

    \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\left(1 + x \cdot \left(1 + -1 \cdot \left(1 - y\right)\right)\right) - y} \]
  4. Step-by-step derivation
    1. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, 1 - y\right)} \]
    2. Step-by-step derivation
      1. Applied rewrites100.0%

        \[\leadsto 1 - \color{blue}{\left(y - y \cdot x\right)} \]
      2. Add Preprocessing

      Alternative 2: 99.0% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -210000 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;y \cdot x - y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, x, 1\right)\\ \end{array} \end{array} \]
      (FPCore (x y)
       :precision binary64
       (if (or (<= y -210000.0) (not (<= y 1.0))) (- (* y x) y) (fma y x 1.0)))
      double code(double x, double y) {
      	double tmp;
      	if ((y <= -210000.0) || !(y <= 1.0)) {
      		tmp = (y * x) - y;
      	} else {
      		tmp = fma(y, x, 1.0);
      	}
      	return tmp;
      }
      
      function code(x, y)
      	tmp = 0.0
      	if ((y <= -210000.0) || !(y <= 1.0))
      		tmp = Float64(Float64(y * x) - y);
      	else
      		tmp = fma(y, x, 1.0);
      	end
      	return tmp
      end
      
      code[x_, y_] := If[Or[LessEqual[y, -210000.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] - y), $MachinePrecision], N[(y * x + 1.0), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y \leq -210000 \lor \neg \left(y \leq 1\right):\\
      \;\;\;\;y \cdot x - y\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(y, x, 1\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -2.1e5 or 1 < y

        1. Initial program 100.0%

          \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
        2. Add Preprocessing
        3. Taylor expanded in y around inf

          \[\leadsto \color{blue}{-1 \cdot \left(y \cdot \left(1 - x\right)\right)} \]
        4. Applied rewrites99.8%

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

        if -2.1e5 < y < 1

        1. Initial program 64.5%

          \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
        2. Add Preprocessing
        3. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\left(1 + x \cdot \left(1 + -1 \cdot \left(1 - y\right)\right)\right) - y} \]
        4. Step-by-step derivation
          1. Applied rewrites100.0%

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

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

              \[\leadsto \mathsf{fma}\left(y, x, 1\right) \]
          4. Recombined 2 regimes into one program.
          5. Final simplification99.6%

            \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -210000 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;y \cdot x - y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, x, 1\right)\\ \end{array} \]
          6. Add Preprocessing

          Alternative 3: 61.6% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;1 - y \leq -2 \cdot 10^{+24} \lor \neg \left(1 - y \leq 400000\right):\\ \;\;\;\;-y\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
          (FPCore (x y)
           :precision binary64
           (if (or (<= (- 1.0 y) -2e+24) (not (<= (- 1.0 y) 400000.0))) (- y) 1.0))
          double code(double x, double y) {
          	double tmp;
          	if (((1.0 - y) <= -2e+24) || !((1.0 - y) <= 400000.0)) {
          		tmp = -y;
          	} else {
          		tmp = 1.0;
          	}
          	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 (((1.0d0 - y) <= (-2d+24)) .or. (.not. ((1.0d0 - y) <= 400000.0d0))) then
                  tmp = -y
              else
                  tmp = 1.0d0
              end if
              code = tmp
          end function
          
          public static double code(double x, double y) {
          	double tmp;
          	if (((1.0 - y) <= -2e+24) || !((1.0 - y) <= 400000.0)) {
          		tmp = -y;
          	} else {
          		tmp = 1.0;
          	}
          	return tmp;
          }
          
          def code(x, y):
          	tmp = 0
          	if ((1.0 - y) <= -2e+24) or not ((1.0 - y) <= 400000.0):
          		tmp = -y
          	else:
          		tmp = 1.0
          	return tmp
          
          function code(x, y)
          	tmp = 0.0
          	if ((Float64(1.0 - y) <= -2e+24) || !(Float64(1.0 - y) <= 400000.0))
          		tmp = Float64(-y);
          	else
          		tmp = 1.0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y)
          	tmp = 0.0;
          	if (((1.0 - y) <= -2e+24) || ~(((1.0 - y) <= 400000.0)))
          		tmp = -y;
          	else
          		tmp = 1.0;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_] := If[Or[LessEqual[N[(1.0 - y), $MachinePrecision], -2e+24], N[Not[LessEqual[N[(1.0 - y), $MachinePrecision], 400000.0]], $MachinePrecision]], (-y), 1.0]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;1 - y \leq -2 \cdot 10^{+24} \lor \neg \left(1 - y \leq 400000\right):\\
          \;\;\;\;-y\\
          
          \mathbf{else}:\\
          \;\;\;\;1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (-.f64 #s(literal 1 binary64) y) < -2e24 or 4e5 < (-.f64 #s(literal 1 binary64) y)

            1. Initial program 100.0%

              \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
            2. Add Preprocessing
            3. Taylor expanded in y around inf

              \[\leadsto \color{blue}{-1 \cdot \left(y \cdot \left(1 - x\right)\right)} \]
            4. Applied rewrites99.7%

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

              \[\leadsto -1 \cdot \color{blue}{y} \]
            6. Step-by-step derivation
              1. Applied rewrites60.1%

                \[\leadsto -y \]

              if -2e24 < (-.f64 #s(literal 1 binary64) y) < 4e5

              1. Initial program 65.0%

                \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
              2. Add Preprocessing
              3. Taylor expanded in y around 0

                \[\leadsto \color{blue}{1} \]
              4. Step-by-step derivation
                1. Applied rewrites79.9%

                  \[\leadsto \color{blue}{1} \]
              5. Recombined 2 regimes into one program.
              6. Final simplification70.8%

                \[\leadsto \begin{array}{l} \mathbf{if}\;1 - y \leq -2 \cdot 10^{+24} \lor \neg \left(1 - y \leq 400000\right):\\ \;\;\;\;-y\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
              7. Add Preprocessing

              Alternative 4: 98.4% accurate, 0.8× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.08 \cdot 10^{-23}\right):\\ \;\;\;\;\mathsf{fma}\left(y, x, 1\right)\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \end{array} \]
              (FPCore (x y)
               :precision binary64
               (if (or (<= x -1.0) (not (<= x 1.08e-23))) (fma y x 1.0) (- 1.0 y)))
              double code(double x, double y) {
              	double tmp;
              	if ((x <= -1.0) || !(x <= 1.08e-23)) {
              		tmp = fma(y, x, 1.0);
              	} else {
              		tmp = 1.0 - y;
              	}
              	return tmp;
              }
              
              function code(x, y)
              	tmp = 0.0
              	if ((x <= -1.0) || !(x <= 1.08e-23))
              		tmp = fma(y, x, 1.0);
              	else
              		tmp = Float64(1.0 - y);
              	end
              	return tmp
              end
              
              code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.08e-23]], $MachinePrecision]], N[(y * x + 1.0), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.08 \cdot 10^{-23}\right):\\
              \;\;\;\;\mathsf{fma}\left(y, x, 1\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;1 - y\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if x < -1 or 1.08000000000000003e-23 < x

                1. Initial program 56.9%

                  \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
                2. Add Preprocessing
                3. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{\left(1 + x \cdot \left(1 + -1 \cdot \left(1 - y\right)\right)\right) - y} \]
                4. Step-by-step derivation
                  1. Applied rewrites100.0%

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

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

                      \[\leadsto \mathsf{fma}\left(y, x, 1\right) \]

                    if -1 < x < 1.08000000000000003e-23

                    1. Initial program 100.0%

                      \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
                    2. Add Preprocessing
                    3. Taylor expanded in x around 0

                      \[\leadsto \color{blue}{1 - y} \]
                    4. Step-by-step derivation
                      1. Applied rewrites99.8%

                        \[\leadsto \color{blue}{1 - y} \]
                    5. Recombined 2 regimes into one program.
                    6. Final simplification99.5%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1.08 \cdot 10^{-23}\right):\\ \;\;\;\;\mathsf{fma}\left(y, x, 1\right)\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \]
                    7. Add Preprocessing

                    Alternative 5: 84.7% accurate, 0.8× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{+151} \lor \neg \left(x \leq 2.3 \cdot 10^{+25}\right):\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \end{array} \]
                    (FPCore (x y)
                     :precision binary64
                     (if (or (<= x -4.5e+151) (not (<= x 2.3e+25))) (* y x) (- 1.0 y)))
                    double code(double x, double y) {
                    	double tmp;
                    	if ((x <= -4.5e+151) || !(x <= 2.3e+25)) {
                    		tmp = y * x;
                    	} else {
                    		tmp = 1.0 - 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 ((x <= (-4.5d+151)) .or. (.not. (x <= 2.3d+25))) then
                            tmp = y * x
                        else
                            tmp = 1.0d0 - y
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double x, double y) {
                    	double tmp;
                    	if ((x <= -4.5e+151) || !(x <= 2.3e+25)) {
                    		tmp = y * x;
                    	} else {
                    		tmp = 1.0 - y;
                    	}
                    	return tmp;
                    }
                    
                    def code(x, y):
                    	tmp = 0
                    	if (x <= -4.5e+151) or not (x <= 2.3e+25):
                    		tmp = y * x
                    	else:
                    		tmp = 1.0 - y
                    	return tmp
                    
                    function code(x, y)
                    	tmp = 0.0
                    	if ((x <= -4.5e+151) || !(x <= 2.3e+25))
                    		tmp = Float64(y * x);
                    	else
                    		tmp = Float64(1.0 - y);
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(x, y)
                    	tmp = 0.0;
                    	if ((x <= -4.5e+151) || ~((x <= 2.3e+25)))
                    		tmp = y * x;
                    	else
                    		tmp = 1.0 - y;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_, y_] := If[Or[LessEqual[x, -4.5e+151], N[Not[LessEqual[x, 2.3e+25]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;x \leq -4.5 \cdot 10^{+151} \lor \neg \left(x \leq 2.3 \cdot 10^{+25}\right):\\
                    \;\;\;\;y \cdot x\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;1 - y\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if x < -4.4999999999999999e151 or 2.2999999999999998e25 < x

                      1. Initial program 56.5%

                        \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
                      2. Add Preprocessing
                      3. Taylor expanded in x around inf

                        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(1 - y\right)\right)} \]
                      4. Step-by-step derivation
                        1. Applied rewrites80.0%

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

                        if -4.4999999999999999e151 < x < 2.2999999999999998e25

                        1. Initial program 92.7%

                          \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
                        2. Add Preprocessing
                        3. Taylor expanded in x around 0

                          \[\leadsto \color{blue}{1 - y} \]
                        4. Step-by-step derivation
                          1. Applied rewrites94.8%

                            \[\leadsto \color{blue}{1 - y} \]
                        5. Recombined 2 regimes into one program.
                        6. Final simplification90.1%

                          \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{+151} \lor \neg \left(x \leq 2.3 \cdot 10^{+25}\right):\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \]
                        7. Add Preprocessing

                        Alternative 6: 100.0% accurate, 1.5× speedup?

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

                          \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
                        2. Add Preprocessing
                        3. Taylor expanded in x around 0

                          \[\leadsto \color{blue}{\left(1 + x \cdot \left(1 + -1 \cdot \left(1 - y\right)\right)\right) - y} \]
                        4. Step-by-step derivation
                          1. Applied rewrites100.0%

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

                          Alternative 7: 63.3% accurate, 3.8× speedup?

                          \[\begin{array}{l} \\ 1 - y \end{array} \]
                          (FPCore (x y) :precision binary64 (- 1.0 y))
                          double code(double x, double y) {
                          	return 1.0 - 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 = 1.0d0 - y
                          end function
                          
                          public static double code(double x, double y) {
                          	return 1.0 - y;
                          }
                          
                          def code(x, y):
                          	return 1.0 - y
                          
                          function code(x, y)
                          	return Float64(1.0 - y)
                          end
                          
                          function tmp = code(x, y)
                          	tmp = 1.0 - y;
                          end
                          
                          code[x_, y_] := N[(1.0 - y), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          1 - y
                          \end{array}
                          
                          Derivation
                          1. Initial program 81.1%

                            \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
                          2. Add Preprocessing
                          3. Taylor expanded in x around 0

                            \[\leadsto \color{blue}{1 - y} \]
                          4. Step-by-step derivation
                            1. Applied rewrites71.1%

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

                            Alternative 8: 37.8% accurate, 15.0× speedup?

                            \[\begin{array}{l} \\ 1 \end{array} \]
                            (FPCore (x y) :precision binary64 1.0)
                            double code(double x, double y) {
                            	return 1.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 = 1.0d0
                            end function
                            
                            public static double code(double x, double y) {
                            	return 1.0;
                            }
                            
                            def code(x, y):
                            	return 1.0
                            
                            function code(x, y)
                            	return 1.0
                            end
                            
                            function tmp = code(x, y)
                            	tmp = 1.0;
                            end
                            
                            code[x_, y_] := 1.0
                            
                            \begin{array}{l}
                            
                            \\
                            1
                            \end{array}
                            
                            Derivation
                            1. Initial program 81.1%

                              \[x + \left(1 - x\right) \cdot \left(1 - y\right) \]
                            2. Add Preprocessing
                            3. Taylor expanded in y around 0

                              \[\leadsto \color{blue}{1} \]
                            4. Step-by-step derivation
                              1. Applied rewrites44.3%

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

                              Developer Target 1: 100.0% accurate, 1.3× speedup?

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

                              Reproduce

                              ?
                              herbie shell --seed 2025021 
                              (FPCore (x y)
                                :name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
                                :precision binary64
                              
                                :alt
                                (! :herbie-platform default (- (* y x) (- y 1)))
                              
                                (+ x (* (- 1.0 x) (- 1.0 y))))