Average Error: 3.8 → 0.7
Time: 36.2s
Precision: 64
\[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.003259736590562 \cdot 10^{+151}:\\ \;\;\;\;\left(z \cdot \left(y - 1.0\right)\right) \cdot x + 1.0 \cdot x\\ \mathbf{elif}\;x \le 4.962820235479597 \cdot 10^{-135}:\\ \;\;\;\;1.0 \cdot x + \left(z \cdot \left(y \cdot x\right) + z \cdot \left(-1.0 \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1.0 \cdot x + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \end{array}\]
x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \le -7.003259736590562 \cdot 10^{+151}:\\
\;\;\;\;\left(z \cdot \left(y - 1.0\right)\right) \cdot x + 1.0 \cdot x\\

\mathbf{elif}\;x \le 4.962820235479597 \cdot 10^{-135}:\\
\;\;\;\;1.0 \cdot x + \left(z \cdot \left(y \cdot x\right) + z \cdot \left(-1.0 \cdot x\right)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r35444126 = x;
        double r35444127 = 1.0;
        double r35444128 = y;
        double r35444129 = r35444127 - r35444128;
        double r35444130 = z;
        double r35444131 = r35444129 * r35444130;
        double r35444132 = r35444127 - r35444131;
        double r35444133 = r35444126 * r35444132;
        return r35444133;
}

double f(double x, double y, double z) {
        double r35444134 = x;
        double r35444135 = -7.003259736590562e+151;
        bool r35444136 = r35444134 <= r35444135;
        double r35444137 = z;
        double r35444138 = y;
        double r35444139 = 1.0;
        double r35444140 = r35444138 - r35444139;
        double r35444141 = r35444137 * r35444140;
        double r35444142 = r35444141 * r35444134;
        double r35444143 = r35444139 * r35444134;
        double r35444144 = r35444142 + r35444143;
        double r35444145 = 4.962820235479597e-135;
        bool r35444146 = r35444134 <= r35444145;
        double r35444147 = r35444138 * r35444134;
        double r35444148 = r35444137 * r35444147;
        double r35444149 = -r35444143;
        double r35444150 = r35444137 * r35444149;
        double r35444151 = r35444148 + r35444150;
        double r35444152 = r35444143 + r35444151;
        double r35444153 = r35444137 * r35444134;
        double r35444154 = r35444140 * r35444153;
        double r35444155 = r35444143 + r35444154;
        double r35444156 = r35444146 ? r35444152 : r35444155;
        double r35444157 = r35444136 ? r35444144 : r35444156;
        return r35444157;
}

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.8
Target0.2
Herbie0.7
\[\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{elif}\;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 x < -7.003259736590562e+151

    1. Initial program 0.1

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Simplified0.1

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(z, y - 1.0, 1.0\right)}\]
    3. Using strategy rm
    4. Applied fma-udef0.1

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

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

    if -7.003259736590562e+151 < x < 4.962820235479597e-135

    1. Initial program 5.5

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Simplified5.5

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(z, y - 1.0, 1.0\right)}\]
    3. Using strategy rm
    4. Applied fma-udef5.5

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

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

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

      \[\leadsto x \cdot \color{blue}{\left(\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(\sqrt[3]{z} \cdot \left(y - 1.0\right)\right)\right)} + x \cdot 1.0\]
    9. Using strategy rm
    10. Applied sub-neg6.1

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

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

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

      \[\leadsto \color{blue}{\left(x \cdot \left(\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(\sqrt[3]{z} \cdot y\right)\right) + x \cdot \left(\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(\sqrt[3]{z} \cdot \left(-1.0\right)\right)\right)\right)} + x \cdot 1.0\]
    14. Simplified1.4

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

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

    if 4.962820235479597e-135 < x

    1. Initial program 1.4

      \[x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\]
    2. Simplified1.4

      \[\leadsto \color{blue}{x \cdot \mathsf{fma}\left(z, y - 1.0, 1.0\right)}\]
    3. Using strategy rm
    4. Applied fma-udef1.4

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

      \[\leadsto \color{blue}{x \cdot \left(z \cdot \left(y - 1.0\right)\right) + x \cdot 1.0}\]
    6. Taylor expanded around inf 1.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -7.003259736590562 \cdot 10^{+151}:\\ \;\;\;\;\left(z \cdot \left(y - 1.0\right)\right) \cdot x + 1.0 \cdot x\\ \mathbf{elif}\;x \le 4.962820235479597 \cdot 10^{-135}:\\ \;\;\;\;1.0 \cdot x + \left(z \cdot \left(y \cdot x\right) + z \cdot \left(-1.0 \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1.0 \cdot x + \left(y - 1.0\right) \cdot \left(z \cdot x\right)\\ \end{array}\]

Reproduce

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