Average Error: 3.4 → 0.4
Time: 19.6s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.772670088629298551029424282089112926727 \cdot 10^{-191}:\\ \;\;\;\;1 \cdot x + \left(y \cdot \left(x \cdot z\right) + \left(-x \cdot z\right) \cdot 1\right)\\ \mathbf{elif}\;x \le 6.000187177265717435057895603864687673774 \cdot 10^{-176}:\\ \;\;\;\;1 \cdot x + z \cdot \left(x \cdot y - 1 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x + \left(y \cdot \left(x \cdot z\right) + \left(-x \cdot z\right) \cdot 1\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \le -1.772670088629298551029424282089112926727 \cdot 10^{-191}:\\
\;\;\;\;1 \cdot x + \left(y \cdot \left(x \cdot z\right) + \left(-x \cdot z\right) \cdot 1\right)\\

\mathbf{elif}\;x \le 6.000187177265717435057895603864687673774 \cdot 10^{-176}:\\
\;\;\;\;1 \cdot x + z \cdot \left(x \cdot y - 1 \cdot x\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r146310139 = x;
        double r146310140 = 1.0;
        double r146310141 = y;
        double r146310142 = r146310140 - r146310141;
        double r146310143 = z;
        double r146310144 = r146310142 * r146310143;
        double r146310145 = r146310140 - r146310144;
        double r146310146 = r146310139 * r146310145;
        return r146310146;
}

double f(double x, double y, double z) {
        double r146310147 = x;
        double r146310148 = -1.7726700886292986e-191;
        bool r146310149 = r146310147 <= r146310148;
        double r146310150 = 1.0;
        double r146310151 = r146310150 * r146310147;
        double r146310152 = y;
        double r146310153 = z;
        double r146310154 = r146310147 * r146310153;
        double r146310155 = r146310152 * r146310154;
        double r146310156 = -r146310154;
        double r146310157 = r146310156 * r146310150;
        double r146310158 = r146310155 + r146310157;
        double r146310159 = r146310151 + r146310158;
        double r146310160 = 6.0001871772657174e-176;
        bool r146310161 = r146310147 <= r146310160;
        double r146310162 = r146310147 * r146310152;
        double r146310163 = r146310162 - r146310151;
        double r146310164 = r146310153 * r146310163;
        double r146310165 = r146310151 + r146310164;
        double r146310166 = r146310161 ? r146310165 : r146310159;
        double r146310167 = r146310149 ? r146310159 : r146310166;
        return r146310167;
}

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.2
Herbie0.4
\[\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 x < -1.7726700886292986e-191 or 6.0001871772657174e-176 < x

    1. Initial program 1.9

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 1.9

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

      \[\leadsto \color{blue}{1 \cdot x + z \cdot \left(x \cdot y - 1 \cdot x\right)}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt5.0

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

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

      \[\leadsto 1 \cdot x + \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(\sqrt[3]{z} \cdot \color{blue}{\left(x \cdot y + \left(-1 \cdot x\right)\right)}\right)\]
    9. Applied distribute-lft-in5.0

      \[\leadsto 1 \cdot x + \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \color{blue}{\left(\sqrt[3]{z} \cdot \left(x \cdot y\right) + \sqrt[3]{z} \cdot \left(-1 \cdot x\right)\right)}\]
    10. Applied distribute-lft-in5.0

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

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

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

    if -1.7726700886292986e-191 < x < 6.0001871772657174e-176

    1. Initial program 7.7

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Taylor expanded around inf 7.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.772670088629298551029424282089112926727 \cdot 10^{-191}:\\ \;\;\;\;1 \cdot x + \left(y \cdot \left(x \cdot z\right) + \left(-x \cdot z\right) \cdot 1\right)\\ \mathbf{elif}\;x \le 6.000187177265717435057895603864687673774 \cdot 10^{-176}:\\ \;\;\;\;1 \cdot x + z \cdot \left(x \cdot y - 1 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x + \left(y \cdot \left(x \cdot z\right) + \left(-x \cdot z\right) \cdot 1\right)\\ \end{array}\]

Reproduce

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

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