Average Error: 3.6 → 0.1
Time: 5.4s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.329374264349992850062661166929405576475 \cdot 10^{-45} \lor \neg \left(z \le 14399917448371046271501632115048448\right):\\ \;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -3.329374264349992850062661166929405576475 \cdot 10^{-45} \lor \neg \left(z \le 14399917448371046271501632115048448\right):\\
\;\;\;\;x \cdot 1 + \left(x \cdot z\right) \cdot \left(y - 1\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r395140 = x;
        double r395141 = 1.0;
        double r395142 = y;
        double r395143 = r395141 - r395142;
        double r395144 = z;
        double r395145 = r395143 * r395144;
        double r395146 = r395141 - r395145;
        double r395147 = r395140 * r395146;
        return r395147;
}

double f(double x, double y, double z) {
        double r395148 = z;
        double r395149 = -3.329374264349993e-45;
        bool r395150 = r395148 <= r395149;
        double r395151 = 1.4399917448371046e+34;
        bool r395152 = r395148 <= r395151;
        double r395153 = !r395152;
        bool r395154 = r395150 || r395153;
        double r395155 = x;
        double r395156 = 1.0;
        double r395157 = r395155 * r395156;
        double r395158 = r395155 * r395148;
        double r395159 = y;
        double r395160 = r395159 - r395156;
        double r395161 = r395158 * r395160;
        double r395162 = r395157 + r395161;
        double r395163 = r395156 - r395159;
        double r395164 = r395163 * r395148;
        double r395165 = r395156 - r395164;
        double r395166 = r395155 * r395165;
        double r395167 = r395154 ? r395162 : r395166;
        return r395167;
}

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.1
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \lt -1.618195973607048970493874632750554853795 \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.892237649663902900973248011051357504727 \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.329374264349993e-45 or 1.4399917448371046e+34 < z

    1. Initial program 8.8

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

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

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

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

    if -3.329374264349993e-45 < z < 1.4399917448371046e+34

    1. Initial program 0.1

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

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

Reproduce

herbie shell --seed 2019362 +o rules:numerics
(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))))