Average Error: 3.7 → 0.1
Time: 14.8s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.957614737323000504536869802612188098583 \cdot 10^{-22}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{elif}\;x \le 3.384200571349336964958405078165718304511 \cdot 10^{-78}:\\ \;\;\;\;\left(y \cdot x\right) \cdot z + 1 \cdot \left(x - x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot z\right) + 1 \cdot \left(x - x \cdot z\right)\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \le -5.957614737323000504536869802612188098583 \cdot 10^{-22}:\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r39541891 = x;
        double r39541892 = 1.0;
        double r39541893 = y;
        double r39541894 = r39541892 - r39541893;
        double r39541895 = z;
        double r39541896 = r39541894 * r39541895;
        double r39541897 = r39541892 - r39541896;
        double r39541898 = r39541891 * r39541897;
        return r39541898;
}

double f(double x, double y, double z) {
        double r39541899 = x;
        double r39541900 = -5.9576147373230005e-22;
        bool r39541901 = r39541899 <= r39541900;
        double r39541902 = 1.0;
        double r39541903 = y;
        double r39541904 = r39541902 - r39541903;
        double r39541905 = z;
        double r39541906 = r39541904 * r39541905;
        double r39541907 = r39541902 - r39541906;
        double r39541908 = r39541899 * r39541907;
        double r39541909 = 3.384200571349337e-78;
        bool r39541910 = r39541899 <= r39541909;
        double r39541911 = r39541903 * r39541899;
        double r39541912 = r39541911 * r39541905;
        double r39541913 = r39541899 * r39541905;
        double r39541914 = r39541899 - r39541913;
        double r39541915 = r39541902 * r39541914;
        double r39541916 = r39541912 + r39541915;
        double r39541917 = r39541903 * r39541913;
        double r39541918 = r39541917 + r39541915;
        double r39541919 = r39541910 ? r39541916 : r39541918;
        double r39541920 = r39541901 ? r39541908 : r39541919;
        return r39541920;
}

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.7
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 3 regimes
  2. if x < -5.9576147373230005e-22

    1. Initial program 0.2

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

    if -5.9576147373230005e-22 < x < 3.384200571349337e-78

    1. Initial program 6.9

      \[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt7.5

      \[\leadsto x \cdot \left(1 - \left(1 - y\right) \cdot \color{blue}{\left(\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}\right)}\right)\]
    4. Applied associate-*r*7.5

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(\left(1 - y\right) \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right) \cdot \sqrt[3]{z}}\right)\]
    5. Taylor expanded around inf 6.9

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

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

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

    if 3.384200571349337e-78 < x

    1. Initial program 0.7

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

      \[\leadsto x \cdot \left(1 - \left(1 - y\right) \cdot \color{blue}{\left(\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}\right)}\right)\]
    4. Applied associate-*r*1.2

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(\left(1 - y\right) \cdot \left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right)\right) \cdot \sqrt[3]{z}}\right)\]
    5. Taylor expanded around inf 0.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -5.957614737323000504536869802612188098583 \cdot 10^{-22}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{elif}\;x \le 3.384200571349336964958405078165718304511 \cdot 10^{-78}:\\ \;\;\;\;\left(y \cdot x\right) \cdot z + 1 \cdot \left(x - x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot z\right) + 1 \cdot \left(x - x \cdot z\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019192 
(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))))