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

Percentage Accurate: 99.5% → 99.8%
Time: 14.4s
Alternatives: 17
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 17 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, \mathsf{fma}\left(z, -6, 4\right), x\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (- y x) (fma z -6.0 4.0) x))
double code(double x, double y, double z) {
	return fma((y - x), fma(z, -6.0, 4.0), x);
}
function code(x, y, z)
	return fma(Float64(y - x), fma(z, -6.0, 4.0), x)
end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(z * -6.0 + 4.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), 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. +-commutative99.8%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 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 3: 97.7% accurate, 0.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;y \cdot 4 + x \cdot -3\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.56000000000000005 or 0.599999999999999978 < 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 x around 0 95.2%

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

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

    if -0.56000000000000005 < z < 0.599999999999999978

    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.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 x around 0 99.4%

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

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

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

Alternative 4: 75.3% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.5e13 or 2.7499999999999999e47 < x

    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.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 85.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.5e13 < x < 2.7499999999999999e47

    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. Taylor expanded in y around inf 75.1%

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

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

Alternative 5: 75.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{+14} \lor \neg \left(x \leq 1.45 \cdot 10^{+49}\right):\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.4e14 or 1.45e49 < x

    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.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 85.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.4e14 < x < 1.45e49

    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 x around 0 99.4%

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
    8. Simplified75.1%

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

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

Alternative 6: 75.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -29500000000000 \lor \neg \left(x \leq 10800\right):\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.95e13 or 10800 < x

    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.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.95e13 < x < 10800

    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.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 x around 0 99.5%

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

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

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

Alternative 7: 74.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 1.08 \cdot 10^{-8}:\\
\;\;\;\;y \cdot 4 + x \cdot -3\\

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


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

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

        \[\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 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.60000000000000004e-15 < z < 1.0800000000000001e-8

    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.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 x around 0 99.4%

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

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

    if 1.0800000000000001e-8 < 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. 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. Taylor expanded in y around inf 55.9%

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

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

Alternative 8: 74.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 2.9 \cdot 10^{-8}:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\

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


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

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

        \[\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 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.60000000000000004e-15 < z < 2.9000000000000002e-8

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

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

    if 2.9000000000000002e-8 < 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. 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. Taylor expanded in y around inf 55.9%

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

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

Alternative 9: 58.4% accurate, 0.8× speedup?

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

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

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

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


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

    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.8%

        \[\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 87.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.85e12 < x < 1.06000000000000006e150

    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 x around 0 98.9%

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

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

    if 1.06000000000000006e150 < x

    1. Initial program 99.9%

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

        \[\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 92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 50.6% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;y \cdot 4\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.69999999999999996 or 0.55000000000000004 < 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.8%

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

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

        \[\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 60.7%

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

    if -0.69999999999999996 < z < 0.55000000000000004

    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.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. Taylor expanded in y around inf 60.3%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    7. Step-by-step derivation
      1. *-commutative58.4%

        \[\leadsto \color{blue}{y \cdot 4} \]
    8. Simplified58.4%

      \[\leadsto \color{blue}{y \cdot 4} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.6%

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

Alternative 11: 50.4% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;z \leq 0.66:\\
\;\;\;\;y \cdot 4\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.340000000000000024 < z < 0.660000000000000031

    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.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. Taylor expanded in y around inf 60.3%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    7. Step-by-step derivation
      1. *-commutative58.4%

        \[\leadsto \color{blue}{y \cdot 4} \]
    8. Simplified58.4%

      \[\leadsto \color{blue}{y \cdot 4} \]

    if 0.660000000000000031 < 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. 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. Taylor expanded in y around inf 54.7%

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

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

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

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

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

Alternative 12: 50.6% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;z \leq 0.62:\\
\;\;\;\;y \cdot 4\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0115 < z < 0.619999999999999996

    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.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. Taylor expanded in y around inf 60.3%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    7. Step-by-step derivation
      1. *-commutative58.4%

        \[\leadsto \color{blue}{y \cdot 4} \]
    8. Simplified58.4%

      \[\leadsto \color{blue}{y \cdot 4} \]

    if 0.619999999999999996 < 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 53.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 37.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+20} \lor \neg \left(x \leq 4.8 \cdot 10^{+47}\right):\\
\;\;\;\;x \cdot -3\\

\mathbf{else}:\\
\;\;\;\;y \cdot 4\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9e20 or 4.80000000000000037e47 < x

    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.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 85.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9e20 < x < 4.80000000000000037e47

    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. Taylor expanded in y around inf 74.7%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    7. Step-by-step derivation
      1. *-commutative43.4%

        \[\leadsto \color{blue}{y \cdot 4} \]
    8. Simplified43.4%

      \[\leadsto \color{blue}{y \cdot 4} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{+20} \lor \neg \left(x \leq 4.8 \cdot 10^{+47}\right):\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 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 15: 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 16: 26.0% 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 51.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot -3} \]
  10. Simplified20.5%

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

Alternative 17: 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 z around inf 52.0%

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

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

Reproduce

?
herbie shell --seed 2024146 
(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))))