Average Error: 3.2 → 0.3
Time: 34.5s
Precision: 64
Internal precision: 128
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.6282574721209407 \cdot 10^{+98}:\\ \;\;\;\;x \cdot 1.0 + z \cdot \left(x \cdot \left(y - 1.0\right)\right)\\ \mathbf{if}\;z \le 1.1178113736376001 \cdot 10^{+57}:\\ \;\;\;\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 1.0 + \left(z \cdot x\right) \cdot \left(y - 1.0\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original3.2
Comparison0.2
Herbie0.3
\[ \begin{array}{l} \mathbf{if}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt -1.618195973607049 \cdot 10^{+50}:\\ \;\;\;\;x + \left(1.0 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \mathbf{if}\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right) \lt 3.892237649663903 \cdot 10^{+134}:\\ \;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(1.0 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\ \end{array} \]

Derivation

  1. Split input into 3 regimes.
  2. if z < -2.6282574721209407e+98

    1. Initial program 11.7

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Applied taylor 0.1

      \[\leadsto \left(1.0 \cdot x + y \cdot \left(x \cdot z\right)\right) - 1.0 \cdot \left(x \cdot z\right)\]
    3. Taylor expanded around inf 0.1

      \[\leadsto \color{blue}{\left(1.0 \cdot x + y \cdot \left(x \cdot z\right)\right) - 1.0 \cdot \left(x \cdot z\right)}\]
    4. Applied simplify 0.1

      \[\leadsto \color{blue}{x \cdot 1.0 + \left(z \cdot x\right) \cdot \left(y - 1.0\right)}\]
    5. Using strategy rm
    6. Applied associate-*l* 0.1

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

    if -2.6282574721209407e+98 < z < 1.1178113736376001e+57

    1. Initial program 0.4

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]

    if 1.1178113736376001e+57 < z

    1. Initial program 9.8

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Applied taylor 0.1

      \[\leadsto \left(1.0 \cdot x + y \cdot \left(x \cdot z\right)\right) - 1.0 \cdot \left(x \cdot z\right)\]
    3. Taylor expanded around inf 0.1

      \[\leadsto \color{blue}{\left(1.0 \cdot x + y \cdot \left(x \cdot z\right)\right) - 1.0 \cdot \left(x \cdot z\right)}\]
    4. Applied simplify 0.1

      \[\leadsto \color{blue}{x \cdot 1.0 + \left(z \cdot x\right) \cdot \left(y - 1.0\right)}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 34.5s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(1263240699 3960646907 392216334 637456588 434149341 1861915064)'
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"

  :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))))