Average Error: 3.5 → 0.2
Time: 6.2s
Precision: binary64
Cost: 1218
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \leq -8.392853027253622 \cdot 10^{+35}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;z \leq 5.443626847987299 \cdot 10^{-37}:\\ \;\;\;\;x + x \cdot \left(z \cdot y - z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(z \cdot x\right) \cdot \left(y - 1\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \leq -8.392853027253622 \cdot 10^{+35}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right)\\

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

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

\end{array}
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
 :precision binary64
 (if (<= z -8.392853027253622e+35)
   (* (* z x) (- y 1.0))
   (if (<= z 5.443626847987299e-37)
     (+ x (* x (- (* z y) z)))
     (+ x (* (* z x) (- y 1.0))))))
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 <= -8.392853027253622e+35) {
		tmp = (z * x) * (y - 1.0);
	} else if (z <= 5.443626847987299e-37) {
		tmp = x + (x * ((z * y) - z));
	} else {
		tmp = x + ((z * x) * (y - 1.0));
	}
	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.5
Target0.2
Herbie0.2
\[\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}\]

Alternatives

Alternative 1
Error0.3
Cost1346
\[\begin{array}{l} \mathbf{if}\;z \leq -2.1233612960453473 \cdot 10^{+106}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;z \leq 3.136881405758548 \cdot 10^{-38}:\\ \;\;\;\;x + \left(x \cdot \left(z \cdot y\right) - z \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(z \cdot x\right) \cdot \left(y - 1\right)\\ \end{array}\]
Alternative 2
Error0.1
Cost904
\[\begin{array}{l} \mathbf{if}\;z \leq -6.282820306787024 \cdot 10^{-17} \lor \neg \left(z \leq 5.2549567956787756 \cdot 10^{-37}\right):\\ \;\;\;\;x + \left(z \cdot x\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \left(z \cdot y\right)\\ \end{array}\]
Alternative 3
Error0.9
Cost776
\[\begin{array}{l} \mathbf{if}\;z \leq -0.9726678355413415 \lor \neg \left(z \leq 0.013501177578971787\right):\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \left(z \cdot y\right)\\ \end{array}\]
Alternative 4
Error4.8
Cost1097
\[\begin{array}{l} \mathbf{if}\;y \leq -6.862279592571848 \cdot 10^{+192}:\\ \;\;\;\;\left(z \cdot x\right) \cdot y\\ \mathbf{elif}\;y \leq -0.996931097297141 \lor \neg \left(y \leq 4.665056350753174 \cdot 10^{-08}\right):\\ \;\;\;\;x + x \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot x\\ \end{array}\]
Alternative 5
Error12.2
Cost913
\[\begin{array}{l} \mathbf{if}\;y \leq -8.698140323986826 \cdot 10^{+79} \lor \neg \left(y \leq -5.242997599206687 \cdot 10^{+47} \lor \neg \left(y \leq -5307172302.714934\right) \land y \leq 1.623090438617971 \cdot 10^{+120}\right):\\ \;\;\;\;\left(z \cdot x\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot x\\ \end{array}\]
Alternative 6
Error19.1
Cost320
\[x - z \cdot x\]
Alternative 7
Error33.4
Cost64
\[x\]
Alternative 8
Error61.8
Cost64
\[-1\]
Alternative 9
Error61.9
Cost64
\[0\]
Alternative 10
Error61.8
Cost64
\[1\]

Error

Derivation

  1. Split input into 3 regimes
  2. if z < -8.3928530272536224e35

    1. Initial program 10.1

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

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(1 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-rgt-in_binary64_2355710.1

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

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

      \[\leadsto x + \color{blue}{x \cdot \left(y \cdot z - z\right)}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity_binary64_2360710.1

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

      \[\leadsto x + x \cdot \color{blue}{\left(z \cdot \left(y - 1\right)\right)}\]
    10. Applied associate-*r*_binary64_235470.1

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

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

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

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

    if -8.3928530272536224e35 < z < 5.4436268479872988e-37

    1. Initial program 0.2

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

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(1 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-rgt-in_binary64_235570.2

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

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

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

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

    if 5.4436268479872988e-37 < z

    1. Initial program 7.6

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied sub-neg_binary64_236007.6

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(1 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-rgt-in_binary64_235577.6

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

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

      \[\leadsto x + \color{blue}{x \cdot \left(y \cdot z - z\right)}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity_binary64_236077.6

      \[\leadsto x + x \cdot \left(y \cdot z - \color{blue}{1 \cdot z}\right)\]
    9. Applied distribute-rgt-out--_binary64_235617.6

      \[\leadsto x + x \cdot \color{blue}{\left(z \cdot \left(y - 1\right)\right)}\]
    10. Applied associate-*r*_binary64_235470.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.392853027253622 \cdot 10^{+35}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right)\\ \mathbf{elif}\;z \leq 5.443626847987299 \cdot 10^{-37}:\\ \;\;\;\;x + x \cdot \left(z \cdot y - z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(z \cdot x\right) \cdot \left(y - 1\right)\\ \end{array}\]

Reproduce

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