Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E

Percentage Accurate: 99.7% → 99.8%
Time: 7.2s
Alternatives: 9
Speedup: 1.0×

Specification

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

\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\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 9 alternatives:

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

Initial Program: 99.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

\\
x + \left(y - x\right) \cdot \left(6 \cdot z\right)
\end{array}
Derivation
  1. Initial program 99.8%

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

      \[\leadsto \mathsf{+.f64}\left(x, \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot z\right)}\right) \]
    2. associate-*l*N/A

      \[\leadsto \mathsf{+.f64}\left(x, \left(\left(y - x\right) \cdot \color{blue}{\left(6 \cdot z\right)}\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\left(y - x\right), \color{blue}{\left(6 \cdot z\right)}\right)\right) \]
    4. --lowering--.f64N/A

      \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{6} \cdot z\right)\right)\right) \]
    5. *-lowering-*.f6499.8%

      \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{*.f64}\left(6, \color{blue}{z}\right)\right)\right) \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 98.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.165:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;z \leq 0.00052:\\ \;\;\;\;x + y \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -0.165)
   (* (- y x) (* 6.0 z))
   (if (<= z 0.00052) (+ x (* y (* 6.0 z))) (* z (* (- y x) 6.0)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.165) {
		tmp = (y - x) * (6.0 * z);
	} else if (z <= 0.00052) {
		tmp = x + (y * (6.0 * z));
	} else {
		tmp = z * ((y - x) * 6.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) :: tmp
    if (z <= (-0.165d0)) then
        tmp = (y - x) * (6.0d0 * z)
    else if (z <= 0.00052d0) then
        tmp = x + (y * (6.0d0 * z))
    else
        tmp = z * ((y - x) * 6.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.165) {
		tmp = (y - x) * (6.0 * z);
	} else if (z <= 0.00052) {
		tmp = x + (y * (6.0 * z));
	} else {
		tmp = z * ((y - x) * 6.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -0.165:
		tmp = (y - x) * (6.0 * z)
	elif z <= 0.00052:
		tmp = x + (y * (6.0 * z))
	else:
		tmp = z * ((y - x) * 6.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -0.165)
		tmp = Float64(Float64(y - x) * Float64(6.0 * z));
	elseif (z <= 0.00052)
		tmp = Float64(x + Float64(y * Float64(6.0 * z)));
	else
		tmp = Float64(z * Float64(Float64(y - x) * 6.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -0.165)
		tmp = (y - x) * (6.0 * z);
	elseif (z <= 0.00052)
		tmp = x + (y * (6.0 * z));
	else
		tmp = z * ((y - x) * 6.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -0.165], N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.00052], N[(x + N[(y * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165:\\
\;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\

\mathbf{elif}\;z \leq 0.00052:\\
\;\;\;\;x + y \cdot \left(6 \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -0.165000000000000008

    1. Initial program 99.8%

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

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

        \[\leadsto \mathsf{*.f64}\left(6, \color{blue}{\left(z \cdot \left(y - x\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \color{blue}{\left(y - x\right)}\right)\right) \]
      3. --lowering--.f6497.8%

        \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \mathsf{\_.f64}\left(y, \color{blue}{x}\right)\right)\right) \]
    5. Simplified97.8%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(y - x\right), \color{blue}{\left(6 \cdot z\right)}\right) \]
      4. --lowering--.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(z \cdot \color{blue}{6}\right)\right) \]
      6. *-lowering-*.f6497.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{*.f64}\left(z, \color{blue}{6}\right)\right) \]
    7. Applied egg-rr97.9%

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

    if -0.165000000000000008 < z < 5.19999999999999954e-4

    1. Initial program 99.8%

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

        \[\leadsto \mathsf{+.f64}\left(x, \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot z\right)}\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{+.f64}\left(x, \left(\left(y - x\right) \cdot \color{blue}{\left(6 \cdot z\right)}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\left(y - x\right), \color{blue}{\left(6 \cdot z\right)}\right)\right) \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{6} \cdot z\right)\right)\right) \]
      5. *-lowering-*.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{*.f64}\left(6, \color{blue}{z}\right)\right)\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf

      \[\leadsto \mathsf{+.f64}\left(x, \mathsf{*.f64}\left(\color{blue}{y}, \mathsf{*.f64}\left(6, z\right)\right)\right) \]
    6. Step-by-step derivation
      1. Simplified98.7%

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

      if 5.19999999999999954e-4 < z

      1. Initial program 99.8%

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

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

          \[\leadsto \mathsf{*.f64}\left(6, \color{blue}{\left(z \cdot \left(y - x\right)\right)}\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \color{blue}{\left(y - x\right)}\right)\right) \]
        3. --lowering--.f6497.7%

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \mathsf{\_.f64}\left(y, \color{blue}{x}\right)\right)\right) \]
      5. Simplified97.7%

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\left(\left(y - x\right) \cdot 6\right), z\right) \]
        5. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(y - x\right), 6\right), z\right) \]
        6. --lowering--.f6497.9%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), 6\right), z\right) \]
      7. Applied egg-rr97.9%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot 6\right) \cdot z} \]
    7. Recombined 3 regimes into one program.
    8. Final simplification98.3%

      \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.165:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;z \leq 0.00052:\\ \;\;\;\;x + y \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \end{array} \]
    9. Add Preprocessing

    Alternative 3: 79.0% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{+20}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+28}:\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (if (<= y -3.7e+20)
       (* z (* (- y x) 6.0))
       (if (<= y 2.3e+28) (* x (+ 1.0 (* z -6.0))) (* (- y x) (* 6.0 z)))))
    double code(double x, double y, double z) {
    	double tmp;
    	if (y <= -3.7e+20) {
    		tmp = z * ((y - x) * 6.0);
    	} else if (y <= 2.3e+28) {
    		tmp = x * (1.0 + (z * -6.0));
    	} else {
    		tmp = (y - x) * (6.0 * 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 <= (-3.7d+20)) then
            tmp = z * ((y - x) * 6.0d0)
        else if (y <= 2.3d+28) then
            tmp = x * (1.0d0 + (z * (-6.0d0)))
        else
            tmp = (y - x) * (6.0d0 * z)
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double tmp;
    	if (y <= -3.7e+20) {
    		tmp = z * ((y - x) * 6.0);
    	} else if (y <= 2.3e+28) {
    		tmp = x * (1.0 + (z * -6.0));
    	} else {
    		tmp = (y - x) * (6.0 * z);
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	tmp = 0
    	if y <= -3.7e+20:
    		tmp = z * ((y - x) * 6.0)
    	elif y <= 2.3e+28:
    		tmp = x * (1.0 + (z * -6.0))
    	else:
    		tmp = (y - x) * (6.0 * z)
    	return tmp
    
    function code(x, y, z)
    	tmp = 0.0
    	if (y <= -3.7e+20)
    		tmp = Float64(z * Float64(Float64(y - x) * 6.0));
    	elseif (y <= 2.3e+28)
    		tmp = Float64(x * Float64(1.0 + Float64(z * -6.0)));
    	else
    		tmp = Float64(Float64(y - x) * Float64(6.0 * z));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	tmp = 0.0;
    	if (y <= -3.7e+20)
    		tmp = z * ((y - x) * 6.0);
    	elseif (y <= 2.3e+28)
    		tmp = x * (1.0 + (z * -6.0));
    	else
    		tmp = (y - x) * (6.0 * z);
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := If[LessEqual[y, -3.7e+20], N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3e+28], N[(x * N[(1.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;y \leq -3.7 \cdot 10^{+20}:\\
    \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\
    
    \mathbf{elif}\;y \leq 2.3 \cdot 10^{+28}:\\
    \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if y < -3.7e20

      1. Initial program 100.0%

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

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

          \[\leadsto \mathsf{*.f64}\left(6, \color{blue}{\left(z \cdot \left(y - x\right)\right)}\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \color{blue}{\left(y - x\right)}\right)\right) \]
        3. --lowering--.f6481.2%

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \mathsf{\_.f64}\left(y, \color{blue}{x}\right)\right)\right) \]
      5. Simplified81.2%

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\left(\left(y - x\right) \cdot 6\right), z\right) \]
        5. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(y - x\right), 6\right), z\right) \]
        6. --lowering--.f6481.5%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), 6\right), z\right) \]
      7. Applied egg-rr81.5%

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

      if -3.7e20 < y < 2.29999999999999984e28

      1. Initial program 99.8%

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

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

          \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(1 + -6 \cdot z\right)}\right) \]
        2. +-lowering-+.f64N/A

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

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(1, \left(z \cdot \color{blue}{-6}\right)\right)\right) \]
        4. *-lowering-*.f6484.0%

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(z, \color{blue}{-6}\right)\right)\right) \]
      5. Simplified84.0%

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

      if 2.29999999999999984e28 < y

      1. Initial program 99.8%

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

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

          \[\leadsto \mathsf{*.f64}\left(6, \color{blue}{\left(z \cdot \left(y - x\right)\right)}\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \color{blue}{\left(y - x\right)}\right)\right) \]
        3. --lowering--.f6479.8%

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \mathsf{\_.f64}\left(y, \color{blue}{x}\right)\right)\right) \]
      5. Simplified79.8%

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\left(y - x\right), \color{blue}{\left(6 \cdot z\right)}\right) \]
        4. --lowering--.f64N/A

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(z \cdot \color{blue}{6}\right)\right) \]
        6. *-lowering-*.f6479.9%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{*.f64}\left(z, \color{blue}{6}\right)\right) \]
      7. Applied egg-rr79.9%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(z \cdot 6\right)} \]
    3. Recombined 3 regimes into one program.
    4. Final simplification82.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{+20}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+28}:\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 4: 79.0% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \mathbf{if}\;y \leq -9.8 \cdot 10^{+19}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{+28}:\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (* z (* (- y x) 6.0))))
       (if (<= y -9.8e+19) t_0 (if (<= y 9.6e+28) (* x (+ 1.0 (* z -6.0))) t_0))))
    double code(double x, double y, double z) {
    	double t_0 = z * ((y - x) * 6.0);
    	double tmp;
    	if (y <= -9.8e+19) {
    		tmp = t_0;
    	} else if (y <= 9.6e+28) {
    		tmp = x * (1.0 + (z * -6.0));
    	} else {
    		tmp = t_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 = z * ((y - x) * 6.0d0)
        if (y <= (-9.8d+19)) then
            tmp = t_0
        else if (y <= 9.6d+28) then
            tmp = x * (1.0d0 + (z * (-6.0d0)))
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double t_0 = z * ((y - x) * 6.0);
    	double tmp;
    	if (y <= -9.8e+19) {
    		tmp = t_0;
    	} else if (y <= 9.6e+28) {
    		tmp = x * (1.0 + (z * -6.0));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = z * ((y - x) * 6.0)
    	tmp = 0
    	if y <= -9.8e+19:
    		tmp = t_0
    	elif y <= 9.6e+28:
    		tmp = x * (1.0 + (z * -6.0))
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(z * Float64(Float64(y - x) * 6.0))
    	tmp = 0.0
    	if (y <= -9.8e+19)
    		tmp = t_0;
    	elseif (y <= 9.6e+28)
    		tmp = Float64(x * Float64(1.0 + Float64(z * -6.0)));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = z * ((y - x) * 6.0);
    	tmp = 0.0;
    	if (y <= -9.8e+19)
    		tmp = t_0;
    	elseif (y <= 9.6e+28)
    		tmp = x * (1.0 + (z * -6.0));
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.8e+19], t$95$0, If[LessEqual[y, 9.6e+28], N[(x * N[(1.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := z \cdot \left(\left(y - x\right) \cdot 6\right)\\
    \mathbf{if}\;y \leq -9.8 \cdot 10^{+19}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y \leq 9.6 \cdot 10^{+28}:\\
    \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -9.8e19 or 9.59999999999999925e28 < y

      1. Initial program 99.8%

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

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

          \[\leadsto \mathsf{*.f64}\left(6, \color{blue}{\left(z \cdot \left(y - x\right)\right)}\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \color{blue}{\left(y - x\right)}\right)\right) \]
        3. --lowering--.f6480.4%

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \mathsf{\_.f64}\left(y, \color{blue}{x}\right)\right)\right) \]
      5. Simplified80.4%

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\left(\left(y - x\right) \cdot 6\right), z\right) \]
        5. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(y - x\right), 6\right), z\right) \]
        6. --lowering--.f6480.5%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(y, x\right), 6\right), z\right) \]
      7. Applied egg-rr80.5%

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

      if -9.8e19 < y < 9.59999999999999925e28

      1. Initial program 99.8%

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

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

          \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(1 + -6 \cdot z\right)}\right) \]
        2. +-lowering-+.f64N/A

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

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(1, \left(z \cdot \color{blue}{-6}\right)\right)\right) \]
        4. *-lowering-*.f6484.0%

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(z, \color{blue}{-6}\right)\right)\right) \]
      5. Simplified84.0%

        \[\leadsto \color{blue}{x \cdot \left(1 + z \cdot -6\right)} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification82.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.8 \cdot 10^{+19}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{+28}:\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 5: 79.0% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{if}\;y \leq -1.05 \cdot 10^{+20}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+28}:\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (* 6.0 (* (- y x) z))))
       (if (<= y -1.05e+20) t_0 (if (<= y 1.3e+28) (* x (+ 1.0 (* z -6.0))) t_0))))
    double code(double x, double y, double z) {
    	double t_0 = 6.0 * ((y - x) * z);
    	double tmp;
    	if (y <= -1.05e+20) {
    		tmp = t_0;
    	} else if (y <= 1.3e+28) {
    		tmp = x * (1.0 + (z * -6.0));
    	} else {
    		tmp = t_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 = 6.0d0 * ((y - x) * z)
        if (y <= (-1.05d+20)) then
            tmp = t_0
        else if (y <= 1.3d+28) then
            tmp = x * (1.0d0 + (z * (-6.0d0)))
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double t_0 = 6.0 * ((y - x) * z);
    	double tmp;
    	if (y <= -1.05e+20) {
    		tmp = t_0;
    	} else if (y <= 1.3e+28) {
    		tmp = x * (1.0 + (z * -6.0));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = 6.0 * ((y - x) * z)
    	tmp = 0
    	if y <= -1.05e+20:
    		tmp = t_0
    	elif y <= 1.3e+28:
    		tmp = x * (1.0 + (z * -6.0))
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(6.0 * Float64(Float64(y - x) * z))
    	tmp = 0.0
    	if (y <= -1.05e+20)
    		tmp = t_0;
    	elseif (y <= 1.3e+28)
    		tmp = Float64(x * Float64(1.0 + Float64(z * -6.0)));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = 6.0 * ((y - x) * z);
    	tmp = 0.0;
    	if (y <= -1.05e+20)
    		tmp = t_0;
    	elseif (y <= 1.3e+28)
    		tmp = x * (1.0 + (z * -6.0));
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.05e+20], t$95$0, If[LessEqual[y, 1.3e+28], N[(x * N[(1.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := 6 \cdot \left(\left(y - x\right) \cdot z\right)\\
    \mathbf{if}\;y \leq -1.05 \cdot 10^{+20}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y \leq 1.3 \cdot 10^{+28}:\\
    \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -1.05e20 or 1.3000000000000001e28 < y

      1. Initial program 99.8%

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

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

          \[\leadsto \mathsf{*.f64}\left(6, \color{blue}{\left(z \cdot \left(y - x\right)\right)}\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \color{blue}{\left(y - x\right)}\right)\right) \]
        3. --lowering--.f6480.4%

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \mathsf{\_.f64}\left(y, \color{blue}{x}\right)\right)\right) \]
      5. Simplified80.4%

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

      if -1.05e20 < y < 1.3000000000000001e28

      1. Initial program 99.8%

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

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

          \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(1 + -6 \cdot z\right)}\right) \]
        2. +-lowering-+.f64N/A

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

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(1, \left(z \cdot \color{blue}{-6}\right)\right)\right) \]
        4. *-lowering-*.f6484.0%

          \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(z, \color{blue}{-6}\right)\right)\right) \]
      5. Simplified84.0%

        \[\leadsto \color{blue}{x \cdot \left(1 + z \cdot -6\right)} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification82.4%

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+20}:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+28}:\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 6: 84.7% accurate, 0.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{-13}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-28}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (* 6.0 (* (- y x) z))))
       (if (<= z -3.8e-13) t_0 (if (<= z 7e-28) x t_0))))
    double code(double x, double y, double z) {
    	double t_0 = 6.0 * ((y - x) * z);
    	double tmp;
    	if (z <= -3.8e-13) {
    		tmp = t_0;
    	} else if (z <= 7e-28) {
    		tmp = x;
    	} else {
    		tmp = t_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 = 6.0d0 * ((y - x) * z)
        if (z <= (-3.8d-13)) then
            tmp = t_0
        else if (z <= 7d-28) then
            tmp = x
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double t_0 = 6.0 * ((y - x) * z);
    	double tmp;
    	if (z <= -3.8e-13) {
    		tmp = t_0;
    	} else if (z <= 7e-28) {
    		tmp = x;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = 6.0 * ((y - x) * z)
    	tmp = 0
    	if z <= -3.8e-13:
    		tmp = t_0
    	elif z <= 7e-28:
    		tmp = x
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(6.0 * Float64(Float64(y - x) * z))
    	tmp = 0.0
    	if (z <= -3.8e-13)
    		tmp = t_0;
    	elseif (z <= 7e-28)
    		tmp = x;
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = 6.0 * ((y - x) * z);
    	tmp = 0.0;
    	if (z <= -3.8e-13)
    		tmp = t_0;
    	elseif (z <= 7e-28)
    		tmp = x;
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.8e-13], t$95$0, If[LessEqual[z, 7e-28], x, t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := 6 \cdot \left(\left(y - x\right) \cdot z\right)\\
    \mathbf{if}\;z \leq -3.8 \cdot 10^{-13}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;z \leq 7 \cdot 10^{-28}:\\
    \;\;\;\;x\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < -3.8e-13 or 6.9999999999999999e-28 < z

      1. Initial program 99.8%

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

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

          \[\leadsto \mathsf{*.f64}\left(6, \color{blue}{\left(z \cdot \left(y - x\right)\right)}\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \color{blue}{\left(y - x\right)}\right)\right) \]
        3. --lowering--.f6495.1%

          \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \mathsf{\_.f64}\left(y, \color{blue}{x}\right)\right)\right) \]
      5. Simplified95.1%

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

      if -3.8e-13 < z < 6.9999999999999999e-28

      1. Initial program 99.9%

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{-13}:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-28}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]
      7. Add Preprocessing

      Alternative 7: 60.8% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(z \cdot -6\right)\\ \mathbf{if}\;z \leq -0.165:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 0.17:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* x (* z -6.0)))) (if (<= z -0.165) t_0 (if (<= z 0.17) x t_0))))
      double code(double x, double y, double z) {
      	double t_0 = x * (z * -6.0);
      	double tmp;
      	if (z <= -0.165) {
      		tmp = t_0;
      	} else if (z <= 0.17) {
      		tmp = x;
      	} else {
      		tmp = t_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 = x * (z * (-6.0d0))
          if (z <= (-0.165d0)) then
              tmp = t_0
          else if (z <= 0.17d0) then
              tmp = x
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double t_0 = x * (z * -6.0);
      	double tmp;
      	if (z <= -0.165) {
      		tmp = t_0;
      	} else if (z <= 0.17) {
      		tmp = x;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = x * (z * -6.0)
      	tmp = 0
      	if z <= -0.165:
      		tmp = t_0
      	elif z <= 0.17:
      		tmp = x
      	else:
      		tmp = t_0
      	return tmp
      
      function code(x, y, z)
      	t_0 = Float64(x * Float64(z * -6.0))
      	tmp = 0.0
      	if (z <= -0.165)
      		tmp = t_0;
      	elseif (z <= 0.17)
      		tmp = x;
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	t_0 = x * (z * -6.0);
      	tmp = 0.0;
      	if (z <= -0.165)
      		tmp = t_0;
      	elseif (z <= 0.17)
      		tmp = x;
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.165], t$95$0, If[LessEqual[z, 0.17], x, t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := x \cdot \left(z \cdot -6\right)\\
      \mathbf{if}\;z \leq -0.165:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;z \leq 0.17:\\
      \;\;\;\;x\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if z < -0.165000000000000008 or 0.170000000000000012 < z

        1. Initial program 99.8%

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

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

            \[\leadsto \mathsf{*.f64}\left(6, \color{blue}{\left(z \cdot \left(y - x\right)\right)}\right) \]
          2. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \color{blue}{\left(y - x\right)}\right)\right) \]
          3. --lowering--.f6497.7%

            \[\leadsto \mathsf{*.f64}\left(6, \mathsf{*.f64}\left(z, \mathsf{\_.f64}\left(y, \color{blue}{x}\right)\right)\right) \]
        5. Simplified97.7%

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

          \[\leadsto \color{blue}{-6 \cdot \left(x \cdot z\right)} \]
        7. Step-by-step derivation
          1. *-commutativeN/A

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

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

            \[\leadsto x \cdot \left(-6 \cdot \color{blue}{z}\right) \]
          4. *-lowering-*.f64N/A

            \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(-6 \cdot z\right)}\right) \]
          5. *-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(x, \left(z \cdot \color{blue}{-6}\right)\right) \]
          6. *-lowering-*.f6458.0%

            \[\leadsto \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(z, \color{blue}{-6}\right)\right) \]
        8. Simplified58.0%

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

        if -0.165000000000000008 < z < 0.170000000000000012

        1. Initial program 99.9%

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

          \[\leadsto \color{blue}{x} \]
        4. Step-by-step derivation
          1. Simplified62.2%

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

        Alternative 8: 99.7% accurate, 1.0× speedup?

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

          \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
        2. Add Preprocessing
        3. Final simplification99.8%

          \[\leadsto x + z \cdot \left(\left(y - x\right) \cdot 6\right) \]
        4. Add Preprocessing

        Alternative 9: 37.0% accurate, 9.0× speedup?

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

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

          \[\leadsto \color{blue}{x} \]
        4. Step-by-step derivation
          1. Simplified32.2%

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

          Developer Target 1: 99.8% accurate, 1.0× speedup?

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

          Reproduce

          ?
          herbie shell --seed 2024145 
          (FPCore (x y z)
            :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
            :precision binary64
          
            :alt
            (! :herbie-platform default (- x (* (* 6 z) (- x y))))
          
            (+ x (* (* (- y x) 6.0) z)))