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

Percentage Accurate: 99.5% → 99.8%
Time: 14.4s
Alternatives: 11
Speedup: 1.2×

Specification

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

\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\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 11 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.1× speedup?

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

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. +-commutative99.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.8% accurate, 0.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\


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

    1. Initial program 99.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.8%

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

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

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

    if -0.660000000000000031 < z < 0.5

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.4%

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

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

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

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

Alternative 3: 97.8% accurate, 0.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\


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

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.7%

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

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

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

    if -0.660000000000000031 < z < 0.52000000000000002

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.4%

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

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

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

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

Alternative 4: 75.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.2 \cdot 10^{-11} \lor \neg \left(y \leq 2.46 \cdot 10^{+61}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -3.2e-11) (not (<= y 2.46e+61)))
   (* y (+ 4.0 (* z -6.0)))
   (* x (+ -3.0 (* z 6.0)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.2e-11) || !(y <= 2.46e+61)) {
		tmp = y * (4.0 + (z * -6.0));
	} else {
		tmp = x * (-3.0 + (z * 6.0));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-3.2d-11)) .or. (.not. (y <= 2.46d+61))) then
        tmp = y * (4.0d0 + (z * (-6.0d0)))
    else
        tmp = x * ((-3.0d0) + (z * 6.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.2e-11) || !(y <= 2.46e+61)) {
		tmp = y * (4.0 + (z * -6.0));
	} else {
		tmp = x * (-3.0 + (z * 6.0));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -3.2e-11) or not (y <= 2.46e+61):
		tmp = y * (4.0 + (z * -6.0))
	else:
		tmp = x * (-3.0 + (z * 6.0))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -3.2e-11) || !(y <= 2.46e+61))
		tmp = Float64(y * Float64(4.0 + Float64(z * -6.0)));
	else
		tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -3.2e-11) || ~((y <= 2.46e+61)))
		tmp = y * (4.0 + (z * -6.0));
	else
		tmp = x * (-3.0 + (z * 6.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.2e-11], N[Not[LessEqual[y, 2.46e+61]], $MachinePrecision]], N[(y * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-11} \lor \neg \left(y \leq 2.46 \cdot 10^{+61}\right):\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.19999999999999994e-11 or 2.46e61 < y

    1. Initial program 99.6%

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

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) + x} \]
      2. associate-*l*99.9%

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

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

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.9%

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

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

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

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

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

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

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

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

    if -3.19999999999999994e-11 < y < 2.46e61

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{1 \cdot x} + -6 \cdot \left(x \cdot \left(0.6666666666666666 - z\right)\right) \]
      2. *-commutative79.4%

        \[\leadsto 1 \cdot x + -6 \cdot \color{blue}{\left(\left(0.6666666666666666 - z\right) \cdot x\right)} \]
      3. associate-*r*79.7%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-6 \cdot \left(0.6666666666666666 - z\right)\right) \cdot x} \]
      4. sub-neg79.7%

        \[\leadsto 1 \cdot x + \left(-6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \cdot x \]
      5. distribute-rgt-in79.6%

        \[\leadsto 1 \cdot x + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)} \cdot x \]
      6. metadata-eval79.6%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right) \cdot x \]
      7. neg-mul-179.6%

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

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

        \[\leadsto 1 \cdot x + \left(-4 + -1 \cdot \color{blue}{\left(-6 \cdot z\right)}\right) \cdot x \]
      10. metadata-eval79.6%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-1 \cdot 4} + -1 \cdot \left(-6 \cdot z\right)\right) \cdot x \]
      11. distribute-lft-in79.6%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(4 + -6 \cdot z\right)\right)} \cdot x \]
      12. distribute-rgt-in79.7%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
      13. distribute-lft-in79.7%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-1 \cdot 4 + -1 \cdot \left(-6 \cdot z\right)\right)}\right) \]
      14. metadata-eval79.7%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + -1 \cdot \left(-6 \cdot z\right)\right)\right) \]
      15. associate-+r+79.7%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + -1 \cdot \left(-6 \cdot z\right)\right)} \]
      16. metadata-eval79.7%

        \[\leadsto x \cdot \left(\color{blue}{-3} + -1 \cdot \left(-6 \cdot z\right)\right) \]
      17. associate-*r*79.7%

        \[\leadsto x \cdot \left(-3 + \color{blue}{\left(-1 \cdot -6\right) \cdot z}\right) \]
      18. metadata-eval79.7%

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

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

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

Alternative 5: 50.2% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x \cdot -3\\


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot x + -6 \cdot \color{blue}{\left(\left(0.6666666666666666 - z\right) \cdot x\right)} \]
      3. associate-*r*61.3%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-6 \cdot \left(0.6666666666666666 - z\right)\right) \cdot x} \]
      4. sub-neg61.3%

        \[\leadsto 1 \cdot x + \left(-6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \cdot x \]
      5. distribute-rgt-in61.3%

        \[\leadsto 1 \cdot x + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)} \cdot x \]
      6. metadata-eval61.3%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right) \cdot x \]
      7. neg-mul-161.3%

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

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

        \[\leadsto 1 \cdot x + \left(-4 + -1 \cdot \color{blue}{\left(-6 \cdot z\right)}\right) \cdot x \]
      10. metadata-eval61.3%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-1 \cdot 4} + -1 \cdot \left(-6 \cdot z\right)\right) \cdot x \]
      11. distribute-lft-in61.3%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(4 + -6 \cdot z\right)\right)} \cdot x \]
      12. distribute-rgt-in61.3%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
      13. distribute-lft-in61.3%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-1 \cdot 4 + -1 \cdot \left(-6 \cdot z\right)\right)}\right) \]
      14. metadata-eval61.3%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + -1 \cdot \left(-6 \cdot z\right)\right)\right) \]
      15. associate-+r+61.3%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + -1 \cdot \left(-6 \cdot z\right)\right)} \]
      16. metadata-eval61.3%

        \[\leadsto x \cdot \left(\color{blue}{-3} + -1 \cdot \left(-6 \cdot z\right)\right) \]
      17. associate-*r*61.3%

        \[\leadsto x \cdot \left(-3 + \color{blue}{\left(-1 \cdot -6\right) \cdot z}\right) \]
      18. metadata-eval61.3%

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

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

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

    if -0.5 < z < 12800

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.4%

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

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

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

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

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

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

        \[\leadsto \color{blue}{1 \cdot x} + -6 \cdot \left(x \cdot \left(0.6666666666666666 - z\right)\right) \]
      2. *-commutative52.0%

        \[\leadsto 1 \cdot x + -6 \cdot \color{blue}{\left(\left(0.6666666666666666 - z\right) \cdot x\right)} \]
      3. associate-*r*52.2%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-6 \cdot \left(0.6666666666666666 - z\right)\right) \cdot x} \]
      4. sub-neg52.2%

        \[\leadsto 1 \cdot x + \left(-6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \cdot x \]
      5. distribute-rgt-in52.2%

        \[\leadsto 1 \cdot x + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)} \cdot x \]
      6. metadata-eval52.2%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right) \cdot x \]
      7. neg-mul-152.2%

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

        \[\leadsto 1 \cdot x + \left(-4 + \color{blue}{-1 \cdot \left(z \cdot -6\right)}\right) \cdot x \]
      9. *-commutative52.2%

        \[\leadsto 1 \cdot x + \left(-4 + -1 \cdot \color{blue}{\left(-6 \cdot z\right)}\right) \cdot x \]
      10. metadata-eval52.2%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-1 \cdot 4} + -1 \cdot \left(-6 \cdot z\right)\right) \cdot x \]
      11. distribute-lft-in52.2%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(4 + -6 \cdot z\right)\right)} \cdot x \]
      12. distribute-rgt-in52.2%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
      13. distribute-lft-in52.2%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-1 \cdot 4 + -1 \cdot \left(-6 \cdot z\right)\right)}\right) \]
      14. metadata-eval52.2%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + -1 \cdot \left(-6 \cdot z\right)\right)\right) \]
      15. associate-+r+52.3%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + -1 \cdot \left(-6 \cdot z\right)\right)} \]
      16. metadata-eval52.3%

        \[\leadsto x \cdot \left(\color{blue}{-3} + -1 \cdot \left(-6 \cdot z\right)\right) \]
      17. associate-*r*52.3%

        \[\leadsto x \cdot \left(-3 + \color{blue}{\left(-1 \cdot -6\right) \cdot z}\right) \]
      18. metadata-eval52.3%

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

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

      \[\leadsto \color{blue}{-3 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative50.2%

        \[\leadsto \color{blue}{x \cdot -3} \]
    10. Simplified50.2%

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

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

Alternative 6: 50.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.5:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 12800:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -0.5)
   (* 6.0 (* x z))
   (if (<= z 12800.0) (* x -3.0) (* x (* z 6.0)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.5) {
		tmp = 6.0 * (x * z);
	} else if (z <= 12800.0) {
		tmp = x * -3.0;
	} else {
		tmp = x * (z * 6.0);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-0.5d0)) then
        tmp = 6.0d0 * (x * z)
    else if (z <= 12800.0d0) then
        tmp = x * (-3.0d0)
    else
        tmp = x * (z * 6.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.5) {
		tmp = 6.0 * (x * z);
	} else if (z <= 12800.0) {
		tmp = x * -3.0;
	} else {
		tmp = x * (z * 6.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -0.5:
		tmp = 6.0 * (x * z)
	elif z <= 12800.0:
		tmp = x * -3.0
	else:
		tmp = x * (z * 6.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -0.5)
		tmp = Float64(6.0 * Float64(x * z));
	elseif (z <= 12800.0)
		tmp = Float64(x * -3.0);
	else
		tmp = Float64(x * Float64(z * 6.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -0.5)
		tmp = 6.0 * (x * z);
	elseif (z <= 12800.0)
		tmp = x * -3.0;
	else
		tmp = x * (z * 6.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -0.5], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 12800.0], N[(x * -3.0), $MachinePrecision], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 12800:\\
\;\;\;\;x \cdot -3\\

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot x + -6 \cdot \color{blue}{\left(\left(0.6666666666666666 - z\right) \cdot x\right)} \]
      3. associate-*r*59.7%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-6 \cdot \left(0.6666666666666666 - z\right)\right) \cdot x} \]
      4. sub-neg59.7%

        \[\leadsto 1 \cdot x + \left(-6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \cdot x \]
      5. distribute-rgt-in59.7%

        \[\leadsto 1 \cdot x + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)} \cdot x \]
      6. metadata-eval59.7%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right) \cdot x \]
      7. neg-mul-159.7%

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

        \[\leadsto 1 \cdot x + \left(-4 + \color{blue}{-1 \cdot \left(z \cdot -6\right)}\right) \cdot x \]
      9. *-commutative59.7%

        \[\leadsto 1 \cdot x + \left(-4 + -1 \cdot \color{blue}{\left(-6 \cdot z\right)}\right) \cdot x \]
      10. metadata-eval59.7%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-1 \cdot 4} + -1 \cdot \left(-6 \cdot z\right)\right) \cdot x \]
      11. distribute-lft-in59.7%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(4 + -6 \cdot z\right)\right)} \cdot x \]
      12. distribute-rgt-in59.7%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
      13. distribute-lft-in59.7%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-1 \cdot 4 + -1 \cdot \left(-6 \cdot z\right)\right)}\right) \]
      14. metadata-eval59.7%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + -1 \cdot \left(-6 \cdot z\right)\right)\right) \]
      15. associate-+r+59.7%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + -1 \cdot \left(-6 \cdot z\right)\right)} \]
      16. metadata-eval59.7%

        \[\leadsto x \cdot \left(\color{blue}{-3} + -1 \cdot \left(-6 \cdot z\right)\right) \]
      17. associate-*r*59.7%

        \[\leadsto x \cdot \left(-3 + \color{blue}{\left(-1 \cdot -6\right) \cdot z}\right) \]
      18. metadata-eval59.7%

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

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

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

    if -0.5 < z < 12800

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.4%

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

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

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

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

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

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

        \[\leadsto \color{blue}{1 \cdot x} + -6 \cdot \left(x \cdot \left(0.6666666666666666 - z\right)\right) \]
      2. *-commutative52.0%

        \[\leadsto 1 \cdot x + -6 \cdot \color{blue}{\left(\left(0.6666666666666666 - z\right) \cdot x\right)} \]
      3. associate-*r*52.2%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-6 \cdot \left(0.6666666666666666 - z\right)\right) \cdot x} \]
      4. sub-neg52.2%

        \[\leadsto 1 \cdot x + \left(-6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \cdot x \]
      5. distribute-rgt-in52.2%

        \[\leadsto 1 \cdot x + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)} \cdot x \]
      6. metadata-eval52.2%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right) \cdot x \]
      7. neg-mul-152.2%

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

        \[\leadsto 1 \cdot x + \left(-4 + \color{blue}{-1 \cdot \left(z \cdot -6\right)}\right) \cdot x \]
      9. *-commutative52.2%

        \[\leadsto 1 \cdot x + \left(-4 + -1 \cdot \color{blue}{\left(-6 \cdot z\right)}\right) \cdot x \]
      10. metadata-eval52.2%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-1 \cdot 4} + -1 \cdot \left(-6 \cdot z\right)\right) \cdot x \]
      11. distribute-lft-in52.2%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(4 + -6 \cdot z\right)\right)} \cdot x \]
      12. distribute-rgt-in52.2%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
      13. distribute-lft-in52.2%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-1 \cdot 4 + -1 \cdot \left(-6 \cdot z\right)\right)}\right) \]
      14. metadata-eval52.2%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + -1 \cdot \left(-6 \cdot z\right)\right)\right) \]
      15. associate-+r+52.3%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + -1 \cdot \left(-6 \cdot z\right)\right)} \]
      16. metadata-eval52.3%

        \[\leadsto x \cdot \left(\color{blue}{-3} + -1 \cdot \left(-6 \cdot z\right)\right) \]
      17. associate-*r*52.3%

        \[\leadsto x \cdot \left(-3 + \color{blue}{\left(-1 \cdot -6\right) \cdot z}\right) \]
      18. metadata-eval52.3%

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

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

      \[\leadsto \color{blue}{-3 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative50.2%

        \[\leadsto \color{blue}{x \cdot -3} \]
    10. Simplified50.2%

      \[\leadsto \color{blue}{x \cdot -3} \]

    if 12800 < z

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot x + -6 \cdot \color{blue}{\left(\left(0.6666666666666666 - z\right) \cdot x\right)} \]
      3. associate-*r*62.8%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-6 \cdot \left(0.6666666666666666 - z\right)\right) \cdot x} \]
      4. sub-neg62.8%

        \[\leadsto 1 \cdot x + \left(-6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \cdot x \]
      5. distribute-rgt-in62.8%

        \[\leadsto 1 \cdot x + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)} \cdot x \]
      6. metadata-eval62.8%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right) \cdot x \]
      7. neg-mul-162.8%

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

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

        \[\leadsto 1 \cdot x + \left(-4 + -1 \cdot \color{blue}{\left(-6 \cdot z\right)}\right) \cdot x \]
      10. metadata-eval62.8%

        \[\leadsto 1 \cdot x + \left(\color{blue}{-1 \cdot 4} + -1 \cdot \left(-6 \cdot z\right)\right) \cdot x \]
      11. distribute-lft-in62.8%

        \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(4 + -6 \cdot z\right)\right)} \cdot x \]
      12. distribute-rgt-in62.8%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
      13. distribute-lft-in62.8%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-1 \cdot 4 + -1 \cdot \left(-6 \cdot z\right)\right)}\right) \]
      14. metadata-eval62.8%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + -1 \cdot \left(-6 \cdot z\right)\right)\right) \]
      15. associate-+r+62.8%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + -1 \cdot \left(-6 \cdot z\right)\right)} \]
      16. metadata-eval62.8%

        \[\leadsto x \cdot \left(\color{blue}{-3} + -1 \cdot \left(-6 \cdot z\right)\right) \]
      17. associate-*r*62.8%

        \[\leadsto x \cdot \left(-3 + \color{blue}{\left(-1 \cdot -6\right) \cdot z}\right) \]
      18. metadata-eval62.8%

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

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

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

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

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

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

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

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

Alternative 7: 99.8% accurate, 1.2× speedup?

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

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. +-commutative99.5%

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine99.8%

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

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

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

Alternative 8: 99.5% accurate, 1.2× speedup?

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

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. metadata-eval99.5%

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

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

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

Alternative 9: 51.3% accurate, 1.9× speedup?

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

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. +-commutative99.5%

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot x} + -6 \cdot \left(x \cdot \left(0.6666666666666666 - z\right)\right) \]
    2. *-commutative56.5%

      \[\leadsto 1 \cdot x + -6 \cdot \color{blue}{\left(\left(0.6666666666666666 - z\right) \cdot x\right)} \]
    3. associate-*r*56.7%

      \[\leadsto 1 \cdot x + \color{blue}{\left(-6 \cdot \left(0.6666666666666666 - z\right)\right) \cdot x} \]
    4. sub-neg56.7%

      \[\leadsto 1 \cdot x + \left(-6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \cdot x \]
    5. distribute-rgt-in56.7%

      \[\leadsto 1 \cdot x + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)} \cdot x \]
    6. metadata-eval56.7%

      \[\leadsto 1 \cdot x + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right) \cdot x \]
    7. neg-mul-156.7%

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

      \[\leadsto 1 \cdot x + \left(-4 + \color{blue}{-1 \cdot \left(z \cdot -6\right)}\right) \cdot x \]
    9. *-commutative56.7%

      \[\leadsto 1 \cdot x + \left(-4 + -1 \cdot \color{blue}{\left(-6 \cdot z\right)}\right) \cdot x \]
    10. metadata-eval56.7%

      \[\leadsto 1 \cdot x + \left(\color{blue}{-1 \cdot 4} + -1 \cdot \left(-6 \cdot z\right)\right) \cdot x \]
    11. distribute-lft-in56.7%

      \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(4 + -6 \cdot z\right)\right)} \cdot x \]
    12. distribute-rgt-in56.7%

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
    13. distribute-lft-in56.7%

      \[\leadsto x \cdot \left(1 + \color{blue}{\left(-1 \cdot 4 + -1 \cdot \left(-6 \cdot z\right)\right)}\right) \]
    14. metadata-eval56.7%

      \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + -1 \cdot \left(-6 \cdot z\right)\right)\right) \]
    15. associate-+r+56.7%

      \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + -1 \cdot \left(-6 \cdot z\right)\right)} \]
    16. metadata-eval56.7%

      \[\leadsto x \cdot \left(\color{blue}{-3} + -1 \cdot \left(-6 \cdot z\right)\right) \]
    17. associate-*r*56.7%

      \[\leadsto x \cdot \left(-3 + \color{blue}{\left(-1 \cdot -6\right) \cdot z}\right) \]
    18. metadata-eval56.7%

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

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

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

Alternative 10: 26.1% accurate, 4.3× speedup?

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

\\
x \cdot -3
\end{array}
Derivation
  1. Initial program 99.5%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. +-commutative99.5%

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot x} + -6 \cdot \left(x \cdot \left(0.6666666666666666 - z\right)\right) \]
    2. *-commutative56.5%

      \[\leadsto 1 \cdot x + -6 \cdot \color{blue}{\left(\left(0.6666666666666666 - z\right) \cdot x\right)} \]
    3. associate-*r*56.7%

      \[\leadsto 1 \cdot x + \color{blue}{\left(-6 \cdot \left(0.6666666666666666 - z\right)\right) \cdot x} \]
    4. sub-neg56.7%

      \[\leadsto 1 \cdot x + \left(-6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \cdot x \]
    5. distribute-rgt-in56.7%

      \[\leadsto 1 \cdot x + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)} \cdot x \]
    6. metadata-eval56.7%

      \[\leadsto 1 \cdot x + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right) \cdot x \]
    7. neg-mul-156.7%

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

      \[\leadsto 1 \cdot x + \left(-4 + \color{blue}{-1 \cdot \left(z \cdot -6\right)}\right) \cdot x \]
    9. *-commutative56.7%

      \[\leadsto 1 \cdot x + \left(-4 + -1 \cdot \color{blue}{\left(-6 \cdot z\right)}\right) \cdot x \]
    10. metadata-eval56.7%

      \[\leadsto 1 \cdot x + \left(\color{blue}{-1 \cdot 4} + -1 \cdot \left(-6 \cdot z\right)\right) \cdot x \]
    11. distribute-lft-in56.7%

      \[\leadsto 1 \cdot x + \color{blue}{\left(-1 \cdot \left(4 + -6 \cdot z\right)\right)} \cdot x \]
    12. distribute-rgt-in56.7%

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(4 + -6 \cdot z\right)\right)} \]
    13. distribute-lft-in56.7%

      \[\leadsto x \cdot \left(1 + \color{blue}{\left(-1 \cdot 4 + -1 \cdot \left(-6 \cdot z\right)\right)}\right) \]
    14. metadata-eval56.7%

      \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + -1 \cdot \left(-6 \cdot z\right)\right)\right) \]
    15. associate-+r+56.7%

      \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + -1 \cdot \left(-6 \cdot z\right)\right)} \]
    16. metadata-eval56.7%

      \[\leadsto x \cdot \left(\color{blue}{-3} + -1 \cdot \left(-6 \cdot z\right)\right) \]
    17. associate-*r*56.7%

      \[\leadsto x \cdot \left(-3 + \color{blue}{\left(-1 \cdot -6\right) \cdot z}\right) \]
    18. metadata-eval56.7%

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

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

    \[\leadsto \color{blue}{-3 \cdot x} \]
  9. Step-by-step derivation
    1. *-commutative26.8%

      \[\leadsto \color{blue}{x \cdot -3} \]
  10. Simplified26.8%

    \[\leadsto \color{blue}{x \cdot -3} \]
  11. Add Preprocessing

Alternative 11: 2.6% accurate, 13.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.5%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. metadata-eval99.5%

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

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

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

    \[\leadsto x + \left(-6 \cdot x\right) \cdot \color{blue}{\left(-1 \cdot z\right)} \]
  7. Step-by-step derivation
    1. neg-mul-131.1%

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

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

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

Reproduce

?
herbie shell --seed 2024131 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
  :precision binary64
  (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))