Average Error: 3.6 → 0.9
Time: 4.3s
Precision: binary64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \leq -5.2458616075492657 \cdot 10^{+166}:\\ \;\;\;\;\left(y - 1\right) \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq 1.1574701340110282 \cdot 10^{-107}:\\ \;\;\;\;\left(x + x \cdot \left(z \cdot y\right)\right) - z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(y \cdot x - x\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \leq -5.2458616075492657 \cdot 10^{+166}:\\
\;\;\;\;\left(y - 1\right) \cdot \left(z \cdot x\right)\\

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

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

\end{array}
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.2458616075492657e+166)
   (* (- y 1.0) (* z x))
   (if (<= z 1.1574701340110282e-107)
     (- (+ x (* x (* z y))) (* z x))
     (+ x (* z (- (* y x) x))))))
double code(double x, double y, double z) {
	return x * (1.0 - ((1.0 - y) * z));
}
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.2458616075492657e+166) {
		tmp = (y - 1.0) * (z * x);
	} else if (z <= 1.1574701340110282e-107) {
		tmp = (x + (x * (z * y))) - (z * x);
	} else {
		tmp = x + (z * ((y * x) - x));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.6
Target0.2
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) < -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) < 3.892237649663903 \cdot 10^{+134}:\\ \;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -5.2458616075492657e166

    1. Initial program 16.3

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary6417.2

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(\sqrt[3]{\left(1 - y\right) \cdot z} \cdot \sqrt[3]{\left(1 - y\right) \cdot z}\right) \cdot \sqrt[3]{\left(1 - y\right) \cdot z}}\right)\]
    4. Simplified17.2

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(\sqrt[3]{z - z \cdot y} \cdot \sqrt[3]{z - z \cdot y}\right)} \cdot \sqrt[3]{\left(1 - y\right) \cdot z}\right)\]
    5. Simplified17.2

      \[\leadsto x \cdot \left(1 - \left(\sqrt[3]{z - z \cdot y} \cdot \sqrt[3]{z - z \cdot y}\right) \cdot \color{blue}{\sqrt[3]{z - z \cdot y}}\right)\]
    6. Taylor expanded around inf 16.3

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

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

    if -5.2458616075492657e166 < z < 1.15747013401102817e-107

    1. Initial program 1.0

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Taylor expanded around 0 0.9

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

    if 1.15747013401102817e-107 < z

    1. Initial program 6.2

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary646.9

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(\sqrt[3]{\left(1 - y\right) \cdot z} \cdot \sqrt[3]{\left(1 - y\right) \cdot z}\right) \cdot \sqrt[3]{\left(1 - y\right) \cdot z}}\right)\]
    4. Simplified6.9

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(\sqrt[3]{z - z \cdot y} \cdot \sqrt[3]{z - z \cdot y}\right)} \cdot \sqrt[3]{\left(1 - y\right) \cdot z}\right)\]
    5. Simplified6.9

      \[\leadsto x \cdot \left(1 - \left(\sqrt[3]{z - z \cdot y} \cdot \sqrt[3]{z - z \cdot y}\right) \cdot \color{blue}{\sqrt[3]{z - z \cdot y}}\right)\]
    6. Using strategy rm
    7. Applied sub-neg_binary646.9

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(\sqrt[3]{z - z \cdot y} \cdot \sqrt[3]{z - z \cdot y}\right) \cdot \sqrt[3]{z - z \cdot y}\right)\right)}\]
    8. Applied distribute-rgt-in_binary646.9

      \[\leadsto \color{blue}{1 \cdot x + \left(-\left(\sqrt[3]{z - z \cdot y} \cdot \sqrt[3]{z - z \cdot y}\right) \cdot \sqrt[3]{z - z \cdot y}\right) \cdot x}\]
    9. Simplified6.9

      \[\leadsto \color{blue}{x} + \left(-\left(\sqrt[3]{z - z \cdot y} \cdot \sqrt[3]{z - z \cdot y}\right) \cdot \sqrt[3]{z - z \cdot y}\right) \cdot x\]
    10. Simplified0.7

      \[\leadsto x + \color{blue}{\left(y - 1\right) \cdot \left(z \cdot x\right)}\]
    11. Taylor expanded around 0 1.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.2458616075492657 \cdot 10^{+166}:\\ \;\;\;\;\left(y - 1\right) \cdot \left(z \cdot x\right)\\ \mathbf{elif}\;z \leq 1.1574701340110282 \cdot 10^{-107}:\\ \;\;\;\;\left(x + x \cdot \left(z \cdot y\right)\right) - z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(y \cdot x - x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2021175 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
  :precision binary64

  :herbie-target
  (if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))

  (* x (- 1.0 (* (- 1.0 y) z))))