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

Percentage Accurate: 99.7% → 99.7%
Time: 9.5s
Alternatives: 10
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 10 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, 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. Final simplification99.8%

    \[\leadsto x + z \cdot \left(\left(y - x\right) \cdot 6\right) \]

Alternative 2: 61.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := z \cdot \left(y \cdot 6\right)\\ t_1 := x \cdot \left(z \cdot -6\right)\\ \mathbf{if}\;z \leq -6.4 \cdot 10^{+44}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7.8 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{-17}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{+65}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* z (* y 6.0))) (t_1 (* x (* z -6.0))))
   (if (<= z -6.4e+44)
     t_0
     (if (<= z -7.8e-13)
       t_1
       (if (<= z 3.9e-17) x (if (<= z 1.8e+65) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = z * (y * 6.0);
	double t_1 = x * (z * -6.0);
	double tmp;
	if (z <= -6.4e+44) {
		tmp = t_0;
	} else if (z <= -7.8e-13) {
		tmp = t_1;
	} else if (z <= 3.9e-17) {
		tmp = x;
	} else if (z <= 1.8e+65) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: tmp
    t_0 = z * (y * 6.0d0)
    t_1 = x * (z * (-6.0d0))
    if (z <= (-6.4d+44)) then
        tmp = t_0
    else if (z <= (-7.8d-13)) then
        tmp = t_1
    else if (z <= 3.9d-17) then
        tmp = x
    else if (z <= 1.8d+65) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = z * (y * 6.0);
	double t_1 = x * (z * -6.0);
	double tmp;
	if (z <= -6.4e+44) {
		tmp = t_0;
	} else if (z <= -7.8e-13) {
		tmp = t_1;
	} else if (z <= 3.9e-17) {
		tmp = x;
	} else if (z <= 1.8e+65) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = z * (y * 6.0)
	t_1 = x * (z * -6.0)
	tmp = 0
	if z <= -6.4e+44:
		tmp = t_0
	elif z <= -7.8e-13:
		tmp = t_1
	elif z <= 3.9e-17:
		tmp = x
	elif z <= 1.8e+65:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(z * Float64(y * 6.0))
	t_1 = Float64(x * Float64(z * -6.0))
	tmp = 0.0
	if (z <= -6.4e+44)
		tmp = t_0;
	elseif (z <= -7.8e-13)
		tmp = t_1;
	elseif (z <= 3.9e-17)
		tmp = x;
	elseif (z <= 1.8e+65)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = z * (y * 6.0);
	t_1 = x * (z * -6.0);
	tmp = 0.0;
	if (z <= -6.4e+44)
		tmp = t_0;
	elseif (z <= -7.8e-13)
		tmp = t_1;
	elseif (z <= 3.9e-17)
		tmp = x;
	elseif (z <= 1.8e+65)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y * 6.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.4e+44], t$95$0, If[LessEqual[z, -7.8e-13], t$95$1, If[LessEqual[z, 3.9e-17], x, If[LessEqual[z, 1.8e+65], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := z \cdot \left(y \cdot 6\right)\\
t_1 := x \cdot \left(z \cdot -6\right)\\
\mathbf{if}\;z \leq -6.4 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -7.8 \cdot 10^{-13}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 3.9 \cdot 10^{-17}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 1.8 \cdot 10^{+65}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -6.40000000000000009e44 or 3.89999999999999989e-17 < z < 1.79999999999999989e65

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. flip3-+16.2%

        \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}} \]
      3. clear-num16.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}}} \]
      4. *-un-lft-identity16.2%

        \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot \left(x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)\right)}}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}} \]
      5. associate-/l*16.2%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}}}} \]
      6. flip3-+99.7%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)}}} \]
      7. +-commutative99.7%

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y - x, 6 \cdot z, x\right)}}} \]
    3. Applied egg-rr99.7%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{0.16666666666666666}{y \cdot z}}} \]
    5. Step-by-step derivation
      1. *-commutative62.4%

        \[\leadsto \frac{1}{\frac{0.16666666666666666}{\color{blue}{z \cdot y}}} \]
    6. Simplified62.4%

      \[\leadsto \frac{1}{\color{blue}{\frac{0.16666666666666666}{z \cdot y}}} \]
    7. Step-by-step derivation
      1. associate-/r/62.5%

        \[\leadsto \color{blue}{\frac{1}{0.16666666666666666} \cdot \left(z \cdot y\right)} \]
      2. *-commutative62.5%

        \[\leadsto \frac{1}{0.16666666666666666} \cdot \color{blue}{\left(y \cdot z\right)} \]
      3. associate-*r*62.7%

        \[\leadsto \color{blue}{\left(\frac{1}{0.16666666666666666} \cdot y\right) \cdot z} \]
      4. metadata-eval62.7%

        \[\leadsto \left(\color{blue}{6} \cdot y\right) \cdot z \]
    8. Applied egg-rr62.7%

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

    if -6.40000000000000009e44 < z < -7.80000000000000009e-13 or 1.79999999999999989e65 < z

    1. Initial program 99.7%

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

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

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

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

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

    if -7.80000000000000009e-13 < z < 3.89999999999999989e-17

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{+44}:\\ \;\;\;\;z \cdot \left(y \cdot 6\right)\\ \mathbf{elif}\;z \leq -7.8 \cdot 10^{-13}:\\ \;\;\;\;x \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{-17}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{+65}:\\ \;\;\;\;z \cdot \left(y \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot -6\right)\\ \end{array} \]

Alternative 3: 84.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-17} \lor \neg \left(z \leq 4.5 \cdot 10^{-17}\right):\\
\;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.6999999999999999e-17 or 4.49999999999999978e-17 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. flip3-+17.6%

        \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}} \]
      3. clear-num17.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}}} \]
      4. *-un-lft-identity17.6%

        \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot \left(x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)\right)}}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}} \]
      5. associate-/l*17.6%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}}}} \]
      6. flip3-+99.7%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)}}} \]
      7. +-commutative99.7%

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y - x, 6 \cdot z, x\right)}}} \]
    3. Applied egg-rr99.7%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{0.16666666666666666}{z \cdot \left(y - x\right)}}} \]
    5. Step-by-step derivation
      1. *-commutative97.0%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    6. Simplified97.0%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    7. Taylor expanded in z around 0 97.1%

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

    if -1.6999999999999999e-17 < z < 4.49999999999999978e-17

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{-17} \lor \neg \left(z \leq 4.5 \cdot 10^{-17}\right):\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 4: 84.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{-17} \lor \neg \left(z \leq 1.4 \cdot 10^{-9}\right):\\
\;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.30000000000000009e-17 or 1.39999999999999992e-9 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. flip3-+17.9%

        \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}} \]
      3. clear-num17.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}}} \]
      4. *-un-lft-identity17.9%

        \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot \left(x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)\right)}}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}} \]
      5. associate-/l*17.9%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}}}} \]
      6. flip3-+99.7%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)}}} \]
      7. +-commutative99.7%

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y - x, 6 \cdot z, x\right)}}} \]
    3. Applied egg-rr99.7%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{0.16666666666666666}{z \cdot \left(y - x\right)}}} \]
    5. Step-by-step derivation
      1. *-commutative97.7%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    6. Simplified97.8%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    7. Taylor expanded in z around 0 97.9%

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

    if -2.30000000000000009e-17 < z < 1.39999999999999992e-9

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{-17} \lor \neg \left(z \leq 1.4 \cdot 10^{-9}\right):\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \end{array} \]

Alternative 5: 84.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-17} \lor \neg \left(z \leq 1.2 \cdot 10^{-9}\right):\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.2e-17 or 1.2e-9 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. flip3-+17.9%

        \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}} \]
      3. clear-num17.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}}} \]
      4. *-un-lft-identity17.9%

        \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot \left(x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)\right)}}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}} \]
      5. associate-/l*17.9%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}}}} \]
      6. flip3-+99.7%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)}}} \]
      7. +-commutative99.7%

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y - x, 6 \cdot z, x\right)}}} \]
    3. Applied egg-rr99.7%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{0.16666666666666666}{z \cdot \left(y - x\right)}}} \]
    5. Step-by-step derivation
      1. *-commutative97.7%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    6. Simplified97.8%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    7. Step-by-step derivation
      1. associate-/r/97.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{0.16666666666666666}{y - x}} \cdot z} \]
      2. associate-/r/97.9%

        \[\leadsto \color{blue}{\left(\frac{1}{0.16666666666666666} \cdot \left(y - x\right)\right)} \cdot z \]
      3. metadata-eval97.9%

        \[\leadsto \left(\color{blue}{6} \cdot \left(y - x\right)\right) \cdot z \]
    8. Applied egg-rr97.9%

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

    if -2.2e-17 < z < 1.2e-9

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{-17} \lor \neg \left(z \leq 1.2 \cdot 10^{-9}\right):\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 + z \cdot -6\right)\\ \end{array} \]

Alternative 6: 84.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{-17} \lor \neg \left(z \leq 1.45 \cdot 10^{-10}\right):\\
\;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.50000000000000003e-17 or 1.4499999999999999e-10 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. flip3-+17.9%

        \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}} \]
      3. clear-num17.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}}} \]
      4. *-un-lft-identity17.9%

        \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot \left(x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)\right)}}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}} \]
      5. associate-/l*17.9%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}}}} \]
      6. flip3-+99.7%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)}}} \]
      7. +-commutative99.7%

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y - x, 6 \cdot z, x\right)}}} \]
    3. Applied egg-rr99.7%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{0.16666666666666666}{z \cdot \left(y - x\right)}}} \]
    5. Step-by-step derivation
      1. *-commutative97.7%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    6. Simplified97.8%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    7. Step-by-step derivation
      1. associate-/r/97.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{0.16666666666666666}{y - x}} \cdot z} \]
      2. associate-/r/97.9%

        \[\leadsto \color{blue}{\left(\frac{1}{0.16666666666666666} \cdot \left(y - x\right)\right)} \cdot z \]
      3. metadata-eval97.9%

        \[\leadsto \left(\color{blue}{6} \cdot \left(y - x\right)\right) \cdot z \]
    8. Applied egg-rr97.9%

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

    if -1.50000000000000003e-17 < z < 1.4499999999999999e-10

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-17} \lor \neg \left(z \leq 1.45 \cdot 10^{-10}\right):\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\ \end{array} \]

Alternative 7: 98.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.154999999999999999 or 0.170000000000000012 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. flip3-+17.2%

        \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}} \]
      3. clear-num17.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}}} \]
      4. *-un-lft-identity17.2%

        \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot \left(x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)\right)}}{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}} \]
      5. associate-/l*17.2%

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right) - x \cdot \left(\left(y - x\right) \cdot \left(6 \cdot z\right)\right)\right)}}}} \]
      6. flip3-+99.7%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)}}} \]
      7. +-commutative99.7%

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

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\mathsf{fma}\left(y - x, 6 \cdot z, x\right)}}} \]
    3. Applied egg-rr99.7%

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

      \[\leadsto \frac{1}{\color{blue}{\frac{0.16666666666666666}{z \cdot \left(y - x\right)}}} \]
    5. Step-by-step derivation
      1. *-commutative99.1%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    6. Simplified99.2%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{0.16666666666666666}{y - x}}{z}}} \]
    7. Step-by-step derivation
      1. associate-/r/99.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{0.16666666666666666}{y - x}} \cdot z} \]
      2. associate-/r/99.4%

        \[\leadsto \color{blue}{\left(\frac{1}{0.16666666666666666} \cdot \left(y - x\right)\right)} \cdot z \]
      3. metadata-eval99.4%

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

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

    if -0.154999999999999999 < z < 0.170000000000000012

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.155 \lor \neg \left(z \leq 0.17\right):\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \end{array} \]

Alternative 8: 59.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{-13} \lor \neg \left(z \leq 0.17\right):\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.80000000000000009e-13 or 0.170000000000000012 < z

    1. Initial program 99.8%

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

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

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

    if -7.80000000000000009e-13 < z < 0.170000000000000012

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{-13} \lor \neg \left(z \leq 0.17\right):\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 9: 59.8% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;z \leq 0.17:\\
\;\;\;\;x\\

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


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

    1. Initial program 99.8%

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

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

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

    if -7.80000000000000009e-13 < z < 0.170000000000000012

    1. Initial program 99.9%

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

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

    if 0.170000000000000012 < z

    1. Initial program 99.7%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{-13}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 0.17:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot -6\right)\\ \end{array} \]

Alternative 10: 35.5% 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. Taylor expanded in z around 0 41.6%

    \[\leadsto \color{blue}{x} \]
  3. Final simplification41.6%

    \[\leadsto x \]

Developer target: 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 2023301 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
  :precision binary64

  :herbie-target
  (- x (* (* 6.0 z) (- x y)))

  (+ x (* (* (- y x) 6.0) z)))