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

Percentage Accurate: 99.7% → 99.8%
Time: 9.5s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 99.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (* (- y x) z) 6.0 x))
double code(double x, double y, double z) {
	return fma(((y - x) * z), 6.0, x);
}
function code(x, y, z)
	return fma(Float64(Float64(y - x) * z), 6.0, x)
end
code[x_, y_, z_] := N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * 6.0 + x), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
  5. Final simplification99.8%

    \[\leadsto \mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right) \]
  6. Add Preprocessing

Alternative 2: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(z, \left(x - y\right) \cdot -6, x\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma z (* (- x y) -6.0) x))
double code(double x, double y, double z) {
	return fma(z, ((x - y) * -6.0), x);
}
function code(x, y, z)
	return fma(z, Float64(Float64(x - y) * -6.0), x)
end
code[x_, y_, z_] := N[(z * N[(N[(x - y), $MachinePrecision] * -6.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
  2. Step-by-step derivation
    1. +-commutative99.8%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)} \]
    4. remove-double-neg99.8%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{-\left(-\left(y - x\right) \cdot 6\right)}, x\right) \]
    5. distribute-lft-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(z, -\color{blue}{\left(-\left(y - x\right)\right) \cdot 6}, x\right) \]
    6. distribute-rgt-neg-in99.8%

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

      \[\leadsto \mathsf{fma}\left(z, \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-6\right), x\right) \]
    8. distribute-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\left(-y\right) + \left(-\left(-x\right)\right)\right)} \cdot \left(-6\right), x\right) \]
    9. remove-double-neg99.8%

      \[\leadsto \mathsf{fma}\left(z, \left(\left(-y\right) + \color{blue}{x}\right) \cdot \left(-6\right), x\right) \]
    10. +-commutative99.8%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x + \left(-y\right)\right)} \cdot \left(-6\right), x\right) \]
    11. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x - y\right)} \cdot \left(-6\right), x\right) \]
    12. metadata-eval99.8%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, \left(x - y\right) \cdot -6, x\right)} \]
  4. Add Preprocessing
  5. Final simplification99.8%

    \[\leadsto \mathsf{fma}\left(z, \left(x - y\right) \cdot -6, x\right) \]
  6. Add Preprocessing

Alternative 3: 60.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(x \cdot z\right)\\ t_1 := 6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -180000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-60}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+143} \lor \neg \left(z \leq 7.5 \cdot 10^{+181}\right) \land z \leq 8.1 \cdot 10^{+245}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -6.0 (* x z))) (t_1 (* 6.0 (* y z))))
   (if (<= z -180000000000.0)
     t_0
     (if (<= z -6.8e-36)
       t_1
       (if (<= z 1.4e-60)
         x
         (if (or (<= z 1.1e+143) (and (not (<= z 7.5e+181)) (<= z 8.1e+245)))
           t_1
           t_0))))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * (x * z);
	double t_1 = 6.0 * (y * z);
	double tmp;
	if (z <= -180000000000.0) {
		tmp = t_0;
	} else if (z <= -6.8e-36) {
		tmp = t_1;
	} else if (z <= 1.4e-60) {
		tmp = x;
	} else if ((z <= 1.1e+143) || (!(z <= 7.5e+181) && (z <= 8.1e+245))) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-6.0d0) * (x * z)
    t_1 = 6.0d0 * (y * z)
    if (z <= (-180000000000.0d0)) then
        tmp = t_0
    else if (z <= (-6.8d-36)) then
        tmp = t_1
    else if (z <= 1.4d-60) then
        tmp = x
    else if ((z <= 1.1d+143) .or. (.not. (z <= 7.5d+181)) .and. (z <= 8.1d+245)) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -6.0 * (x * z);
	double t_1 = 6.0 * (y * z);
	double tmp;
	if (z <= -180000000000.0) {
		tmp = t_0;
	} else if (z <= -6.8e-36) {
		tmp = t_1;
	} else if (z <= 1.4e-60) {
		tmp = x;
	} else if ((z <= 1.1e+143) || (!(z <= 7.5e+181) && (z <= 8.1e+245))) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -6.0 * (x * z)
	t_1 = 6.0 * (y * z)
	tmp = 0
	if z <= -180000000000.0:
		tmp = t_0
	elif z <= -6.8e-36:
		tmp = t_1
	elif z <= 1.4e-60:
		tmp = x
	elif (z <= 1.1e+143) or (not (z <= 7.5e+181) and (z <= 8.1e+245)):
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(-6.0 * Float64(x * z))
	t_1 = Float64(6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -180000000000.0)
		tmp = t_0;
	elseif (z <= -6.8e-36)
		tmp = t_1;
	elseif (z <= 1.4e-60)
		tmp = x;
	elseif ((z <= 1.1e+143) || (!(z <= 7.5e+181) && (z <= 8.1e+245)))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -6.0 * (x * z);
	t_1 = 6.0 * (y * z);
	tmp = 0.0;
	if (z <= -180000000000.0)
		tmp = t_0;
	elseif (z <= -6.8e-36)
		tmp = t_1;
	elseif (z <= 1.4e-60)
		tmp = x;
	elseif ((z <= 1.1e+143) || (~((z <= 7.5e+181)) && (z <= 8.1e+245)))
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -180000000000.0], t$95$0, If[LessEqual[z, -6.8e-36], t$95$1, If[LessEqual[z, 1.4e-60], x, If[Or[LessEqual[z, 1.1e+143], And[N[Not[LessEqual[z, 7.5e+181]], $MachinePrecision], LessEqual[z, 8.1e+245]]], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -6.8 \cdot 10^{-36}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 1.4 \cdot 10^{-60}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{+143} \lor \neg \left(z \leq 7.5 \cdot 10^{+181}\right) \land z \leq 8.1 \cdot 10^{+245}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.8e11 or 1.10000000000000007e143 < z < 7.5000000000000005e181 or 8.10000000000000023e245 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)} \]
      4. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-\left(-\left(y - x\right) \cdot 6\right)}, x\right) \]
      5. distribute-lft-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, -\color{blue}{\left(-\left(y - x\right)\right) \cdot 6}, x\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(-\left(y - x\right)\right) \cdot \left(-6\right)}, x\right) \]
      7. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-6\right), x\right) \]
      8. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\left(-y\right) + \left(-\left(-x\right)\right)\right)} \cdot \left(-6\right), x\right) \]
      9. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(\left(-y\right) + \color{blue}{x}\right) \cdot \left(-6\right), x\right) \]
      10. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x + \left(-y\right)\right)} \cdot \left(-6\right), x\right) \]
      11. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x - y\right)} \cdot \left(-6\right), x\right) \]
      12. metadata-eval99.7%

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

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

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

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

    if -1.8e11 < z < -6.8000000000000005e-36 or 1.4000000000000001e-60 < z < 1.10000000000000007e143 or 7.5000000000000005e181 < z < 8.10000000000000023e245

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

        \[\leadsto 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    7. Simplified75.4%

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

    if -6.8000000000000005e-36 < z < 1.4000000000000001e-60

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -180000000000:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-36}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-60}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+143} \lor \neg \left(z \leq 7.5 \cdot 10^{+181}\right) \land z \leq 8.1 \cdot 10^{+245}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 60.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(z \cdot -6\right)\\ t_1 := 6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -260000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-53}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{+142}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+181}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 5.9 \cdot 10^{+245}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (* z -6.0))) (t_1 (* 6.0 (* y z))))
   (if (<= z -260000000000.0)
     t_0
     (if (<= z -2.2e-39)
       t_1
       (if (<= z 1.8e-53)
         x
         (if (<= z 3.2e+142)
           t_1
           (if (<= z 1.7e+181)
             (* -6.0 (* x z))
             (if (<= z 5.9e+245) t_1 t_0))))))))
double code(double x, double y, double z) {
	double t_0 = x * (z * -6.0);
	double t_1 = 6.0 * (y * z);
	double tmp;
	if (z <= -260000000000.0) {
		tmp = t_0;
	} else if (z <= -2.2e-39) {
		tmp = t_1;
	} else if (z <= 1.8e-53) {
		tmp = x;
	} else if (z <= 3.2e+142) {
		tmp = t_1;
	} else if (z <= 1.7e+181) {
		tmp = -6.0 * (x * z);
	} else if (z <= 5.9e+245) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * (z * (-6.0d0))
    t_1 = 6.0d0 * (y * z)
    if (z <= (-260000000000.0d0)) then
        tmp = t_0
    else if (z <= (-2.2d-39)) then
        tmp = t_1
    else if (z <= 1.8d-53) then
        tmp = x
    else if (z <= 3.2d+142) then
        tmp = t_1
    else if (z <= 1.7d+181) then
        tmp = (-6.0d0) * (x * z)
    else if (z <= 5.9d+245) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (z * -6.0);
	double t_1 = 6.0 * (y * z);
	double tmp;
	if (z <= -260000000000.0) {
		tmp = t_0;
	} else if (z <= -2.2e-39) {
		tmp = t_1;
	} else if (z <= 1.8e-53) {
		tmp = x;
	} else if (z <= 3.2e+142) {
		tmp = t_1;
	} else if (z <= 1.7e+181) {
		tmp = -6.0 * (x * z);
	} else if (z <= 5.9e+245) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (z * -6.0)
	t_1 = 6.0 * (y * z)
	tmp = 0
	if z <= -260000000000.0:
		tmp = t_0
	elif z <= -2.2e-39:
		tmp = t_1
	elif z <= 1.8e-53:
		tmp = x
	elif z <= 3.2e+142:
		tmp = t_1
	elif z <= 1.7e+181:
		tmp = -6.0 * (x * z)
	elif z <= 5.9e+245:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(z * -6.0))
	t_1 = Float64(6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -260000000000.0)
		tmp = t_0;
	elseif (z <= -2.2e-39)
		tmp = t_1;
	elseif (z <= 1.8e-53)
		tmp = x;
	elseif (z <= 3.2e+142)
		tmp = t_1;
	elseif (z <= 1.7e+181)
		tmp = Float64(-6.0 * Float64(x * z));
	elseif (z <= 5.9e+245)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (z * -6.0);
	t_1 = 6.0 * (y * z);
	tmp = 0.0;
	if (z <= -260000000000.0)
		tmp = t_0;
	elseif (z <= -2.2e-39)
		tmp = t_1;
	elseif (z <= 1.8e-53)
		tmp = x;
	elseif (z <= 3.2e+142)
		tmp = t_1;
	elseif (z <= 1.7e+181)
		tmp = -6.0 * (x * z);
	elseif (z <= 5.9e+245)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -260000000000.0], t$95$0, If[LessEqual[z, -2.2e-39], t$95$1, If[LessEqual[z, 1.8e-53], x, If[LessEqual[z, 3.2e+142], t$95$1, If[LessEqual[z, 1.7e+181], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.9e+245], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.2 \cdot 10^{-39}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 1.8 \cdot 10^{-53}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 3.2 \cdot 10^{+142}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;z \leq 5.9 \cdot 10^{+245}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -2.6e11 or 5.9000000000000002e245 < z

    1. Initial program 99.7%

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

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

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

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

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

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

    if -2.6e11 < z < -2.20000000000000001e-39 or 1.7999999999999999e-53 < z < 3.20000000000000005e142 or 1.70000000000000015e181 < z < 5.9000000000000002e245

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

        \[\leadsto 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    7. Simplified75.4%

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

    if -2.20000000000000001e-39 < z < 1.7999999999999999e-53

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

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

    if 3.20000000000000005e142 < z < 1.70000000000000015e181

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)} \]
      4. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-\left(-\left(y - x\right) \cdot 6\right)}, x\right) \]
      5. distribute-lft-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, -\color{blue}{\left(-\left(y - x\right)\right) \cdot 6}, x\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(-\left(y - x\right)\right) \cdot \left(-6\right)}, x\right) \]
      7. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-6\right), x\right) \]
      8. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\left(-y\right) + \left(-\left(-x\right)\right)\right)} \cdot \left(-6\right), x\right) \]
      9. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(\left(-y\right) + \color{blue}{x}\right) \cdot \left(-6\right), x\right) \]
      10. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x + \left(-y\right)\right)} \cdot \left(-6\right), x\right) \]
      11. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x - y\right)} \cdot \left(-6\right), x\right) \]
      12. metadata-eval99.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -260000000000:\\ \;\;\;\;x \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-39}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-53}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{+142}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+181}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 5.9 \cdot 10^{+245}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot -6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 60.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(z \cdot -6\right)\\ t_1 := 6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -470000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-55}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+142}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{+182}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{+245}:\\ \;\;\;\;y \cdot \left(z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (* z -6.0))) (t_1 (* 6.0 (* y z))))
   (if (<= z -470000000.0)
     t_0
     (if (<= z -2e-42)
       t_1
       (if (<= z 1.5e-55)
         x
         (if (<= z 4.4e+142)
           t_1
           (if (<= z 2.6e+182)
             (* -6.0 (* x z))
             (if (<= z 1.65e+245) (* y (* z 6.0)) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = x * (z * -6.0);
	double t_1 = 6.0 * (y * z);
	double tmp;
	if (z <= -470000000.0) {
		tmp = t_0;
	} else if (z <= -2e-42) {
		tmp = t_1;
	} else if (z <= 1.5e-55) {
		tmp = x;
	} else if (z <= 4.4e+142) {
		tmp = t_1;
	} else if (z <= 2.6e+182) {
		tmp = -6.0 * (x * z);
	} else if (z <= 1.65e+245) {
		tmp = y * (z * 6.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * (z * (-6.0d0))
    t_1 = 6.0d0 * (y * z)
    if (z <= (-470000000.0d0)) then
        tmp = t_0
    else if (z <= (-2d-42)) then
        tmp = t_1
    else if (z <= 1.5d-55) then
        tmp = x
    else if (z <= 4.4d+142) then
        tmp = t_1
    else if (z <= 2.6d+182) then
        tmp = (-6.0d0) * (x * z)
    else if (z <= 1.65d+245) then
        tmp = y * (z * 6.0d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (z * -6.0);
	double t_1 = 6.0 * (y * z);
	double tmp;
	if (z <= -470000000.0) {
		tmp = t_0;
	} else if (z <= -2e-42) {
		tmp = t_1;
	} else if (z <= 1.5e-55) {
		tmp = x;
	} else if (z <= 4.4e+142) {
		tmp = t_1;
	} else if (z <= 2.6e+182) {
		tmp = -6.0 * (x * z);
	} else if (z <= 1.65e+245) {
		tmp = y * (z * 6.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (z * -6.0)
	t_1 = 6.0 * (y * z)
	tmp = 0
	if z <= -470000000.0:
		tmp = t_0
	elif z <= -2e-42:
		tmp = t_1
	elif z <= 1.5e-55:
		tmp = x
	elif z <= 4.4e+142:
		tmp = t_1
	elif z <= 2.6e+182:
		tmp = -6.0 * (x * z)
	elif z <= 1.65e+245:
		tmp = y * (z * 6.0)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(z * -6.0))
	t_1 = Float64(6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -470000000.0)
		tmp = t_0;
	elseif (z <= -2e-42)
		tmp = t_1;
	elseif (z <= 1.5e-55)
		tmp = x;
	elseif (z <= 4.4e+142)
		tmp = t_1;
	elseif (z <= 2.6e+182)
		tmp = Float64(-6.0 * Float64(x * z));
	elseif (z <= 1.65e+245)
		tmp = Float64(y * Float64(z * 6.0));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (z * -6.0);
	t_1 = 6.0 * (y * z);
	tmp = 0.0;
	if (z <= -470000000.0)
		tmp = t_0;
	elseif (z <= -2e-42)
		tmp = t_1;
	elseif (z <= 1.5e-55)
		tmp = x;
	elseif (z <= 4.4e+142)
		tmp = t_1;
	elseif (z <= 2.6e+182)
		tmp = -6.0 * (x * z);
	elseif (z <= 1.65e+245)
		tmp = y * (z * 6.0);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -470000000.0], t$95$0, If[LessEqual[z, -2e-42], t$95$1, If[LessEqual[z, 1.5e-55], x, If[LessEqual[z, 4.4e+142], t$95$1, If[LessEqual[z, 2.6e+182], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.65e+245], N[(y * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2 \cdot 10^{-42}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 1.5 \cdot 10^{-55}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 4.4 \cdot 10^{+142}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;z \leq 1.65 \cdot 10^{+245}:\\
\;\;\;\;y \cdot \left(z \cdot 6\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -4.7e8 or 1.65000000000000005e245 < z

    1. Initial program 99.7%

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

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

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

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

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

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

    if -4.7e8 < z < -2.00000000000000008e-42 or 1.50000000000000008e-55 < z < 4.39999999999999974e142

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000008e-42 < z < 1.50000000000000008e-55

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

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

    if 4.39999999999999974e142 < z < 2.6e182

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)} \]
      4. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-\left(-\left(y - x\right) \cdot 6\right)}, x\right) \]
      5. distribute-lft-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, -\color{blue}{\left(-\left(y - x\right)\right) \cdot 6}, x\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(-\left(y - x\right)\right) \cdot \left(-6\right)}, x\right) \]
      7. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-6\right), x\right) \]
      8. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\left(-y\right) + \left(-\left(-x\right)\right)\right)} \cdot \left(-6\right), x\right) \]
      9. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(\left(-y\right) + \color{blue}{x}\right) \cdot \left(-6\right), x\right) \]
      10. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x + \left(-y\right)\right)} \cdot \left(-6\right), x\right) \]
      11. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x - y\right)} \cdot \left(-6\right), x\right) \]
      12. metadata-eval99.7%

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

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

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

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

    if 2.6e182 < z < 1.65000000000000005e245

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(6 \cdot z\right)} \]
    10. Simplified92.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -470000000:\\ \;\;\;\;x \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-42}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-55}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+142}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{+182}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{+245}:\\ \;\;\;\;y \cdot \left(z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot -6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 60.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(z \cdot -6\right)\\ t_1 := 6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -49000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-56}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+181}:\\ \;\;\;\;z \cdot \left(x \cdot -6\right)\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+245}:\\ \;\;\;\;y \cdot \left(z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (* z -6.0))) (t_1 (* 6.0 (* y z))))
   (if (<= z -49000000000.0)
     t_0
     (if (<= z -7e-36)
       t_1
       (if (<= z 6.8e-56)
         x
         (if (<= z 1.2e+143)
           t_1
           (if (<= z 1.35e+181)
             (* z (* x -6.0))
             (if (<= z 4e+245) (* y (* z 6.0)) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = x * (z * -6.0);
	double t_1 = 6.0 * (y * z);
	double tmp;
	if (z <= -49000000000.0) {
		tmp = t_0;
	} else if (z <= -7e-36) {
		tmp = t_1;
	} else if (z <= 6.8e-56) {
		tmp = x;
	} else if (z <= 1.2e+143) {
		tmp = t_1;
	} else if (z <= 1.35e+181) {
		tmp = z * (x * -6.0);
	} else if (z <= 4e+245) {
		tmp = y * (z * 6.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * (z * (-6.0d0))
    t_1 = 6.0d0 * (y * z)
    if (z <= (-49000000000.0d0)) then
        tmp = t_0
    else if (z <= (-7d-36)) then
        tmp = t_1
    else if (z <= 6.8d-56) then
        tmp = x
    else if (z <= 1.2d+143) then
        tmp = t_1
    else if (z <= 1.35d+181) then
        tmp = z * (x * (-6.0d0))
    else if (z <= 4d+245) then
        tmp = y * (z * 6.0d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (z * -6.0);
	double t_1 = 6.0 * (y * z);
	double tmp;
	if (z <= -49000000000.0) {
		tmp = t_0;
	} else if (z <= -7e-36) {
		tmp = t_1;
	} else if (z <= 6.8e-56) {
		tmp = x;
	} else if (z <= 1.2e+143) {
		tmp = t_1;
	} else if (z <= 1.35e+181) {
		tmp = z * (x * -6.0);
	} else if (z <= 4e+245) {
		tmp = y * (z * 6.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (z * -6.0)
	t_1 = 6.0 * (y * z)
	tmp = 0
	if z <= -49000000000.0:
		tmp = t_0
	elif z <= -7e-36:
		tmp = t_1
	elif z <= 6.8e-56:
		tmp = x
	elif z <= 1.2e+143:
		tmp = t_1
	elif z <= 1.35e+181:
		tmp = z * (x * -6.0)
	elif z <= 4e+245:
		tmp = y * (z * 6.0)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(z * -6.0))
	t_1 = Float64(6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -49000000000.0)
		tmp = t_0;
	elseif (z <= -7e-36)
		tmp = t_1;
	elseif (z <= 6.8e-56)
		tmp = x;
	elseif (z <= 1.2e+143)
		tmp = t_1;
	elseif (z <= 1.35e+181)
		tmp = Float64(z * Float64(x * -6.0));
	elseif (z <= 4e+245)
		tmp = Float64(y * Float64(z * 6.0));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (z * -6.0);
	t_1 = 6.0 * (y * z);
	tmp = 0.0;
	if (z <= -49000000000.0)
		tmp = t_0;
	elseif (z <= -7e-36)
		tmp = t_1;
	elseif (z <= 6.8e-56)
		tmp = x;
	elseif (z <= 1.2e+143)
		tmp = t_1;
	elseif (z <= 1.35e+181)
		tmp = z * (x * -6.0);
	elseif (z <= 4e+245)
		tmp = y * (z * 6.0);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -49000000000.0], t$95$0, If[LessEqual[z, -7e-36], t$95$1, If[LessEqual[z, 6.8e-56], x, If[LessEqual[z, 1.2e+143], t$95$1, If[LessEqual[z, 1.35e+181], N[(z * N[(x * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4e+245], N[(y * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -7 \cdot 10^{-36}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 6.8 \cdot 10^{-56}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 1.2 \cdot 10^{+143}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;z \leq 4 \cdot 10^{+245}:\\
\;\;\;\;y \cdot \left(z \cdot 6\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -4.9e10 or 4.00000000000000018e245 < z

    1. Initial program 99.7%

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

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

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

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

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

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

    if -4.9e10 < z < -6.9999999999999999e-36 or 6.79999999999999964e-56 < z < 1.1999999999999999e143

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

    if -6.9999999999999999e-36 < z < 6.79999999999999964e-56

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

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

    if 1.1999999999999999e143 < z < 1.35000000000000004e181

    1. Initial program 99.7%

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

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

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

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

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

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

    if 1.35000000000000004e181 < z < 4.00000000000000018e245

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(6 \cdot z\right)} \]
    10. Simplified92.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -49000000000:\\ \;\;\;\;x \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-36}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{-56}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+143}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+181}:\\ \;\;\;\;z \cdot \left(x \cdot -6\right)\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+245}:\\ \;\;\;\;y \cdot \left(z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot -6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{-44} \lor \neg \left(z \leq 1.85 \cdot 10^{-60}\right):\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.40000000000000024e-44 or 1.85000000000000012e-60 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)} \]
      4. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-\left(-\left(y - x\right) \cdot 6\right)}, x\right) \]
      5. distribute-lft-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, -\color{blue}{\left(-\left(y - x\right)\right) \cdot 6}, x\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(-\left(y - x\right)\right) \cdot \left(-6\right)}, x\right) \]
      7. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-6\right), x\right) \]
      8. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\left(-y\right) + \left(-\left(-x\right)\right)\right)} \cdot \left(-6\right), x\right) \]
      9. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(\left(-y\right) + \color{blue}{x}\right) \cdot \left(-6\right), x\right) \]
      10. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x + \left(-y\right)\right)} \cdot \left(-6\right), x\right) \]
      11. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x - y\right)} \cdot \left(-6\right), x\right) \]
      12. metadata-eval99.7%

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

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

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

    if -4.40000000000000024e-44 < z < 1.85000000000000012e-60

    1. Initial program 99.9%

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

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

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

Alternative 8: 84.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-43} \lor \neg \left(z \leq 3.9 \cdot 10^{-59}\right):\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\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.05e-43 or 3.90000000000000019e-59 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)} \]
      4. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-\left(-\left(y - x\right) \cdot 6\right)}, x\right) \]
      5. distribute-lft-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, -\color{blue}{\left(-\left(y - x\right)\right) \cdot 6}, x\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(-\left(y - x\right)\right) \cdot \left(-6\right)}, x\right) \]
      7. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-6\right), x\right) \]
      8. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\left(-y\right) + \left(-\left(-x\right)\right)\right)} \cdot \left(-6\right), x\right) \]
      9. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(\left(-y\right) + \color{blue}{x}\right) \cdot \left(-6\right), x\right) \]
      10. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x + \left(-y\right)\right)} \cdot \left(-6\right), x\right) \]
      11. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x - y\right)} \cdot \left(-6\right), x\right) \]
      12. metadata-eval99.7%

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

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

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

    if -1.05e-43 < z < 3.90000000000000019e-59

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

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

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

Alternative 9: 98.6% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)} \]
      4. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-\left(-\left(y - x\right) \cdot 6\right)}, x\right) \]
      5. distribute-lft-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, -\color{blue}{\left(-\left(y - x\right)\right) \cdot 6}, x\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(-\left(y - x\right)\right) \cdot \left(-6\right)}, x\right) \]
      7. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-6\right), x\right) \]
      8. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\left(-y\right) + \left(-\left(-x\right)\right)\right)} \cdot \left(-6\right), x\right) \]
      9. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(\left(-y\right) + \color{blue}{x}\right) \cdot \left(-6\right), x\right) \]
      10. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x + \left(-y\right)\right)} \cdot \left(-6\right), x\right) \]
      11. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x - y\right)} \cdot \left(-6\right), x\right) \]
      12. metadata-eval99.7%

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

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

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

    if -0.160000000000000003 < 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 inf 98.3%

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

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

Alternative 10: 59.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165 \lor \neg \left(z \leq 470\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 < -0.165000000000000008 or 470 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, \left(y - x\right) \cdot 6, x\right)} \]
      4. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{-\left(-\left(y - x\right) \cdot 6\right)}, x\right) \]
      5. distribute-lft-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, -\color{blue}{\left(-\left(y - x\right)\right) \cdot 6}, x\right) \]
      6. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(-\left(y - x\right)\right) \cdot \left(-6\right)}, x\right) \]
      7. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(-\color{blue}{\left(y + \left(-x\right)\right)}\right) \cdot \left(-6\right), x\right) \]
      8. distribute-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\left(-y\right) + \left(-\left(-x\right)\right)\right)} \cdot \left(-6\right), x\right) \]
      9. remove-double-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \left(\left(-y\right) + \color{blue}{x}\right) \cdot \left(-6\right), x\right) \]
      10. +-commutative99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x + \left(-y\right)\right)} \cdot \left(-6\right), x\right) \]
      11. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(x - y\right)} \cdot \left(-6\right), x\right) \]
      12. metadata-eval99.7%

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

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

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

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

    if -0.165000000000000008 < z < 470

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

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

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

Alternative 11: 99.7% accurate, 1.0× speedup?

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

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

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

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

Alternative 12: 99.8% accurate, 1.0× speedup?

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

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

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

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

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

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

Alternative 13: 35.7% accurate, 9.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 99.8%

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification33.1%

    \[\leadsto x \]
  5. Add Preprocessing

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 2024010 
(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)))