Average Error: 3.4 → 0.1
Time: 3.3s
Precision: binary64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -6.3854864094269133 \cdot 10^{182}:\\ \;\;\;\;1 \cdot x + \left(1 - y\right) \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \le 5.44080518340726623 \cdot 10^{252}:\\ \;\;\;\;1 \cdot x + \left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x + z \cdot \left(\left(1 - y\right) \cdot \left(-x\right)\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original3.4
Target0.3
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \lt -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) \lt 3.8922376496639029 \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 (* (- 1.0 y) z) < -6.3854864094269133e182

    1. Initial program 16.7

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

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

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

      \[\leadsto x \cdot 1 + \color{blue}{x \cdot \left(\left(1 - y\right) \cdot \left(-z\right)\right)}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt17.6

      \[\leadsto x \cdot 1 + \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)} \cdot \left(\left(1 - y\right) \cdot \left(-z\right)\right)\]
    8. Applied associate-*l*17.6

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

      \[\leadsto x \cdot 1 + \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \color{blue}{\left(\left(1 - y\right) \cdot \left(z \cdot \left(-\sqrt[3]{x}\right)\right)\right)}\]
    10. Using strategy rm
    11. Applied pow110.6

      \[\leadsto x \cdot 1 + \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\left(1 - y\right) \cdot \left(z \cdot \color{blue}{{\left(-\sqrt[3]{x}\right)}^{1}}\right)\right)\]
    12. Applied pow110.6

      \[\leadsto x \cdot 1 + \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\left(1 - y\right) \cdot \left(\color{blue}{{z}^{1}} \cdot {\left(-\sqrt[3]{x}\right)}^{1}\right)\right)\]
    13. Applied pow-prod-down10.6

      \[\leadsto x \cdot 1 + \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\left(1 - y\right) \cdot \color{blue}{{\left(z \cdot \left(-\sqrt[3]{x}\right)\right)}^{1}}\right)\]
    14. Applied pow110.6

      \[\leadsto x \cdot 1 + \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\color{blue}{{\left(1 - y\right)}^{1}} \cdot {\left(z \cdot \left(-\sqrt[3]{x}\right)\right)}^{1}\right)\]
    15. Applied pow-prod-down10.6

      \[\leadsto x \cdot 1 + \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \color{blue}{{\left(\left(1 - y\right) \cdot \left(z \cdot \left(-\sqrt[3]{x}\right)\right)\right)}^{1}}\]
    16. Applied pow110.6

      \[\leadsto x \cdot 1 + \left(\sqrt[3]{x} \cdot \color{blue}{{\left(\sqrt[3]{x}\right)}^{1}}\right) \cdot {\left(\left(1 - y\right) \cdot \left(z \cdot \left(-\sqrt[3]{x}\right)\right)\right)}^{1}\]
    17. Applied pow110.6

      \[\leadsto x \cdot 1 + \left(\color{blue}{{\left(\sqrt[3]{x}\right)}^{1}} \cdot {\left(\sqrt[3]{x}\right)}^{1}\right) \cdot {\left(\left(1 - y\right) \cdot \left(z \cdot \left(-\sqrt[3]{x}\right)\right)\right)}^{1}\]
    18. Applied pow-prod-down10.6

      \[\leadsto x \cdot 1 + \color{blue}{{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)}^{1}} \cdot {\left(\left(1 - y\right) \cdot \left(z \cdot \left(-\sqrt[3]{x}\right)\right)\right)}^{1}\]
    19. Applied pow-prod-down10.6

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

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

    if -6.3854864094269133e182 < (* (- 1.0 y) z) < 5.44080518340726623e252

    1. Initial program 0.1

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

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

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

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

    if 5.44080518340726623e252 < (* (- 1.0 y) z)

    1. Initial program 28.5

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

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

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

      \[\leadsto x \cdot 1 + \color{blue}{x \cdot \left(\left(1 - y\right) \cdot \left(-z\right)\right)}\]
    6. Using strategy rm
    7. Applied associate-*r*0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - y\right) \cdot z \le -6.3854864094269133 \cdot 10^{182}:\\ \;\;\;\;1 \cdot x + \left(1 - y\right) \cdot \left(z \cdot \left(-x\right)\right)\\ \mathbf{elif}\;\left(1 - y\right) \cdot z \le 5.44080518340726623 \cdot 10^{252}:\\ \;\;\;\;1 \cdot x + \left(\left(1 - y\right) \cdot z\right) \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x + z \cdot \left(\left(1 - y\right) \cdot \left(-x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020181 
(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) (* (neg z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (neg z) x)))))

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