Average Error: 3.4 → 0.1
Time: 27.0s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.5627093803727213 \cdot 10^{52} \lor \neg \left(z \le 56035482213991.219\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y + 1\right) + \left(-1\right) \cdot \left(x \cdot z\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -3.5627093803727213 \cdot 10^{52} \lor \neg \left(z \le 56035482213991.219\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r1556029 = x;
        double r1556030 = 1.0;
        double r1556031 = y;
        double r1556032 = r1556030 - r1556031;
        double r1556033 = z;
        double r1556034 = r1556032 * r1556033;
        double r1556035 = r1556030 - r1556034;
        double r1556036 = r1556029 * r1556035;
        return r1556036;
}

double f(double x, double y, double z) {
        double r1556037 = z;
        double r1556038 = -3.5627093803727213e+52;
        bool r1556039 = r1556037 <= r1556038;
        double r1556040 = 56035482213991.22;
        bool r1556041 = r1556037 <= r1556040;
        double r1556042 = !r1556041;
        bool r1556043 = r1556039 || r1556042;
        double r1556044 = x;
        double r1556045 = 1.0;
        double r1556046 = r1556044 * r1556045;
        double r1556047 = r1556044 * r1556037;
        double r1556048 = y;
        double r1556049 = r1556048 - r1556045;
        double r1556050 = r1556047 * r1556049;
        double r1556051 = r1556046 + r1556050;
        double r1556052 = r1556037 * r1556048;
        double r1556053 = r1556052 + r1556045;
        double r1556054 = r1556044 * r1556053;
        double r1556055 = -r1556045;
        double r1556056 = r1556055 * r1556047;
        double r1556057 = r1556054 + r1556056;
        double r1556058 = r1556043 ? r1556051 : r1556057;
        return r1556058;
}

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.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 2 regimes
  2. if z < -3.5627093803727213e+52 or 56035482213991.22 < z

    1. Initial program 10.1

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

      \[\leadsto x \cdot \color{blue}{\left(1 + \left(-\left(1 - y\right) \cdot z\right)\right)}\]
    4. Applied distribute-lft-in10.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}{\left(x \cdot z\right) \cdot \left(y - 1\right)}\]

    if -3.5627093803727213e+52 < z < 56035482213991.22

    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. Simplified2.3

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.5627093803727213 \cdot 10^{52} \lor \neg \left(z \le 56035482213991.219\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y + 1\right) + \left(-1\right) \cdot \left(x \cdot z\right)\\ \end{array}\]

Reproduce

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

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

  (* x (- 1 (* (- 1 y) z))))