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

Percentage Accurate: 99.7% → 99.7%
Time: 11.3s
Alternatives: 8
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 8 alternatives:

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

Initial Program: 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.7% accurate, 0.8× speedup?

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

\\
x + \left(x \cdot -6 + 6 \cdot y\right) \cdot z
\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 y around 0 99.8%

    \[\leadsto x + \color{blue}{\left(-6 \cdot x + 6 \cdot y\right)} \cdot z \]
  4. Final simplification99.8%

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

Alternative 2: 85.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+22} \lor \neg \left(x \leq 3 \cdot 10^{-73}\right):\\ \;\;\;\;x + x \cdot \left(-6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -1.55e+22) (not (<= x 3e-73)))
   (+ x (* x (* -6.0 z)))
   (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.55e+22) || !(x <= 3e-73)) {
		tmp = x + (x * (-6.0 * z));
	} else {
		tmp = x + (6.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 ((x <= (-1.55d+22)) .or. (.not. (x <= 3d-73))) then
        tmp = x + (x * ((-6.0d0) * z))
    else
        tmp = x + (6.0d0 * (y * z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.55e+22) || !(x <= 3e-73)) {
		tmp = x + (x * (-6.0 * z));
	} else {
		tmp = x + (6.0 * (y * z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -1.55e+22) or not (x <= 3e-73):
		tmp = x + (x * (-6.0 * z))
	else:
		tmp = x + (6.0 * (y * z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -1.55e+22) || !(x <= 3e-73))
		tmp = Float64(x + Float64(x * Float64(-6.0 * z)));
	else
		tmp = Float64(x + Float64(6.0 * Float64(y * z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -1.55e+22) || ~((x <= 3e-73)))
		tmp = x + (x * (-6.0 * z));
	else
		tmp = x + (6.0 * (y * z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.55e+22], N[Not[LessEqual[x, 3e-73]], $MachinePrecision]], N[(x + N[(x * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{+22} \lor \neg \left(x \leq 3 \cdot 10^{-73}\right):\\
\;\;\;\;x + x \cdot \left(-6 \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.5500000000000001e22 or 3e-73 < x

    1. Initial program 99.9%

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

      \[\leadsto x + \color{blue}{-6 \cdot \left(x \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutative84.0%

        \[\leadsto x + \color{blue}{\left(x \cdot z\right) \cdot -6} \]
      2. associate-*r*84.0%

        \[\leadsto x + \color{blue}{x \cdot \left(z \cdot -6\right)} \]
      3. *-commutative84.0%

        \[\leadsto x + x \cdot \color{blue}{\left(-6 \cdot z\right)} \]
    5. Simplified84.0%

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

    if -1.5500000000000001e22 < x < 3e-73

    1. Initial program 99.7%

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

      \[\leadsto x + \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutative93.7%

        \[\leadsto x + 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    5. Simplified93.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+22} \lor \neg \left(x \leq 3 \cdot 10^{-73}\right):\\ \;\;\;\;x + x \cdot \left(-6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.3 \cdot 10^{+22} \lor \neg \left(x \leq 3 \cdot 10^{-73}\right):\\ \;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -3.3e+22) (not (<= x 3e-73)))
   (+ x (* -6.0 (* x z)))
   (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -3.3e+22) || !(x <= 3e-73)) {
		tmp = x + (-6.0 * (x * z));
	} else {
		tmp = x + (6.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 ((x <= (-3.3d+22)) .or. (.not. (x <= 3d-73))) then
        tmp = x + ((-6.0d0) * (x * z))
    else
        tmp = x + (6.0d0 * (y * z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -3.3e+22) || !(x <= 3e-73)) {
		tmp = x + (-6.0 * (x * z));
	} else {
		tmp = x + (6.0 * (y * z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -3.3e+22) or not (x <= 3e-73):
		tmp = x + (-6.0 * (x * z))
	else:
		tmp = x + (6.0 * (y * z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -3.3e+22) || !(x <= 3e-73))
		tmp = Float64(x + Float64(-6.0 * Float64(x * z)));
	else
		tmp = Float64(x + Float64(6.0 * Float64(y * z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -3.3e+22) || ~((x <= 3e-73)))
		tmp = x + (-6.0 * (x * z));
	else
		tmp = x + (6.0 * (y * z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.3e+22], N[Not[LessEqual[x, 3e-73]], $MachinePrecision]], N[(x + N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.3 \cdot 10^{+22} \lor \neg \left(x \leq 3 \cdot 10^{-73}\right):\\
\;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.2999999999999998e22 or 3e-73 < x

    1. Initial program 99.9%

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

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

    if -3.2999999999999998e22 < x < 3e-73

    1. Initial program 99.7%

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

      \[\leadsto x + \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutative93.7%

        \[\leadsto x + 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    5. Simplified93.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.3 \cdot 10^{+22} \lor \neg \left(x \leq 3 \cdot 10^{-73}\right):\\ \;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+22}:\\
\;\;\;\;x + \left(x \cdot -6\right) \cdot z\\

\mathbf{elif}\;x \leq 3 \cdot 10^{-73}:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.5e22

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{-6 \cdot \left(x \cdot z\right)} \]
    4. Step-by-step derivation
      1. associate-*r*85.7%

        \[\leadsto x + \color{blue}{\left(-6 \cdot x\right) \cdot z} \]
    5. Simplified85.7%

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

    if -1.5e22 < x < 3e-73

    1. Initial program 99.7%

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

      \[\leadsto x + \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutative93.7%

        \[\leadsto x + 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    5. Simplified93.7%

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

    if 3e-73 < x

    1. Initial program 99.8%

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

      \[\leadsto x + \color{blue}{-6 \cdot \left(x \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutative82.3%

        \[\leadsto x + \color{blue}{\left(x \cdot z\right) \cdot -6} \]
      2. associate-*r*82.4%

        \[\leadsto x + \color{blue}{x \cdot \left(z \cdot -6\right)} \]
      3. *-commutative82.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{+22}:\\ \;\;\;\;x + \left(x \cdot -6\right) \cdot z\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-73}:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \left(-6 \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 74.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.05 \cdot 10^{+127}:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\

\mathbf{elif}\;y \leq 1.5 \cdot 10^{+46}:\\
\;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.0499999999999998e127

    1. Initial program 99.8%

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

      \[\leadsto x + \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutative94.9%

        \[\leadsto x + 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    5. Simplified94.9%

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

      \[\leadsto \color{blue}{y \cdot \left(6 \cdot z + \frac{x}{y}\right)} \]
    7. Step-by-step derivation
      1. fma-define94.8%

        \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(6, z, \frac{x}{y}\right)} \]
    8. Simplified94.8%

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(6, z, \frac{x}{y}\right)} \]
    9. Taylor expanded in y around inf 79.4%

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

    if -4.0499999999999998e127 < y < 1.50000000000000012e46

    1. Initial program 99.8%

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

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

    if 1.50000000000000012e46 < y

    1. Initial program 99.8%

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

      \[\leadsto x + \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutative87.8%

        \[\leadsto x + 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    5. Simplified87.8%

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

      \[\leadsto \color{blue}{y \cdot \left(6 \cdot z + \frac{x}{y}\right)} \]
    7. Step-by-step derivation
      1. fma-define87.8%

        \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(6, z, \frac{x}{y}\right)} \]
    8. Simplified87.8%

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(6, z, \frac{x}{y}\right)} \]
    9. Taylor expanded in y around inf 71.7%

      \[\leadsto \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    10. Step-by-step derivation
      1. associate-*r*71.8%

        \[\leadsto \color{blue}{\left(6 \cdot y\right) \cdot z} \]
      2. *-commutative71.8%

        \[\leadsto \color{blue}{\left(y \cdot 6\right)} \cdot z \]
      3. associate-*r*71.8%

        \[\leadsto \color{blue}{y \cdot \left(6 \cdot z\right)} \]
    11. Simplified71.8%

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

Alternative 6: 61.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{-9} \lor \neg \left(z \leq 8.8 \cdot 10^{-60}\right):\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -3.5e-9) (not (<= z 8.8e-60))) (* 6.0 (* y z)) x))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -3.5e-9) || !(z <= 8.8e-60)) {
		tmp = 6.0 * (y * z);
	} else {
		tmp = x;
	}
	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 <= (-3.5d-9)) .or. (.not. (z <= 8.8d-60))) then
        tmp = 6.0d0 * (y * z)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -3.5e-9) || !(z <= 8.8e-60)) {
		tmp = 6.0 * (y * z);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -3.5e-9) or not (z <= 8.8e-60):
		tmp = 6.0 * (y * z)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -3.5e-9) || !(z <= 8.8e-60))
		tmp = Float64(6.0 * Float64(y * z));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -3.5e-9) || ~((z <= 8.8e-60)))
		tmp = 6.0 * (y * z);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.5e-9], N[Not[LessEqual[z, 8.8e-60]], $MachinePrecision]], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{-9} \lor \neg \left(z \leq 8.8 \cdot 10^{-60}\right):\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.4999999999999999e-9 or 8.7999999999999995e-60 < z

    1. Initial program 99.8%

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(6 \cdot z + \frac{x}{y}\right)} \]
    7. Step-by-step derivation
      1. fma-define57.0%

        \[\leadsto y \cdot \color{blue}{\mathsf{fma}\left(6, z, \frac{x}{y}\right)} \]
    8. Simplified57.0%

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(6, z, \frac{x}{y}\right)} \]
    9. Taylor expanded in y around inf 53.1%

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

    if -3.4999999999999999e-9 < z < 8.7999999999999995e-60

    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 77.8%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{-9} \lor \neg \left(z \leq 8.8 \cdot 10^{-60}\right):\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 99.7% accurate, 1.0× speedup?

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

\\
x + z \cdot \left(6 \cdot \left(y - x\right)\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(6 \cdot \left(y - x\right)\right) \]
  4. Add Preprocessing

Alternative 8: 36.6% 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 33.0%

    \[\leadsto \color{blue}{x} \]
  4. 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 2024160 
(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)))