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

Percentage Accurate: 99.7% → 99.7%
Time: 14.1s
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 + \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}
Derivation
  1. Initial program 99.8%

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

Alternative 2: 60.2% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq -165000:\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\

\mathbf{elif}\;z \leq -3.3 \cdot 10^{-105} \lor \neg \left(z \leq 1.52 \cdot 10^{-28}\right):\\
\;\;\;\;y \cdot \left(6 \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -9.3999999999999995e213

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

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

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

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

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

        \[\leadsto y \cdot \left(\color{blue}{z \cdot 6} + \frac{x}{y}\right) \]
      2. fma-define65.9%

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

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

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

    if -9.3999999999999995e213 < z < -165000

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

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

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

    if -165000 < z < -3.2999999999999999e-105 or 1.5199999999999999e-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 y around inf 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.2999999999999999e-105 < z < 1.5199999999999999e-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 72.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9.4 \cdot 10^{+213}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -165000:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-105} \lor \neg \left(z \leq 1.52 \cdot 10^{-28}\right):\\ \;\;\;\;y \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 60.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -4.3 \cdot 10^{+206}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -400000:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-103} \lor \neg \left(z \leq 2.15 \cdot 10^{-21}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* y z))))
   (if (<= z -4.3e+206)
     t_0
     (if (<= z -400000.0)
       (* -6.0 (* x z))
       (if (or (<= z -2.4e-103) (not (<= z 2.15e-21))) t_0 x)))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (y * z);
	double tmp;
	if (z <= -4.3e+206) {
		tmp = t_0;
	} else if (z <= -400000.0) {
		tmp = -6.0 * (x * z);
	} else if ((z <= -2.4e-103) || !(z <= 2.15e-21)) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = 6.0d0 * (y * z)
    if (z <= (-4.3d+206)) then
        tmp = t_0
    else if (z <= (-400000.0d0)) then
        tmp = (-6.0d0) * (x * z)
    else if ((z <= (-2.4d-103)) .or. (.not. (z <= 2.15d-21))) then
        tmp = t_0
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 6.0 * (y * z);
	double tmp;
	if (z <= -4.3e+206) {
		tmp = t_0;
	} else if (z <= -400000.0) {
		tmp = -6.0 * (x * z);
	} else if ((z <= -2.4e-103) || !(z <= 2.15e-21)) {
		tmp = t_0;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (y * z)
	tmp = 0
	if z <= -4.3e+206:
		tmp = t_0
	elif z <= -400000.0:
		tmp = -6.0 * (x * z)
	elif (z <= -2.4e-103) or not (z <= 2.15e-21):
		tmp = t_0
	else:
		tmp = x
	return tmp
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -4.3e+206)
		tmp = t_0;
	elseif (z <= -400000.0)
		tmp = Float64(-6.0 * Float64(x * z));
	elseif ((z <= -2.4e-103) || !(z <= 2.15e-21))
		tmp = t_0;
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 6.0 * (y * z);
	tmp = 0.0;
	if (z <= -4.3e+206)
		tmp = t_0;
	elseif (z <= -400000.0)
		tmp = -6.0 * (x * z);
	elseif ((z <= -2.4e-103) || ~((z <= 2.15e-21)))
		tmp = t_0;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.3e+206], t$95$0, If[LessEqual[z, -400000.0], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -2.4e-103], N[Not[LessEqual[z, 2.15e-21]], $MachinePrecision]], t$95$0, x]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{+206}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -400000:\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\

\mathbf{elif}\;z \leq -2.4 \cdot 10^{-103} \lor \neg \left(z \leq 2.15 \cdot 10^{-21}\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.29999999999999988e206 or -4e5 < z < -2.4000000000000002e-103 or 2.1499999999999999e-21 < 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 69.6%

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

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

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

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

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

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

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

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

    if -4.29999999999999988e206 < z < -4e5

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

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

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

    if -2.4000000000000002e-103 < z < 2.1499999999999999e-21

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{+206}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -400000:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-103} \lor \neg \left(z \leq 2.15 \cdot 10^{-21}\right):\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 60.4% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq -390000:\\
\;\;\;\;z \cdot \left(x \cdot -6\right)\\

\mathbf{elif}\;z \leq -3.7 \cdot 10^{-104}:\\
\;\;\;\;y \cdot \left(6 \cdot z\right)\\

\mathbf{elif}\;z \leq 2.15 \cdot 10^{-25}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -8.2e207

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

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

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

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

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

        \[\leadsto y \cdot \left(\color{blue}{z \cdot 6} + \frac{x}{y}\right) \]
      2. fma-define65.9%

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

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

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

    if -8.2e207 < z < -3.9e5

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

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

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

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

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

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

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

    if -3.9e5 < z < -3.6999999999999999e-104

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.6999999999999999e-104 < z < 2.14999999999999988e-25

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

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

    if 2.14999999999999988e-25 < 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 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(6 \cdot y\right)} \]
    14. Simplified61.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{+207}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -390000:\\ \;\;\;\;z \cdot \left(x \cdot -6\right)\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-104}:\\ \;\;\;\;y \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;z \leq 2.15 \cdot 10^{-25}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot 6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 60.4% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq -400000:\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\

\mathbf{elif}\;z \leq -3.8 \cdot 10^{-103}:\\
\;\;\;\;y \cdot \left(6 \cdot z\right)\\

\mathbf{elif}\;z \leq 1.65 \cdot 10^{-25}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -1.15999999999999999e208

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

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

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

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

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

        \[\leadsto y \cdot \left(\color{blue}{z \cdot 6} + \frac{x}{y}\right) \]
      2. fma-define65.9%

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

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

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

    if -1.15999999999999999e208 < z < -4e5

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

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

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

    if -4e5 < z < -3.8000000000000001e-103

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.8000000000000001e-103 < z < 1.6499999999999999e-25

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

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

    if 1.6499999999999999e-25 < 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 63.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(6 \cdot y\right)} \]
    14. Simplified61.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.16 \cdot 10^{+208}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -400000:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-103}:\\ \;\;\;\;y \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-25}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot 6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 86.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.55 \cdot 10^{-116} \lor \neg \left(y \leq 4.9 \cdot 10^{-82}\right):\\
\;\;\;\;x + z \cdot \left(y \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 y < -1.55000000000000009e-116 or 4.9000000000000003e-82 < 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 88.1%

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

    if -1.55000000000000009e-116 < y < 4.9000000000000003e-82

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

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

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

Alternative 7: 86.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-116} \lor \neg \left(y \leq 5.1 \cdot 10^{-82}\right):\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.9999999999999999e-117 or 5.09999999999999992e-82 < 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 88.0%

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

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

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

    if -9.9999999999999999e-117 < y < 5.09999999999999992e-82

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

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

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

Alternative 8: 75.0% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.14999999999999999e-14

    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 inf 89.8%

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

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

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

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

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

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

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

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

    if -1.14999999999999999e-14 < y < 1.9e15

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

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

    if 1.9e15 < 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 92.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(6 \cdot y\right)} \]
    14. Simplified74.1%

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

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

Alternative 9: 60.6% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{-13} \lor \neg \left(z \leq 0.0068\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 < -4.19999999999999977e-13 or 0.00679999999999999962 < 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 0 50.7%

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

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

    if -4.19999999999999977e-13 < z < 0.00679999999999999962

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

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

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

Alternative 10: 36.8% 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 32.3%

    \[\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 2024170 
(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)))