Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I

Percentage Accurate: 96.3% → 99.6%
Time: 5.7s
Alternatives: 6
Speedup: 0.8×

Specification

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

\\
x \cdot \left(1 - y \cdot 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 6 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: 96.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot y \leq -\infty \lor \neg \left(z \cdot y \leq 5 \cdot 10^{+161}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \left(z \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* z y) (- INFINITY)) (not (<= (* z y) 5e+161)))
   (* z (* y (- x)))
   (- x (* x (* z y)))))
double code(double x, double y, double z) {
	double tmp;
	if (((z * y) <= -((double) INFINITY)) || !((z * y) <= 5e+161)) {
		tmp = z * (y * -x);
	} else {
		tmp = x - (x * (z * y));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (((z * y) <= -Double.POSITIVE_INFINITY) || !((z * y) <= 5e+161)) {
		tmp = z * (y * -x);
	} else {
		tmp = x - (x * (z * y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if ((z * y) <= -math.inf) or not ((z * y) <= 5e+161):
		tmp = z * (y * -x)
	else:
		tmp = x - (x * (z * y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((Float64(z * y) <= Float64(-Inf)) || !(Float64(z * y) <= 5e+161))
		tmp = Float64(z * Float64(y * Float64(-x)));
	else
		tmp = Float64(x - Float64(x * Float64(z * y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((z * y) <= -Inf) || ~(((z * y) <= 5e+161)))
		tmp = z * (y * -x);
	else
		tmp = x - (x * (z * y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[N[(z * y), $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[(z * y), $MachinePrecision], 5e+161]], $MachinePrecision]], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \cdot y \leq -\infty \lor \neg \left(z \cdot y \leq 5 \cdot 10^{+161}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y z) < -inf.0 or 4.9999999999999997e161 < (*.f64 y z)

    1. Initial program 74.4%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. flip--12.8%

        \[\leadsto x \cdot \color{blue}{\frac{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}{1 + y \cdot z}} \]
      2. clear-num12.8%

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

        \[\leadsto x \cdot \frac{1}{\frac{\color{blue}{y \cdot z + 1}}{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}} \]
      4. fma-def12.8%

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

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

        \[\leadsto x \cdot \frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - \color{blue}{{\left(y \cdot z\right)}^{2}}}} \]
    3. Applied egg-rr12.8%

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - {\left(y \cdot z\right)}^{2}}}} \]
    4. Taylor expanded in y around inf 74.4%

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

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

        \[\leadsto -\color{blue}{\left(y \cdot z\right) \cdot x} \]
      3. distribute-rgt-neg-in74.4%

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

        \[\leadsto \color{blue}{\left(z \cdot y\right)} \cdot \left(-x\right) \]
      5. associate-*l*99.8%

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

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

    if -inf.0 < (*.f64 y z) < 4.9999999999999997e161

    1. Initial program 99.8%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. remove-double-neg99.8%

        \[\leadsto \color{blue}{-\left(-x \cdot \left(1 - y \cdot z\right)\right)} \]
      2. distribute-lft-neg-out99.8%

        \[\leadsto -\color{blue}{\left(-x\right) \cdot \left(1 - y \cdot z\right)} \]
      3. neg-mul-199.8%

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

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

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

        \[\leadsto \color{blue}{-x \cdot \left(\left(1 - y \cdot z\right) \cdot -1\right)} \]
      7. distribute-rgt-neg-out99.8%

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

        \[\leadsto x \cdot \left(-\color{blue}{-1 \cdot \left(1 - y \cdot z\right)}\right) \]
      9. neg-mul-199.8%

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\left(1 - y \cdot z\right)\right)}\right) \]
      10. remove-double-neg99.8%

        \[\leadsto x \cdot \color{blue}{\left(1 - y \cdot z\right)} \]
      11. cancel-sign-sub-inv99.8%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-x \cdot \left(y \cdot z - 1\right)} \]
      2. distribute-lft-out--99.9%

        \[\leadsto -\color{blue}{\left(x \cdot \left(y \cdot z\right) - x \cdot 1\right)} \]
      3. *-rgt-identity99.9%

        \[\leadsto -\left(x \cdot \left(y \cdot z\right) - \color{blue}{x}\right) \]
      4. unsub-neg99.9%

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

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

        \[\leadsto -\color{blue}{\left(-1 \cdot x + x \cdot \left(y \cdot z\right)\right)} \]
      7. distribute-neg-in99.9%

        \[\leadsto \color{blue}{\left(--1 \cdot x\right) + \left(-x \cdot \left(y \cdot z\right)\right)} \]
      8. unsub-neg99.9%

        \[\leadsto \color{blue}{\left(--1 \cdot x\right) - x \cdot \left(y \cdot z\right)} \]
      9. mul-1-neg99.9%

        \[\leadsto \left(-\color{blue}{\left(-x\right)}\right) - x \cdot \left(y \cdot z\right) \]
      10. remove-double-neg99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot y \leq -\infty \lor \neg \left(z \cdot y \leq 5 \cdot 10^{+161}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot \left(z \cdot y\right)\\ \end{array} \]

Alternative 2: 97.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(z \cdot \left(-y\right)\right)\\ t_1 := z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{if}\;z \cdot y \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot y \leq -400000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \cdot y \leq 0.5:\\ \;\;\;\;x\\ \mathbf{elif}\;z \cdot y \leq 5 \cdot 10^{+161}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (* z (- y)))) (t_1 (* z (* y (- x)))))
   (if (<= (* z y) (- INFINITY))
     t_1
     (if (<= (* z y) -400000.0)
       t_0
       (if (<= (* z y) 0.5) x (if (<= (* z y) 5e+161) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = x * (z * -y);
	double t_1 = z * (y * -x);
	double tmp;
	if ((z * y) <= -((double) INFINITY)) {
		tmp = t_1;
	} else if ((z * y) <= -400000.0) {
		tmp = t_0;
	} else if ((z * y) <= 0.5) {
		tmp = x;
	} else if ((z * y) <= 5e+161) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double t_0 = x * (z * -y);
	double t_1 = z * (y * -x);
	double tmp;
	if ((z * y) <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if ((z * y) <= -400000.0) {
		tmp = t_0;
	} else if ((z * y) <= 0.5) {
		tmp = x;
	} else if ((z * y) <= 5e+161) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (z * -y)
	t_1 = z * (y * -x)
	tmp = 0
	if (z * y) <= -math.inf:
		tmp = t_1
	elif (z * y) <= -400000.0:
		tmp = t_0
	elif (z * y) <= 0.5:
		tmp = x
	elif (z * y) <= 5e+161:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(z * Float64(-y)))
	t_1 = Float64(z * Float64(y * Float64(-x)))
	tmp = 0.0
	if (Float64(z * y) <= Float64(-Inf))
		tmp = t_1;
	elseif (Float64(z * y) <= -400000.0)
		tmp = t_0;
	elseif (Float64(z * y) <= 0.5)
		tmp = x;
	elseif (Float64(z * y) <= 5e+161)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (z * -y);
	t_1 = z * (y * -x);
	tmp = 0.0;
	if ((z * y) <= -Inf)
		tmp = t_1;
	elseif ((z * y) <= -400000.0)
		tmp = t_0;
	elseif ((z * y) <= 0.5)
		tmp = x;
	elseif ((z * y) <= 5e+161)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * (-y)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * y), $MachinePrecision], (-Infinity)], t$95$1, If[LessEqual[N[(z * y), $MachinePrecision], -400000.0], t$95$0, If[LessEqual[N[(z * y), $MachinePrecision], 0.5], x, If[LessEqual[N[(z * y), $MachinePrecision], 5e+161], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \cdot y \leq -400000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \cdot y \leq 0.5:\\
\;\;\;\;x\\

\mathbf{elif}\;z \cdot y \leq 5 \cdot 10^{+161}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 y z) < -inf.0 or 4.9999999999999997e161 < (*.f64 y z)

    1. Initial program 74.4%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. flip--12.8%

        \[\leadsto x \cdot \color{blue}{\frac{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}{1 + y \cdot z}} \]
      2. clear-num12.8%

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

        \[\leadsto x \cdot \frac{1}{\frac{\color{blue}{y \cdot z + 1}}{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}} \]
      4. fma-def12.8%

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

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

        \[\leadsto x \cdot \frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - \color{blue}{{\left(y \cdot z\right)}^{2}}}} \]
    3. Applied egg-rr12.8%

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - {\left(y \cdot z\right)}^{2}}}} \]
    4. Taylor expanded in y around inf 74.4%

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

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

        \[\leadsto -\color{blue}{\left(y \cdot z\right) \cdot x} \]
      3. distribute-rgt-neg-in74.4%

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

        \[\leadsto \color{blue}{\left(z \cdot y\right)} \cdot \left(-x\right) \]
      5. associate-*l*99.8%

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

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

    if -inf.0 < (*.f64 y z) < -4e5 or 0.5 < (*.f64 y z) < 4.9999999999999997e161

    1. Initial program 99.7%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. remove-double-neg99.7%

        \[\leadsto \color{blue}{-\left(-x \cdot \left(1 - y \cdot z\right)\right)} \]
      2. distribute-lft-neg-out99.7%

        \[\leadsto -\color{blue}{\left(-x\right) \cdot \left(1 - y \cdot z\right)} \]
      3. neg-mul-199.7%

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

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

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

        \[\leadsto \color{blue}{-x \cdot \left(\left(1 - y \cdot z\right) \cdot -1\right)} \]
      7. distribute-rgt-neg-out99.7%

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

        \[\leadsto x \cdot \left(-\color{blue}{-1 \cdot \left(1 - y \cdot z\right)}\right) \]
      9. neg-mul-199.7%

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\left(1 - y \cdot z\right)\right)}\right) \]
      10. remove-double-neg99.7%

        \[\leadsto x \cdot \color{blue}{\left(1 - y \cdot z\right)} \]
      11. cancel-sign-sub-inv99.7%

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

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

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

        \[\leadsto x \cdot \left(\left(-y \cdot z\right) + \color{blue}{\left(--1\right)}\right) \]
      15. distribute-neg-in99.7%

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

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

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

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

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

        \[\leadsto -\color{blue}{\left(y \cdot z\right) \cdot x} \]
      3. distribute-rgt-neg-in96.2%

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

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

    if -4e5 < (*.f64 y z) < 0.5

    1. Initial program 100.0%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

        \[\leadsto \color{blue}{-\left(-x \cdot \left(1 - y \cdot z\right)\right)} \]
      2. distribute-lft-neg-out100.0%

        \[\leadsto -\color{blue}{\left(-x\right) \cdot \left(1 - y \cdot z\right)} \]
      3. neg-mul-1100.0%

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

        \[\leadsto \color{blue}{\left(\left(-x\right) \cdot \left(1 - y \cdot z\right)\right) \cdot -1} \]
      5. associate-*r*100.0%

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

        \[\leadsto \color{blue}{-x \cdot \left(\left(1 - y \cdot z\right) \cdot -1\right)} \]
      7. distribute-rgt-neg-out100.0%

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

        \[\leadsto x \cdot \left(-\color{blue}{-1 \cdot \left(1 - y \cdot z\right)}\right) \]
      9. neg-mul-1100.0%

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\left(1 - y \cdot z\right)\right)}\right) \]
      10. remove-double-neg100.0%

        \[\leadsto x \cdot \color{blue}{\left(1 - y \cdot z\right)} \]
      11. cancel-sign-sub-inv100.0%

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

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

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

        \[\leadsto x \cdot \left(\left(-y \cdot z\right) + \color{blue}{\left(--1\right)}\right) \]
      15. distribute-neg-in100.0%

        \[\leadsto x \cdot \color{blue}{\left(-\left(y \cdot z + -1\right)\right)} \]
      16. fma-def100.0%

        \[\leadsto x \cdot \left(-\color{blue}{\mathsf{fma}\left(y, z, -1\right)}\right) \]
    3. Simplified100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot y \leq -\infty:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{elif}\;z \cdot y \leq -400000:\\ \;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\ \mathbf{elif}\;z \cdot y \leq 0.5:\\ \;\;\;\;x\\ \mathbf{elif}\;z \cdot y \leq 5 \cdot 10^{+161}:\\ \;\;\;\;x \cdot \left(z \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \end{array} \]

Alternative 3: 99.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot y \leq -\infty \lor \neg \left(z \cdot y \leq 5 \cdot 10^{+161}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z \cdot y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* z y) (- INFINITY)) (not (<= (* z y) 5e+161)))
   (* z (* y (- x)))
   (* x (- 1.0 (* z y)))))
double code(double x, double y, double z) {
	double tmp;
	if (((z * y) <= -((double) INFINITY)) || !((z * y) <= 5e+161)) {
		tmp = z * (y * -x);
	} else {
		tmp = x * (1.0 - (z * y));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (((z * y) <= -Double.POSITIVE_INFINITY) || !((z * y) <= 5e+161)) {
		tmp = z * (y * -x);
	} else {
		tmp = x * (1.0 - (z * y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if ((z * y) <= -math.inf) or not ((z * y) <= 5e+161):
		tmp = z * (y * -x)
	else:
		tmp = x * (1.0 - (z * y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((Float64(z * y) <= Float64(-Inf)) || !(Float64(z * y) <= 5e+161))
		tmp = Float64(z * Float64(y * Float64(-x)));
	else
		tmp = Float64(x * Float64(1.0 - Float64(z * y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((z * y) <= -Inf) || ~(((z * y) <= 5e+161)))
		tmp = z * (y * -x);
	else
		tmp = x * (1.0 - (z * y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[N[(z * y), $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[(z * y), $MachinePrecision], 5e+161]], $MachinePrecision]], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \cdot y \leq -\infty \lor \neg \left(z \cdot y \leq 5 \cdot 10^{+161}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 y z) < -inf.0 or 4.9999999999999997e161 < (*.f64 y z)

    1. Initial program 74.4%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. flip--12.8%

        \[\leadsto x \cdot \color{blue}{\frac{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}{1 + y \cdot z}} \]
      2. clear-num12.8%

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

        \[\leadsto x \cdot \frac{1}{\frac{\color{blue}{y \cdot z + 1}}{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}} \]
      4. fma-def12.8%

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

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

        \[\leadsto x \cdot \frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - \color{blue}{{\left(y \cdot z\right)}^{2}}}} \]
    3. Applied egg-rr12.8%

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - {\left(y \cdot z\right)}^{2}}}} \]
    4. Taylor expanded in y around inf 74.4%

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

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

        \[\leadsto -\color{blue}{\left(y \cdot z\right) \cdot x} \]
      3. distribute-rgt-neg-in74.4%

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

        \[\leadsto \color{blue}{\left(z \cdot y\right)} \cdot \left(-x\right) \]
      5. associate-*l*99.8%

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

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

    if -inf.0 < (*.f64 y z) < 4.9999999999999997e161

    1. Initial program 99.8%

      \[x \cdot \left(1 - y \cdot z\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot y \leq -\infty \lor \neg \left(z \cdot y \leq 5 \cdot 10^{+161}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z \cdot y\right)\\ \end{array} \]

Alternative 4: 69.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+45} \lor \neg \left(y \leq 1.4 \cdot 10^{-160}\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.9000000000000001e45 or 1.40000000000000008e-160 < y

    1. Initial program 91.1%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. flip--64.4%

        \[\leadsto x \cdot \color{blue}{\frac{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}{1 + y \cdot z}} \]
      2. clear-num64.4%

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

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

        \[\leadsto x \cdot \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(y, z, 1\right)}}{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}} \]
      5. metadata-eval64.4%

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

        \[\leadsto x \cdot \frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - \color{blue}{{\left(y \cdot z\right)}^{2}}}} \]
    3. Applied egg-rr64.4%

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - {\left(y \cdot z\right)}^{2}}}} \]
    4. Taylor expanded in y around inf 62.6%

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

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

        \[\leadsto -\color{blue}{\left(y \cdot z\right) \cdot x} \]
      3. distribute-rgt-neg-in62.6%

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

        \[\leadsto \color{blue}{\left(z \cdot y\right)} \cdot \left(-x\right) \]
      5. associate-*l*64.4%

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

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

    if -1.9000000000000001e45 < y < 1.40000000000000008e-160

    1. Initial program 98.9%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. remove-double-neg98.9%

        \[\leadsto \color{blue}{-\left(-x \cdot \left(1 - y \cdot z\right)\right)} \]
      2. distribute-lft-neg-out98.9%

        \[\leadsto -\color{blue}{\left(-x\right) \cdot \left(1 - y \cdot z\right)} \]
      3. neg-mul-198.9%

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

        \[\leadsto \color{blue}{\left(\left(-x\right) \cdot \left(1 - y \cdot z\right)\right) \cdot -1} \]
      5. associate-*r*98.9%

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

        \[\leadsto \color{blue}{-x \cdot \left(\left(1 - y \cdot z\right) \cdot -1\right)} \]
      7. distribute-rgt-neg-out98.9%

        \[\leadsto \color{blue}{x \cdot \left(-\left(1 - y \cdot z\right) \cdot -1\right)} \]
      8. *-commutative98.9%

        \[\leadsto x \cdot \left(-\color{blue}{-1 \cdot \left(1 - y \cdot z\right)}\right) \]
      9. neg-mul-198.9%

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\left(1 - y \cdot z\right)\right)}\right) \]
      10. remove-double-neg98.9%

        \[\leadsto x \cdot \color{blue}{\left(1 - y \cdot z\right)} \]
      11. cancel-sign-sub-inv98.9%

        \[\leadsto x \cdot \color{blue}{\left(1 + \left(-y\right) \cdot z\right)} \]
      12. +-commutative98.9%

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

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

        \[\leadsto x \cdot \left(\left(-y \cdot z\right) + \color{blue}{\left(--1\right)}\right) \]
      15. distribute-neg-in98.9%

        \[\leadsto x \cdot \color{blue}{\left(-\left(y \cdot z + -1\right)\right)} \]
      16. fma-def98.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+45} \lor \neg \left(y \leq 1.4 \cdot 10^{-160}\right):\\ \;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 5: 96.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 8.8 \cdot 10^{+229}:\\
\;\;\;\;x - x \cdot \left(z \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 8.80000000000000014e229

    1. Initial program 95.0%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. remove-double-neg95.0%

        \[\leadsto \color{blue}{-\left(-x \cdot \left(1 - y \cdot z\right)\right)} \]
      2. distribute-lft-neg-out95.0%

        \[\leadsto -\color{blue}{\left(-x\right) \cdot \left(1 - y \cdot z\right)} \]
      3. neg-mul-195.0%

        \[\leadsto \color{blue}{-1 \cdot \left(\left(-x\right) \cdot \left(1 - y \cdot z\right)\right)} \]
      4. *-commutative95.0%

        \[\leadsto \color{blue}{\left(\left(-x\right) \cdot \left(1 - y \cdot z\right)\right) \cdot -1} \]
      5. associate-*r*95.0%

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

        \[\leadsto \color{blue}{-x \cdot \left(\left(1 - y \cdot z\right) \cdot -1\right)} \]
      7. distribute-rgt-neg-out95.0%

        \[\leadsto \color{blue}{x \cdot \left(-\left(1 - y \cdot z\right) \cdot -1\right)} \]
      8. *-commutative95.0%

        \[\leadsto x \cdot \left(-\color{blue}{-1 \cdot \left(1 - y \cdot z\right)}\right) \]
      9. neg-mul-195.0%

        \[\leadsto x \cdot \left(-\color{blue}{\left(-\left(1 - y \cdot z\right)\right)}\right) \]
      10. remove-double-neg95.0%

        \[\leadsto x \cdot \color{blue}{\left(1 - y \cdot z\right)} \]
      11. cancel-sign-sub-inv95.0%

        \[\leadsto x \cdot \color{blue}{\left(1 + \left(-y\right) \cdot z\right)} \]
      12. +-commutative95.0%

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

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

        \[\leadsto x \cdot \left(\left(-y \cdot z\right) + \color{blue}{\left(--1\right)}\right) \]
      15. distribute-neg-in95.0%

        \[\leadsto x \cdot \color{blue}{\left(-\left(y \cdot z + -1\right)\right)} \]
      16. fma-def95.0%

        \[\leadsto x \cdot \left(-\color{blue}{\mathsf{fma}\left(y, z, -1\right)}\right) \]
    3. Simplified95.0%

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

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

        \[\leadsto \color{blue}{-x \cdot \left(y \cdot z - 1\right)} \]
      2. distribute-lft-out--95.0%

        \[\leadsto -\color{blue}{\left(x \cdot \left(y \cdot z\right) - x \cdot 1\right)} \]
      3. *-rgt-identity95.0%

        \[\leadsto -\left(x \cdot \left(y \cdot z\right) - \color{blue}{x}\right) \]
      4. unsub-neg95.0%

        \[\leadsto -\color{blue}{\left(x \cdot \left(y \cdot z\right) + \left(-x\right)\right)} \]
      5. mul-1-neg95.0%

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

        \[\leadsto -\color{blue}{\left(-1 \cdot x + x \cdot \left(y \cdot z\right)\right)} \]
      7. distribute-neg-in95.0%

        \[\leadsto \color{blue}{\left(--1 \cdot x\right) + \left(-x \cdot \left(y \cdot z\right)\right)} \]
      8. unsub-neg95.0%

        \[\leadsto \color{blue}{\left(--1 \cdot x\right) - x \cdot \left(y \cdot z\right)} \]
      9. mul-1-neg95.0%

        \[\leadsto \left(-\color{blue}{\left(-x\right)}\right) - x \cdot \left(y \cdot z\right) \]
      10. remove-double-neg95.0%

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

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

    if 8.80000000000000014e229 < z

    1. Initial program 82.2%

      \[x \cdot \left(1 - y \cdot z\right) \]
    2. Step-by-step derivation
      1. flip--24.5%

        \[\leadsto x \cdot \color{blue}{\frac{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}{1 + y \cdot z}} \]
      2. clear-num24.4%

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

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

        \[\leadsto x \cdot \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(y, z, 1\right)}}{1 \cdot 1 - \left(y \cdot z\right) \cdot \left(y \cdot z\right)}} \]
      5. metadata-eval24.4%

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

        \[\leadsto x \cdot \frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - \color{blue}{{\left(y \cdot z\right)}^{2}}}} \]
    3. Applied egg-rr24.4%

      \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(y, z, 1\right)}{1 - {\left(y \cdot z\right)}^{2}}}} \]
    4. Taylor expanded in y around 0 82.3%

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

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

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

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

        \[\leadsto x - \color{blue}{\left(z \cdot y\right)} \cdot x \]
      5. associate-*l*99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 8.8 \cdot 10^{+229}:\\ \;\;\;\;x - x \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \left(x \cdot y\right)\\ \end{array} \]

Alternative 6: 50.2% accurate, 7.0× speedup?

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

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

    \[x \cdot \left(1 - y \cdot z\right) \]
  2. Step-by-step derivation
    1. remove-double-neg94.0%

      \[\leadsto \color{blue}{-\left(-x \cdot \left(1 - y \cdot z\right)\right)} \]
    2. distribute-lft-neg-out94.0%

      \[\leadsto -\color{blue}{\left(-x\right) \cdot \left(1 - y \cdot z\right)} \]
    3. neg-mul-194.0%

      \[\leadsto \color{blue}{-1 \cdot \left(\left(-x\right) \cdot \left(1 - y \cdot z\right)\right)} \]
    4. *-commutative94.0%

      \[\leadsto \color{blue}{\left(\left(-x\right) \cdot \left(1 - y \cdot z\right)\right) \cdot -1} \]
    5. associate-*r*94.0%

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

      \[\leadsto \color{blue}{-x \cdot \left(\left(1 - y \cdot z\right) \cdot -1\right)} \]
    7. distribute-rgt-neg-out94.0%

      \[\leadsto \color{blue}{x \cdot \left(-\left(1 - y \cdot z\right) \cdot -1\right)} \]
    8. *-commutative94.0%

      \[\leadsto x \cdot \left(-\color{blue}{-1 \cdot \left(1 - y \cdot z\right)}\right) \]
    9. neg-mul-194.0%

      \[\leadsto x \cdot \left(-\color{blue}{\left(-\left(1 - y \cdot z\right)\right)}\right) \]
    10. remove-double-neg94.0%

      \[\leadsto x \cdot \color{blue}{\left(1 - y \cdot z\right)} \]
    11. cancel-sign-sub-inv94.0%

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-y\right) \cdot z\right)} \]
    12. +-commutative94.0%

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

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

      \[\leadsto x \cdot \left(\left(-y \cdot z\right) + \color{blue}{\left(--1\right)}\right) \]
    15. distribute-neg-in94.0%

      \[\leadsto x \cdot \color{blue}{\left(-\left(y \cdot z + -1\right)\right)} \]
    16. fma-def94.0%

      \[\leadsto x \cdot \left(-\color{blue}{\mathsf{fma}\left(y, z, -1\right)}\right) \]
  3. Simplified94.0%

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification46.9%

    \[\leadsto x \]

Reproduce

?
herbie shell --seed 2023290 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
  :precision binary64
  (* x (- 1.0 (* y z))))