Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I

Percentage Accurate: 96.0% → 97.8%
Time: 7.6s
Alternatives: 6
Speedup: 0.6×

Specification

?
\[\begin{array}{l} \\ x \cdot \left(1 - y \cdot z\right) \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
def code(x, y, z):
	return x * (1.0 - (y * z))
function code(x, y, z)
	return Float64(x * Float64(1.0 - Float64(y * z)))
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - (y * z));
end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(1 - y \cdot z\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 6 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: 96.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x \cdot \left(1 - y \cdot z\right) \end{array} \]
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
	return x * (1.0 - (y * z));
}
def code(x, y, z):
	return x * (1.0 - (y * z))
function code(x, y, z)
	return Float64(x * Float64(1.0 - Float64(y * z)))
end
function tmp = code(x, y, z)
	tmp = x * (1.0 - (y * z));
end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 97.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+191}:\\ \;\;\;\;\left(\left(-x\right) \cdot y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(-z, y, 1\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (* y z) -1e+191) (* (* (- x) y) z) (* x (fma (- z) y 1.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((y * z) <= -1e+191) {
		tmp = (-x * y) * z;
	} else {
		tmp = x * fma(-z, y, 1.0);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (Float64(y * z) <= -1e+191)
		tmp = Float64(Float64(Float64(-x) * y) * z);
	else
		tmp = Float64(x * fma(Float64(-z), y, 1.0));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -1e+191], N[(N[((-x) * y), $MachinePrecision] * z), $MachinePrecision], N[(x * N[((-z) * y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+191}:\\
\;\;\;\;\left(\left(-x\right) \cdot y\right) \cdot z\\

\mathbf{else}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(-z, y, 1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y z) < -1.00000000000000007e191

    1. Initial program 83.7%

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

      \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

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

        \[\leadsto x \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot z\right)} \]
      3. mul-1-negN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot z\right) \]
      4. lower-neg.f6483.7

        \[\leadsto x \cdot \left(\color{blue}{\left(-y\right)} \cdot z\right) \]
    5. Applied rewrites83.7%

      \[\leadsto x \cdot \color{blue}{\left(\left(-y\right) \cdot z\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites65.1%

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

        \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(y \cdot z\right)\right)} \]
      3. Step-by-step derivation
        1. associate-*r*N/A

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

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

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

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

          \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot y\right)} \cdot z \]
        6. mul-1-negN/A

          \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot y\right) \cdot z \]
        7. lower-neg.f6499.8

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

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

      if -1.00000000000000007e191 < (*.f64 y z)

      1. Initial program 98.5%

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

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

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

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

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

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

          \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right) \cdot y} + 1\right) \]
        7. lower-fma.f64N/A

          \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z\right), y, 1\right)} \]
        8. lower-neg.f6498.6

          \[\leadsto x \cdot \mathsf{fma}\left(\color{blue}{-z}, y, 1\right) \]
      4. Applied rewrites98.6%

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(-z, y, 1\right)} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 2: 94.4% accurate, 0.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - y \cdot z\\ \mathbf{if}\;t\_0 \leq -0.02 \lor \neg \left(t\_0 \leq 2\right):\\ \;\;\;\;\left(\left(-x\right) \cdot z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (- 1.0 (* y z))))
       (if (or (<= t_0 -0.02) (not (<= t_0 2.0))) (* (* (- x) z) y) (* x 1.0))))
    double code(double x, double y, double z) {
    	double t_0 = 1.0 - (y * z);
    	double tmp;
    	if ((t_0 <= -0.02) || !(t_0 <= 2.0)) {
    		tmp = (-x * z) * y;
    	} else {
    		tmp = x * 1.0;
    	}
    	return tmp;
    }
    
    real(8) function code(x, y, z)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z
        real(8) :: t_0
        real(8) :: tmp
        t_0 = 1.0d0 - (y * z)
        if ((t_0 <= (-0.02d0)) .or. (.not. (t_0 <= 2.0d0))) then
            tmp = (-x * z) * y
        else
            tmp = x * 1.0d0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double t_0 = 1.0 - (y * z);
    	double tmp;
    	if ((t_0 <= -0.02) || !(t_0 <= 2.0)) {
    		tmp = (-x * z) * y;
    	} else {
    		tmp = x * 1.0;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = 1.0 - (y * z)
    	tmp = 0
    	if (t_0 <= -0.02) or not (t_0 <= 2.0):
    		tmp = (-x * z) * y
    	else:
    		tmp = x * 1.0
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(1.0 - Float64(y * z))
    	tmp = 0.0
    	if ((t_0 <= -0.02) || !(t_0 <= 2.0))
    		tmp = Float64(Float64(Float64(-x) * z) * y);
    	else
    		tmp = Float64(x * 1.0);
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = 1.0 - (y * z);
    	tmp = 0.0;
    	if ((t_0 <= -0.02) || ~((t_0 <= 2.0)))
    		tmp = (-x * z) * y;
    	else
    		tmp = x * 1.0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.02], N[Not[LessEqual[t$95$0, 2.0]], $MachinePrecision]], N[(N[((-x) * z), $MachinePrecision] * y), $MachinePrecision], N[(x * 1.0), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := 1 - y \cdot z\\
    \mathbf{if}\;t\_0 \leq -0.02 \lor \neg \left(t\_0 \leq 2\right):\\
    \;\;\;\;\left(\left(-x\right) \cdot z\right) \cdot y\\
    
    \mathbf{else}:\\
    \;\;\;\;x \cdot 1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (-.f64 #s(literal 1 binary64) (*.f64 y z)) < -0.0200000000000000004 or 2 < (-.f64 #s(literal 1 binary64) (*.f64 y z))

      1. Initial program 92.5%

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

        \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \left(y \cdot z\right)\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

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

          \[\leadsto x \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot z\right)} \]
        3. mul-1-negN/A

          \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot z\right) \]
        4. lower-neg.f6488.9

          \[\leadsto x \cdot \left(\color{blue}{\left(-y\right)} \cdot z\right) \]
      5. Applied rewrites88.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(-y\right) \cdot z\right)} \]
      6. Step-by-step derivation
        1. Applied rewrites59.6%

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

          \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(y \cdot z\right)\right)} \]
        3. Step-by-step derivation
          1. associate-*r*N/A

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

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

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

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

            \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot y\right)} \cdot z \]
          6. mul-1-negN/A

            \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot y\right) \cdot z \]
          7. lower-neg.f6488.6

            \[\leadsto \left(\color{blue}{\left(-x\right)} \cdot y\right) \cdot z \]
        4. Applied rewrites88.6%

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

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

          if -0.0200000000000000004 < (-.f64 #s(literal 1 binary64) (*.f64 y z)) < 2

          1. Initial program 100.0%

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

            \[\leadsto x \cdot \color{blue}{1} \]
          4. Step-by-step derivation
            1. Applied rewrites97.0%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;1 - y \cdot z \leq -0.02 \lor \neg \left(1 - y \cdot z \leq 2\right):\\ \;\;\;\;\left(\left(-x\right) \cdot z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1\\ \end{array} \]
          7. Add Preprocessing

          Alternative 3: 94.2% accurate, 0.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - y \cdot z\\ \mathbf{if}\;t\_0 \leq -0.02 \lor \neg \left(t\_0 \leq 2\right):\\ \;\;\;\;\left(\left(-x\right) \cdot y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (let* ((t_0 (- 1.0 (* y z))))
             (if (or (<= t_0 -0.02) (not (<= t_0 2.0))) (* (* (- x) y) z) (* x 1.0))))
          double code(double x, double y, double z) {
          	double t_0 = 1.0 - (y * z);
          	double tmp;
          	if ((t_0 <= -0.02) || !(t_0 <= 2.0)) {
          		tmp = (-x * y) * z;
          	} else {
          		tmp = x * 1.0;
          	}
          	return tmp;
          }
          
          real(8) function code(x, y, z)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8) :: t_0
              real(8) :: tmp
              t_0 = 1.0d0 - (y * z)
              if ((t_0 <= (-0.02d0)) .or. (.not. (t_0 <= 2.0d0))) then
                  tmp = (-x * y) * z
              else
                  tmp = x * 1.0d0
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double t_0 = 1.0 - (y * z);
          	double tmp;
          	if ((t_0 <= -0.02) || !(t_0 <= 2.0)) {
          		tmp = (-x * y) * z;
          	} else {
          		tmp = x * 1.0;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	t_0 = 1.0 - (y * z)
          	tmp = 0
          	if (t_0 <= -0.02) or not (t_0 <= 2.0):
          		tmp = (-x * y) * z
          	else:
          		tmp = x * 1.0
          	return tmp
          
          function code(x, y, z)
          	t_0 = Float64(1.0 - Float64(y * z))
          	tmp = 0.0
          	if ((t_0 <= -0.02) || !(t_0 <= 2.0))
          		tmp = Float64(Float64(Float64(-x) * y) * z);
          	else
          		tmp = Float64(x * 1.0);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	t_0 = 1.0 - (y * z);
          	tmp = 0.0;
          	if ((t_0 <= -0.02) || ~((t_0 <= 2.0)))
          		tmp = (-x * y) * z;
          	else
          		tmp = x * 1.0;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.02], N[Not[LessEqual[t$95$0, 2.0]], $MachinePrecision]], N[(N[((-x) * y), $MachinePrecision] * z), $MachinePrecision], N[(x * 1.0), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := 1 - y \cdot z\\
          \mathbf{if}\;t\_0 \leq -0.02 \lor \neg \left(t\_0 \leq 2\right):\\
          \;\;\;\;\left(\left(-x\right) \cdot y\right) \cdot z\\
          
          \mathbf{else}:\\
          \;\;\;\;x \cdot 1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (-.f64 #s(literal 1 binary64) (*.f64 y z)) < -0.0200000000000000004 or 2 < (-.f64 #s(literal 1 binary64) (*.f64 y z))

            1. Initial program 92.5%

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

              \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \left(y \cdot z\right)\right)} \]
            4. Step-by-step derivation
              1. associate-*r*N/A

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

                \[\leadsto x \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot z\right)} \]
              3. mul-1-negN/A

                \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot z\right) \]
              4. lower-neg.f6488.9

                \[\leadsto x \cdot \left(\color{blue}{\left(-y\right)} \cdot z\right) \]
            5. Applied rewrites88.9%

              \[\leadsto x \cdot \color{blue}{\left(\left(-y\right) \cdot z\right)} \]
            6. Step-by-step derivation
              1. Applied rewrites59.6%

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

                \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(y \cdot z\right)\right)} \]
              3. Step-by-step derivation
                1. associate-*r*N/A

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

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

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

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

                  \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot y\right)} \cdot z \]
                6. mul-1-negN/A

                  \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot y\right) \cdot z \]
                7. lower-neg.f6488.6

                  \[\leadsto \left(\color{blue}{\left(-x\right)} \cdot y\right) \cdot z \]
              4. Applied rewrites88.6%

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

              if -0.0200000000000000004 < (-.f64 #s(literal 1 binary64) (*.f64 y z)) < 2

              1. Initial program 100.0%

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

                \[\leadsto x \cdot \color{blue}{1} \]
              4. Step-by-step derivation
                1. Applied rewrites97.0%

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;1 - y \cdot z \leq -0.02 \lor \neg \left(1 - y \cdot z \leq 2\right):\\ \;\;\;\;\left(\left(-x\right) \cdot y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1\\ \end{array} \]
              7. Add Preprocessing

              Alternative 4: 93.7% accurate, 0.4× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot z \leq -400000:\\ \;\;\;\;\left(\left(-x\right) \cdot z\right) \cdot y\\ \mathbf{elif}\;y \cdot z \leq 0.04:\\ \;\;\;\;x \cdot 1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\left(-y\right) \cdot z\right)\\ \end{array} \end{array} \]
              (FPCore (x y z)
               :precision binary64
               (if (<= (* y z) -400000.0)
                 (* (* (- x) z) y)
                 (if (<= (* y z) 0.04) (* x 1.0) (* x (* (- y) z)))))
              double code(double x, double y, double z) {
              	double tmp;
              	if ((y * z) <= -400000.0) {
              		tmp = (-x * z) * y;
              	} else if ((y * z) <= 0.04) {
              		tmp = x * 1.0;
              	} else {
              		tmp = x * (-y * z);
              	}
              	return tmp;
              }
              
              real(8) function code(x, y, z)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8), intent (in) :: z
                  real(8) :: tmp
                  if ((y * z) <= (-400000.0d0)) then
                      tmp = (-x * z) * y
                  else if ((y * z) <= 0.04d0) then
                      tmp = x * 1.0d0
                  else
                      tmp = x * (-y * z)
                  end if
                  code = tmp
              end function
              
              public static double code(double x, double y, double z) {
              	double tmp;
              	if ((y * z) <= -400000.0) {
              		tmp = (-x * z) * y;
              	} else if ((y * z) <= 0.04) {
              		tmp = x * 1.0;
              	} else {
              		tmp = x * (-y * z);
              	}
              	return tmp;
              }
              
              def code(x, y, z):
              	tmp = 0
              	if (y * z) <= -400000.0:
              		tmp = (-x * z) * y
              	elif (y * z) <= 0.04:
              		tmp = x * 1.0
              	else:
              		tmp = x * (-y * z)
              	return tmp
              
              function code(x, y, z)
              	tmp = 0.0
              	if (Float64(y * z) <= -400000.0)
              		tmp = Float64(Float64(Float64(-x) * z) * y);
              	elseif (Float64(y * z) <= 0.04)
              		tmp = Float64(x * 1.0);
              	else
              		tmp = Float64(x * Float64(Float64(-y) * z));
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y, z)
              	tmp = 0.0;
              	if ((y * z) <= -400000.0)
              		tmp = (-x * z) * y;
              	elseif ((y * z) <= 0.04)
              		tmp = x * 1.0;
              	else
              		tmp = x * (-y * z);
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -400000.0], N[(N[((-x) * z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 0.04], N[(x * 1.0), $MachinePrecision], N[(x * N[((-y) * z), $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;y \cdot z \leq -400000:\\
              \;\;\;\;\left(\left(-x\right) \cdot z\right) \cdot y\\
              
              \mathbf{elif}\;y \cdot z \leq 0.04:\\
              \;\;\;\;x \cdot 1\\
              
              \mathbf{else}:\\
              \;\;\;\;x \cdot \left(\left(-y\right) \cdot z\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if (*.f64 y z) < -4e5

                1. Initial program 90.6%

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

                  \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \left(y \cdot z\right)\right)} \]
                4. Step-by-step derivation
                  1. associate-*r*N/A

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

                    \[\leadsto x \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot z\right)} \]
                  3. mul-1-negN/A

                    \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot z\right) \]
                  4. lower-neg.f6488.0

                    \[\leadsto x \cdot \left(\color{blue}{\left(-y\right)} \cdot z\right) \]
                5. Applied rewrites88.0%

                  \[\leadsto x \cdot \color{blue}{\left(\left(-y\right) \cdot z\right)} \]
                6. Step-by-step derivation
                  1. Applied rewrites64.1%

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

                    \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(y \cdot z\right)\right)} \]
                  3. Step-by-step derivation
                    1. associate-*r*N/A

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

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

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

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

                      \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot y\right)} \cdot z \]
                    6. mul-1-negN/A

                      \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot y\right) \cdot z \]
                    7. lower-neg.f6490.2

                      \[\leadsto \left(\color{blue}{\left(-x\right)} \cdot y\right) \cdot z \]
                  4. Applied rewrites90.2%

                    \[\leadsto \color{blue}{\left(\left(-x\right) \cdot y\right) \cdot z} \]
                  5. Step-by-step derivation
                    1. Applied rewrites89.9%

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

                    if -4e5 < (*.f64 y z) < 0.0400000000000000008

                    1. Initial program 100.0%

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

                      \[\leadsto x \cdot \color{blue}{1} \]
                    4. Step-by-step derivation
                      1. Applied rewrites97.0%

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

                      if 0.0400000000000000008 < (*.f64 y z)

                      1. Initial program 94.8%

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

                        \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \left(y \cdot z\right)\right)} \]
                      4. Step-by-step derivation
                        1. associate-*r*N/A

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

                          \[\leadsto x \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot z\right)} \]
                        3. mul-1-negN/A

                          \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot z\right) \]
                        4. lower-neg.f6490.1

                          \[\leadsto x \cdot \left(\color{blue}{\left(-y\right)} \cdot z\right) \]
                      5. Applied rewrites90.1%

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

                    Alternative 5: 97.8% accurate, 0.6× speedup?

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

                      1. Initial program 83.7%

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

                        \[\leadsto x \cdot \color{blue}{\left(-1 \cdot \left(y \cdot z\right)\right)} \]
                      4. Step-by-step derivation
                        1. associate-*r*N/A

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

                          \[\leadsto x \cdot \color{blue}{\left(\left(-1 \cdot y\right) \cdot z\right)} \]
                        3. mul-1-negN/A

                          \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)} \cdot z\right) \]
                        4. lower-neg.f6483.7

                          \[\leadsto x \cdot \left(\color{blue}{\left(-y\right)} \cdot z\right) \]
                      5. Applied rewrites83.7%

                        \[\leadsto x \cdot \color{blue}{\left(\left(-y\right) \cdot z\right)} \]
                      6. Step-by-step derivation
                        1. Applied rewrites65.1%

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

                          \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \left(y \cdot z\right)\right)} \]
                        3. Step-by-step derivation
                          1. associate-*r*N/A

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

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

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

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

                            \[\leadsto \color{blue}{\left(\left(-1 \cdot x\right) \cdot y\right)} \cdot z \]
                          6. mul-1-negN/A

                            \[\leadsto \left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot y\right) \cdot z \]
                          7. lower-neg.f6499.8

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

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

                        if -1.00000000000000007e191 < (*.f64 y z)

                        1. Initial program 98.5%

                          \[x \cdot \left(1 - y \cdot z\right) \]
                        2. Add Preprocessing
                      7. Recombined 2 regimes into one program.
                      8. Add Preprocessing

                      Alternative 6: 50.8% accurate, 2.3× speedup?

                      \[\begin{array}{l} \\ x \cdot 1 \end{array} \]
                      (FPCore (x y z) :precision binary64 (* x 1.0))
                      double code(double x, double y, double z) {
                      	return x * 1.0;
                      }
                      
                      real(8) function code(x, y, z)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          real(8), intent (in) :: z
                          code = x * 1.0d0
                      end function
                      
                      public static double code(double x, double y, double z) {
                      	return x * 1.0;
                      }
                      
                      def code(x, y, z):
                      	return x * 1.0
                      
                      function code(x, y, z)
                      	return Float64(x * 1.0)
                      end
                      
                      function tmp = code(x, y, z)
                      	tmp = x * 1.0;
                      end
                      
                      code[x_, y_, z_] := N[(x * 1.0), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      x \cdot 1
                      \end{array}
                      
                      Derivation
                      1. Initial program 96.2%

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

                        \[\leadsto x \cdot \color{blue}{1} \]
                      4. Step-by-step derivation
                        1. Applied rewrites49.7%

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

                        Reproduce

                        ?
                        herbie shell --seed 2024324 
                        (FPCore (x y z)
                          :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
                          :precision binary64
                          (* x (- 1.0 (* y z))))