Main:bigenough2 from A

Percentage Accurate: 100.0% → 100.0%
Time: 1.8s
Alternatives: 5
Speedup: 1.1×

Specification

?
\[x + y \cdot \left(z + x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* y (+ z x))))
double code(double x, double y, double z) {
	return x + (y * (z + 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, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + (y * (z + x))
end function
public static double code(double x, double y, double z) {
	return x + (y * (z + x));
}
def code(x, y, z):
	return x + (y * (z + x))
function code(x, y, z)
	return Float64(x + Float64(y * Float64(z + x)))
end
function tmp = code(x, y, z)
	tmp = x + (y * (z + x));
end
code[x_, y_, z_] := N[(x + N[(y * N[(z + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + y \cdot \left(z + x\right)

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 5 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: 100.0% accurate, 1.0× speedup?

\[x + y \cdot \left(z + x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* y (+ z x))))
double code(double x, double y, double z) {
	return x + (y * (z + 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, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + (y * (z + x))
end function
public static double code(double x, double y, double z) {
	return x + (y * (z + x));
}
def code(x, y, z):
	return x + (y * (z + x))
function code(x, y, z)
	return Float64(x + Float64(y * Float64(z + x)))
end
function tmp = code(x, y, z)
	tmp = x + (y * (z + x));
end
code[x_, y_, z_] := N[(x + N[(y * N[(z + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + y \cdot \left(z + x\right)

Alternative 1: 100.0% accurate, 1.1× speedup?

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

    \[x + y \cdot \left(z + x\right) \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

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

      \[\leadsto \color{blue}{y \cdot \left(z + x\right) + x} \]
    3. add-flipN/A

      \[\leadsto \color{blue}{y \cdot \left(z + x\right) - \left(\mathsf{neg}\left(x\right)\right)} \]
    4. sub-flipN/A

      \[\leadsto \color{blue}{y \cdot \left(z + x\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
    5. lift-*.f64N/A

      \[\leadsto \color{blue}{y \cdot \left(z + x\right)} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \color{blue}{\left(z + x\right) \cdot y} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
    7. remove-double-negN/A

      \[\leadsto \left(z + x\right) \cdot y + \color{blue}{x} \]
    8. lower-fma.f64100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z + x, y, x\right)} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z + x, y, x\right)} \]
  4. Add Preprocessing

Alternative 2: 98.7% accurate, 0.7× speedup?

\[\begin{array}{l} t_0 := y \cdot \left(x + z\right)\\ \mathbf{if}\;y \leq -980:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 16600000:\\ \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ x z))))
   (if (<= y -980.0) t_0 (if (<= y 16600000.0) (fma z y x) t_0))))
double code(double x, double y, double z) {
	double t_0 = y * (x + z);
	double tmp;
	if (y <= -980.0) {
		tmp = t_0;
	} else if (y <= 16600000.0) {
		tmp = fma(z, y, x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(y * Float64(x + z))
	tmp = 0.0
	if (y <= -980.0)
		tmp = t_0;
	elseif (y <= 16600000.0)
		tmp = fma(z, y, x);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -980.0], t$95$0, If[LessEqual[y, 16600000.0], N[(z * y + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := y \cdot \left(x + z\right)\\
\mathbf{if}\;y \leq -980:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 16600000:\\
\;\;\;\;\mathsf{fma}\left(z, y, x\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -980 or 1.66e7 < y

    1. Initial program 100.0%

      \[x + y \cdot \left(z + x\right) \]
    2. Taylor expanded in x around 0

      \[\leadsto x + y \cdot \color{blue}{z} \]
    3. Step-by-step derivation
      1. Applied rewrites76.0%

        \[\leadsto x + y \cdot \color{blue}{z} \]
      2. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \color{blue}{x + y \cdot z} \]
        2. +-commutativeN/A

          \[\leadsto \color{blue}{y \cdot z + x} \]
        3. add-flipN/A

          \[\leadsto \color{blue}{y \cdot z - \left(\mathsf{neg}\left(x\right)\right)} \]
        4. sub-flipN/A

          \[\leadsto \color{blue}{y \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
        5. remove-double-negN/A

          \[\leadsto y \cdot z + \color{blue}{x} \]
        6. *-lft-identityN/A

          \[\leadsto y \cdot z + \color{blue}{1 \cdot x} \]
        7. metadata-evalN/A

          \[\leadsto y \cdot z + \color{blue}{\left(0 + 1\right)} \cdot x \]
        8. distribute-rgt1-inN/A

          \[\leadsto y \cdot z + \color{blue}{\left(x + 0 \cdot x\right)} \]
        9. mul0-lftN/A

          \[\leadsto y \cdot z + \left(x + \color{blue}{0}\right) \]
        10. lift-*.f64N/A

          \[\leadsto \color{blue}{y \cdot z} + \left(x + 0\right) \]
        11. *-commutativeN/A

          \[\leadsto \color{blue}{z \cdot y} + \left(x + 0\right) \]
        12. mul0-lftN/A

          \[\leadsto z \cdot y + \left(x + \color{blue}{0 \cdot x}\right) \]
        13. distribute-rgt1-inN/A

          \[\leadsto z \cdot y + \color{blue}{\left(0 + 1\right) \cdot x} \]
        14. metadata-evalN/A

          \[\leadsto z \cdot y + \color{blue}{1} \cdot x \]
        15. *-lft-identityN/A

          \[\leadsto z \cdot y + \color{blue}{x} \]
        16. lower-fma.f6476.0%

          \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, x\right)} \]
      3. Applied rewrites76.0%

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

        \[\leadsto \color{blue}{y \cdot \left(x + z\right)} \]
      5. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto y \cdot \color{blue}{\left(x + z\right)} \]
        2. lower-+.f6466.0%

          \[\leadsto y \cdot \left(x + \color{blue}{z}\right) \]
      6. Applied rewrites66.0%

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

      if -980 < y < 1.66e7

      1. Initial program 100.0%

        \[x + y \cdot \left(z + x\right) \]
      2. Taylor expanded in x around 0

        \[\leadsto x + y \cdot \color{blue}{z} \]
      3. Step-by-step derivation
        1. Applied rewrites76.0%

          \[\leadsto x + y \cdot \color{blue}{z} \]
        2. Step-by-step derivation
          1. lift-+.f64N/A

            \[\leadsto \color{blue}{x + y \cdot z} \]
          2. +-commutativeN/A

            \[\leadsto \color{blue}{y \cdot z + x} \]
          3. add-flipN/A

            \[\leadsto \color{blue}{y \cdot z - \left(\mathsf{neg}\left(x\right)\right)} \]
          4. sub-flipN/A

            \[\leadsto \color{blue}{y \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
          5. remove-double-negN/A

            \[\leadsto y \cdot z + \color{blue}{x} \]
          6. *-lft-identityN/A

            \[\leadsto y \cdot z + \color{blue}{1 \cdot x} \]
          7. metadata-evalN/A

            \[\leadsto y \cdot z + \color{blue}{\left(0 + 1\right)} \cdot x \]
          8. distribute-rgt1-inN/A

            \[\leadsto y \cdot z + \color{blue}{\left(x + 0 \cdot x\right)} \]
          9. mul0-lftN/A

            \[\leadsto y \cdot z + \left(x + \color{blue}{0}\right) \]
          10. lift-*.f64N/A

            \[\leadsto \color{blue}{y \cdot z} + \left(x + 0\right) \]
          11. *-commutativeN/A

            \[\leadsto \color{blue}{z \cdot y} + \left(x + 0\right) \]
          12. mul0-lftN/A

            \[\leadsto z \cdot y + \left(x + \color{blue}{0 \cdot x}\right) \]
          13. distribute-rgt1-inN/A

            \[\leadsto z \cdot y + \color{blue}{\left(0 + 1\right) \cdot x} \]
          14. metadata-evalN/A

            \[\leadsto z \cdot y + \color{blue}{1} \cdot x \]
          15. *-lft-identityN/A

            \[\leadsto z \cdot y + \color{blue}{x} \]
          16. lower-fma.f6476.0%

            \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, x\right)} \]
        3. Applied rewrites76.0%

          \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, x\right)} \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 3: 74.0% accurate, 0.7× speedup?

      \[\begin{array}{l} \mathbf{if}\;x \leq 3.4 \cdot 10^{+109}:\\ \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\ \mathbf{elif}\;x \leq 7 \cdot 10^{+253}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\ \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (if (<= x 3.4e+109) (fma z y x) (if (<= x 7e+253) (* x y) (fma z y x))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (x <= 3.4e+109) {
      		tmp = fma(z, y, x);
      	} else if (x <= 7e+253) {
      		tmp = x * y;
      	} else {
      		tmp = fma(z, y, x);
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	tmp = 0.0
      	if (x <= 3.4e+109)
      		tmp = fma(z, y, x);
      	elseif (x <= 7e+253)
      		tmp = Float64(x * y);
      	else
      		tmp = fma(z, y, x);
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := If[LessEqual[x, 3.4e+109], N[(z * y + x), $MachinePrecision], If[LessEqual[x, 7e+253], N[(x * y), $MachinePrecision], N[(z * y + x), $MachinePrecision]]]
      
      \begin{array}{l}
      \mathbf{if}\;x \leq 3.4 \cdot 10^{+109}:\\
      \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
      
      \mathbf{elif}\;x \leq 7 \cdot 10^{+253}:\\
      \;\;\;\;x \cdot y\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 3.40000000000000006e109 or 6.99999999999999955e253 < x

        1. Initial program 100.0%

          \[x + y \cdot \left(z + x\right) \]
        2. Taylor expanded in x around 0

          \[\leadsto x + y \cdot \color{blue}{z} \]
        3. Step-by-step derivation
          1. Applied rewrites76.0%

            \[\leadsto x + y \cdot \color{blue}{z} \]
          2. Step-by-step derivation
            1. lift-+.f64N/A

              \[\leadsto \color{blue}{x + y \cdot z} \]
            2. +-commutativeN/A

              \[\leadsto \color{blue}{y \cdot z + x} \]
            3. add-flipN/A

              \[\leadsto \color{blue}{y \cdot z - \left(\mathsf{neg}\left(x\right)\right)} \]
            4. sub-flipN/A

              \[\leadsto \color{blue}{y \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
            5. remove-double-negN/A

              \[\leadsto y \cdot z + \color{blue}{x} \]
            6. *-lft-identityN/A

              \[\leadsto y \cdot z + \color{blue}{1 \cdot x} \]
            7. metadata-evalN/A

              \[\leadsto y \cdot z + \color{blue}{\left(0 + 1\right)} \cdot x \]
            8. distribute-rgt1-inN/A

              \[\leadsto y \cdot z + \color{blue}{\left(x + 0 \cdot x\right)} \]
            9. mul0-lftN/A

              \[\leadsto y \cdot z + \left(x + \color{blue}{0}\right) \]
            10. lift-*.f64N/A

              \[\leadsto \color{blue}{y \cdot z} + \left(x + 0\right) \]
            11. *-commutativeN/A

              \[\leadsto \color{blue}{z \cdot y} + \left(x + 0\right) \]
            12. mul0-lftN/A

              \[\leadsto z \cdot y + \left(x + \color{blue}{0 \cdot x}\right) \]
            13. distribute-rgt1-inN/A

              \[\leadsto z \cdot y + \color{blue}{\left(0 + 1\right) \cdot x} \]
            14. metadata-evalN/A

              \[\leadsto z \cdot y + \color{blue}{1} \cdot x \]
            15. *-lft-identityN/A

              \[\leadsto z \cdot y + \color{blue}{x} \]
            16. lower-fma.f6476.0%

              \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, x\right)} \]
          3. Applied rewrites76.0%

            \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, x\right)} \]

          if 3.40000000000000006e109 < x < 6.99999999999999955e253

          1. Initial program 100.0%

            \[x + y \cdot \left(z + x\right) \]
          2. Taylor expanded in x around 0

            \[\leadsto x + y \cdot \color{blue}{z} \]
          3. Step-by-step derivation
            1. Applied rewrites76.0%

              \[\leadsto x + y \cdot \color{blue}{z} \]
            2. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto \color{blue}{x + y \cdot z} \]
              2. +-commutativeN/A

                \[\leadsto \color{blue}{y \cdot z + x} \]
              3. add-flipN/A

                \[\leadsto \color{blue}{y \cdot z - \left(\mathsf{neg}\left(x\right)\right)} \]
              4. sub-flipN/A

                \[\leadsto \color{blue}{y \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
              5. remove-double-negN/A

                \[\leadsto y \cdot z + \color{blue}{x} \]
              6. *-lft-identityN/A

                \[\leadsto y \cdot z + \color{blue}{1 \cdot x} \]
              7. metadata-evalN/A

                \[\leadsto y \cdot z + \color{blue}{\left(0 + 1\right)} \cdot x \]
              8. distribute-rgt1-inN/A

                \[\leadsto y \cdot z + \color{blue}{\left(x + 0 \cdot x\right)} \]
              9. mul0-lftN/A

                \[\leadsto y \cdot z + \left(x + \color{blue}{0}\right) \]
              10. lift-*.f64N/A

                \[\leadsto \color{blue}{y \cdot z} + \left(x + 0\right) \]
              11. *-commutativeN/A

                \[\leadsto \color{blue}{z \cdot y} + \left(x + 0\right) \]
              12. mul0-lftN/A

                \[\leadsto z \cdot y + \left(x + \color{blue}{0 \cdot x}\right) \]
              13. distribute-rgt1-inN/A

                \[\leadsto z \cdot y + \color{blue}{\left(0 + 1\right) \cdot x} \]
              14. metadata-evalN/A

                \[\leadsto z \cdot y + \color{blue}{1} \cdot x \]
              15. *-lft-identityN/A

                \[\leadsto z \cdot y + \color{blue}{x} \]
              16. lower-fma.f6476.0%

                \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, x\right)} \]
            3. Applied rewrites76.0%

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

              \[\leadsto \color{blue}{y \cdot \left(x + z\right)} \]
            5. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto y \cdot \color{blue}{\left(x + z\right)} \]
              2. lower-+.f6466.0%

                \[\leadsto y \cdot \left(x + \color{blue}{z}\right) \]
            6. Applied rewrites66.0%

              \[\leadsto \color{blue}{y \cdot \left(x + z\right)} \]
            7. Taylor expanded in x around inf

              \[\leadsto x \cdot \color{blue}{y} \]
            8. Step-by-step derivation
              1. lower-*.f6428.2%

                \[\leadsto x \cdot y \]
            9. Applied rewrites28.2%

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

          Alternative 4: 52.1% accurate, 0.8× speedup?

          \[\begin{array}{l} \mathbf{if}\;x \leq -32000000000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-11}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= x -32000000000000.0) (* x y) (if (<= x 4e-11) (* y z) (* x y))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (x <= -32000000000000.0) {
          		tmp = x * y;
          	} else if (x <= 4e-11) {
          		tmp = y * z;
          	} else {
          		tmp = x * 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, z)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8) :: tmp
              if (x <= (-32000000000000.0d0)) then
                  tmp = x * y
              else if (x <= 4d-11) then
                  tmp = y * z
              else
                  tmp = x * y
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if (x <= -32000000000000.0) {
          		tmp = x * y;
          	} else if (x <= 4e-11) {
          		tmp = y * z;
          	} else {
          		tmp = x * y;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if x <= -32000000000000.0:
          		tmp = x * y
          	elif x <= 4e-11:
          		tmp = y * z
          	else:
          		tmp = x * y
          	return tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if (x <= -32000000000000.0)
          		tmp = Float64(x * y);
          	elseif (x <= 4e-11)
          		tmp = Float64(y * z);
          	else
          		tmp = Float64(x * y);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if (x <= -32000000000000.0)
          		tmp = x * y;
          	elseif (x <= 4e-11)
          		tmp = y * z;
          	else
          		tmp = x * y;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := If[LessEqual[x, -32000000000000.0], N[(x * y), $MachinePrecision], If[LessEqual[x, 4e-11], N[(y * z), $MachinePrecision], N[(x * y), $MachinePrecision]]]
          
          \begin{array}{l}
          \mathbf{if}\;x \leq -32000000000000:\\
          \;\;\;\;x \cdot y\\
          
          \mathbf{elif}\;x \leq 4 \cdot 10^{-11}:\\
          \;\;\;\;y \cdot z\\
          
          \mathbf{else}:\\
          \;\;\;\;x \cdot y\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -3.2e13 or 3.99999999999999976e-11 < x

            1. Initial program 100.0%

              \[x + y \cdot \left(z + x\right) \]
            2. Taylor expanded in x around 0

              \[\leadsto x + y \cdot \color{blue}{z} \]
            3. Step-by-step derivation
              1. Applied rewrites76.0%

                \[\leadsto x + y \cdot \color{blue}{z} \]
              2. Step-by-step derivation
                1. lift-+.f64N/A

                  \[\leadsto \color{blue}{x + y \cdot z} \]
                2. +-commutativeN/A

                  \[\leadsto \color{blue}{y \cdot z + x} \]
                3. add-flipN/A

                  \[\leadsto \color{blue}{y \cdot z - \left(\mathsf{neg}\left(x\right)\right)} \]
                4. sub-flipN/A

                  \[\leadsto \color{blue}{y \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
                5. remove-double-negN/A

                  \[\leadsto y \cdot z + \color{blue}{x} \]
                6. *-lft-identityN/A

                  \[\leadsto y \cdot z + \color{blue}{1 \cdot x} \]
                7. metadata-evalN/A

                  \[\leadsto y \cdot z + \color{blue}{\left(0 + 1\right)} \cdot x \]
                8. distribute-rgt1-inN/A

                  \[\leadsto y \cdot z + \color{blue}{\left(x + 0 \cdot x\right)} \]
                9. mul0-lftN/A

                  \[\leadsto y \cdot z + \left(x + \color{blue}{0}\right) \]
                10. lift-*.f64N/A

                  \[\leadsto \color{blue}{y \cdot z} + \left(x + 0\right) \]
                11. *-commutativeN/A

                  \[\leadsto \color{blue}{z \cdot y} + \left(x + 0\right) \]
                12. mul0-lftN/A

                  \[\leadsto z \cdot y + \left(x + \color{blue}{0 \cdot x}\right) \]
                13. distribute-rgt1-inN/A

                  \[\leadsto z \cdot y + \color{blue}{\left(0 + 1\right) \cdot x} \]
                14. metadata-evalN/A

                  \[\leadsto z \cdot y + \color{blue}{1} \cdot x \]
                15. *-lft-identityN/A

                  \[\leadsto z \cdot y + \color{blue}{x} \]
                16. lower-fma.f6476.0%

                  \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, x\right)} \]
              3. Applied rewrites76.0%

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

                \[\leadsto \color{blue}{y \cdot \left(x + z\right)} \]
              5. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto y \cdot \color{blue}{\left(x + z\right)} \]
                2. lower-+.f6466.0%

                  \[\leadsto y \cdot \left(x + \color{blue}{z}\right) \]
              6. Applied rewrites66.0%

                \[\leadsto \color{blue}{y \cdot \left(x + z\right)} \]
              7. Taylor expanded in x around inf

                \[\leadsto x \cdot \color{blue}{y} \]
              8. Step-by-step derivation
                1. lower-*.f6428.2%

                  \[\leadsto x \cdot y \]
              9. Applied rewrites28.2%

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

              if -3.2e13 < x < 3.99999999999999976e-11

              1. Initial program 100.0%

                \[x + y \cdot \left(z + x\right) \]
              2. Taylor expanded in x around 0

                \[\leadsto \color{blue}{y \cdot z} \]
              3. Step-by-step derivation
                1. lower-*.f6442.7%

                  \[\leadsto y \cdot \color{blue}{z} \]
              4. Applied rewrites42.7%

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

            Alternative 5: 42.7% accurate, 2.4× speedup?

            \[y \cdot z \]
            (FPCore (x y z) :precision binary64 (* y z))
            double code(double x, double y, double z) {
            	return y * z;
            }
            
            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, z)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                code = y * z
            end function
            
            public static double code(double x, double y, double z) {
            	return y * z;
            }
            
            def code(x, y, z):
            	return y * z
            
            function code(x, y, z)
            	return Float64(y * z)
            end
            
            function tmp = code(x, y, z)
            	tmp = y * z;
            end
            
            code[x_, y_, z_] := N[(y * z), $MachinePrecision]
            
            y \cdot z
            
            Derivation
            1. Initial program 100.0%

              \[x + y \cdot \left(z + x\right) \]
            2. Taylor expanded in x around 0

              \[\leadsto \color{blue}{y \cdot z} \]
            3. Step-by-step derivation
              1. lower-*.f6442.7%

                \[\leadsto y \cdot \color{blue}{z} \]
            4. Applied rewrites42.7%

              \[\leadsto \color{blue}{y \cdot z} \]
            5. Add Preprocessing

            Reproduce

            ?
            herbie shell --seed 2025188 
            (FPCore (x y z)
              :name "Main:bigenough2 from A"
              :precision binary64
              (+ x (* y (+ z x))))