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

Percentage Accurate: 99.5% → 99.5%
Time: 17.3s
Alternatives: 14
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 14 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.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

Alternative 2: 74.0% accurate, 0.6× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \left(-\left(-6 \cdot x + \color{blue}{\left(--6\right)} \cdot y\right)\right) \]
      4. cancel-sign-sub-inv99.4%

        \[\leadsto z \cdot \left(-\color{blue}{\left(-6 \cdot x - -6 \cdot y\right)}\right) \]
      5. distribute-lft-out--99.4%

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

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

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

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

    if -66000 < z < -4.7e-163

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.7e-163 < z < 235000

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

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

Alternative 3: 50.4% accurate, 0.6× speedup?

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

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

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

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

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


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

    1. Initial program 99.7%

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

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 91.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 z around inf 99.4%

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

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

    if -0.025000000000000001 < z < -1.6499999999999999e-165

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6499999999999999e-165 < z < 0.650000000000000022

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      5. neg-mul-159.4%

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

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

        \[\leadsto y \cdot \left(\color{blue}{4} + 6 \cdot \left(-1 \cdot z\right)\right) \]
      8. neg-mul-159.4%

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

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6 \cdot z\right)}\right) \]
      10. distribute-lft-neg-in59.4%

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6\right) \cdot z}\right) \]
      11. metadata-eval59.4%

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

        \[\leadsto y \cdot \color{blue}{\left(-6 \cdot z + 4\right)} \]
      13. *-commutative59.4%

        \[\leadsto y \cdot \left(\color{blue}{z \cdot -6} + 4\right) \]
      14. fma-define59.4%

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

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(z, -6, 4\right)} \]
    9. Taylor expanded in z around 0 58.2%

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

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

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

    if 0.650000000000000022 < z

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.025:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-165}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.65:\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 50.4% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;z \leq -2.1 \cdot 10^{-163}:\\
\;\;\;\;x \cdot -3\\

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

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


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

    1. Initial program 99.7%

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

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 91.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 z around inf 99.4%

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

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

    if -9.5 < z < -2.09999999999999998e-163

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.09999999999999998e-163 < z < 0.660000000000000031

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      5. neg-mul-159.4%

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

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

        \[\leadsto y \cdot \left(\color{blue}{4} + 6 \cdot \left(-1 \cdot z\right)\right) \]
      8. neg-mul-159.4%

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

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6 \cdot z\right)}\right) \]
      10. distribute-lft-neg-in59.4%

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6\right) \cdot z}\right) \]
      11. metadata-eval59.4%

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

        \[\leadsto y \cdot \color{blue}{\left(-6 \cdot z + 4\right)} \]
      13. *-commutative59.4%

        \[\leadsto y \cdot \left(\color{blue}{z \cdot -6} + 4\right) \]
      14. fma-define59.4%

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

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(z, -6, 4\right)} \]
    9. Taylor expanded in z around 0 58.2%

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

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

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

    if 0.660000000000000031 < z

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 50.4% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;z \leq -2.7 \cdot 10^{-163}:\\
\;\;\;\;x \cdot -3\\

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

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


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

    1. Initial program 99.7%

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

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 91.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 z around inf 99.4%

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

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

    if -6.79999999999999982 < z < -2.70000000000000015e-163

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.70000000000000015e-163 < z < 0.52000000000000002

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      5. neg-mul-159.4%

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

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

        \[\leadsto y \cdot \left(\color{blue}{4} + 6 \cdot \left(-1 \cdot z\right)\right) \]
      8. neg-mul-159.4%

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

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6 \cdot z\right)}\right) \]
      10. distribute-lft-neg-in59.4%

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6\right) \cdot z}\right) \]
      11. metadata-eval59.4%

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

        \[\leadsto y \cdot \color{blue}{\left(-6 \cdot z + 4\right)} \]
      13. *-commutative59.4%

        \[\leadsto y \cdot \left(\color{blue}{z \cdot -6} + 4\right) \]
      14. fma-define59.4%

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

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(z, -6, 4\right)} \]
    9. Taylor expanded in z around 0 58.2%

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

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

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

    if 0.52000000000000002 < z

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 50.6% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;z \leq -8.2 \cdot 10^{-165}:\\
\;\;\;\;x \cdot -3\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -0.116000000000000006 or 6.4e10 < z

    1. Initial program 99.8%

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

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

      \[\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 x around 0 95.6%

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

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

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

    if -0.116000000000000006 < z < -8.2000000000000004e-165

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.2000000000000004e-165 < z < 6.4e10

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      5. neg-mul-158.7%

        \[\leadsto y \cdot \left(6 \cdot \left(0.6666666666666666 + \color{blue}{-1 \cdot z}\right)\right) \]
      6. distribute-lft-in58.7%

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

        \[\leadsto y \cdot \left(\color{blue}{4} + 6 \cdot \left(-1 \cdot z\right)\right) \]
      8. neg-mul-158.7%

        \[\leadsto y \cdot \left(4 + 6 \cdot \color{blue}{\left(-z\right)}\right) \]
      9. distribute-rgt-neg-in58.7%

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6 \cdot z\right)}\right) \]
      10. distribute-lft-neg-in58.7%

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6\right) \cdot z}\right) \]
      11. metadata-eval58.7%

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

        \[\leadsto y \cdot \color{blue}{\left(-6 \cdot z + 4\right)} \]
      13. *-commutative58.7%

        \[\leadsto y \cdot \left(\color{blue}{z \cdot -6} + 4\right) \]
      14. fma-define58.7%

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

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(z, -6, 4\right)} \]
    9. Taylor expanded in z around 0 57.5%

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

        \[\leadsto \color{blue}{y \cdot 4} \]
    11. Simplified57.5%

      \[\leadsto \color{blue}{y \cdot 4} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 97.8% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \left(-\left(-6 \cdot x + \color{blue}{\left(--6\right)} \cdot y\right)\right) \]
      4. cancel-sign-sub-inv99.4%

        \[\leadsto z \cdot \left(-\color{blue}{\left(-6 \cdot x - -6 \cdot y\right)}\right) \]
      5. distribute-lft-out--99.4%

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

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

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

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

    if -0.599999999999999978 < z < 0.56000000000000005

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

      \[\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.5%

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

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

Alternative 8: 97.8% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \left(-\left(-6 \cdot x + \color{blue}{\left(--6\right)} \cdot y\right)\right) \]
      4. cancel-sign-sub-inv99.4%

        \[\leadsto z \cdot \left(-\color{blue}{\left(-6 \cdot x - -6 \cdot y\right)}\right) \]
      5. distribute-lft-out--99.4%

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

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

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

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

    if -0.56000000000000005 < z < 0.56000000000000005

    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 0 98.5%

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

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

Alternative 9: 75.6% accurate, 0.8× speedup?

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

    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 0 74.4%

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

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

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

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

        \[\leadsto 1 \cdot x + -1 \cdot \left(\left(\color{blue}{z \cdot -6} + 4\right) \cdot x\right) \]
      5. fma-define74.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.5e17 < x < 2.75000000000000003e-73

    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. metadata-eval99.6%

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

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

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

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

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

Alternative 10: 97.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 0.65:\\
\;\;\;\;x \cdot -3 + y \cdot 4\\

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


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

    1. Initial program 99.7%

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

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 91.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 z around inf 99.4%

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

    if -0.599999999999999978 < z < 0.650000000000000022

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

      \[\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.5%

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

    if 0.650000000000000022 < z

    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. metadata-eval99.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(-6 \cdot x + 6 \cdot y\right)\right)} \]
    9. Step-by-step derivation
      1. mul-1-neg99.5%

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

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

        \[\leadsto z \cdot \left(-\left(-6 \cdot x + \color{blue}{\left(--6\right)} \cdot y\right)\right) \]
      4. cancel-sign-sub-inv99.5%

        \[\leadsto z \cdot \left(-\color{blue}{\left(-6 \cdot x - -6 \cdot y\right)}\right) \]
      5. distribute-lft-out--99.5%

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

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

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

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

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

Alternative 11: 59.6% accurate, 0.8× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.6e21 < x < 4.00000000000000012e83

    1. Initial program 99.5%

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

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

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

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

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

    if 4.00000000000000012e83 < x

    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 0 76.3%

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

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

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

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

        \[\leadsto 1 \cdot x + -1 \cdot \left(\left(\color{blue}{z \cdot -6} + 4\right) \cdot x\right) \]
      5. fma-define76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 34.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.04 \cdot 10^{-109} \lor \neg \left(x \leq 3.7 \cdot 10^{+219}\right):\\
\;\;\;\;x \cdot -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.03999999999999996e-109 or 3.7e219 < x

    1. Initial program 99.8%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. 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 0 74.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.03999999999999996e-109 < x < 3.7e219

    1. Initial program 99.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
      4. sub-neg68.4%

        \[\leadsto y \cdot \left(6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      5. neg-mul-168.4%

        \[\leadsto y \cdot \left(6 \cdot \left(0.6666666666666666 + \color{blue}{-1 \cdot z}\right)\right) \]
      6. distribute-lft-in68.4%

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

        \[\leadsto y \cdot \left(\color{blue}{4} + 6 \cdot \left(-1 \cdot z\right)\right) \]
      8. neg-mul-168.4%

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

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6 \cdot z\right)}\right) \]
      10. distribute-lft-neg-in68.4%

        \[\leadsto y \cdot \left(4 + \color{blue}{\left(-6\right) \cdot z}\right) \]
      11. metadata-eval68.4%

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

        \[\leadsto y \cdot \color{blue}{\left(-6 \cdot z + 4\right)} \]
      13. *-commutative68.4%

        \[\leadsto y \cdot \left(\color{blue}{z \cdot -6} + 4\right) \]
      14. fma-define68.3%

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

      \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(z, -6, 4\right)} \]
    9. Taylor expanded in z around 0 37.5%

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

        \[\leadsto \color{blue}{y \cdot 4} \]
    11. Simplified37.5%

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

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

Alternative 13: 99.5% accurate, 1.2× speedup?

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

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

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

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

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

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

Alternative 14: 26.4% 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.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.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot x + -1 \cdot \left(\left(\color{blue}{z \cdot -6} + 4\right) \cdot x\right) \]
    5. fma-define50.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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