Average Error: 3.5 → 0.7
Time: 11.3s
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}:\\ \;\;\;\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\\ \mathbf{elif}\;x \le 4.962820235479597 \cdot 10^{-135}:\\ \;\;\;\;\left(y \cdot x - 1.0 \cdot x\right) \cdot z + 1.0 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot x\right) + 1.0 \cdot \left(x - 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}:\\
\;\;\;\;x \cdot \left(1.0 - \left(1.0 - y\right) \cdot z\right)\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r36175084 = x;
        double r36175085 = 1.0;
        double r36175086 = y;
        double r36175087 = r36175085 - r36175086;
        double r36175088 = z;
        double r36175089 = r36175087 * r36175088;
        double r36175090 = r36175085 - r36175089;
        double r36175091 = r36175084 * r36175090;
        return r36175091;
}

double f(double x, double y, double z) {
        double r36175092 = x;
        double r36175093 = -7.003259736590562e+151;
        bool r36175094 = r36175092 <= r36175093;
        double r36175095 = 1.0;
        double r36175096 = y;
        double r36175097 = r36175095 - r36175096;
        double r36175098 = z;
        double r36175099 = r36175097 * r36175098;
        double r36175100 = r36175095 - r36175099;
        double r36175101 = r36175092 * r36175100;
        double r36175102 = 4.962820235479597e-135;
        bool r36175103 = r36175092 <= r36175102;
        double r36175104 = r36175096 * r36175092;
        double r36175105 = r36175095 * r36175092;
        double r36175106 = r36175104 - r36175105;
        double r36175107 = r36175106 * r36175098;
        double r36175108 = r36175107 + r36175105;
        double r36175109 = r36175098 * r36175092;
        double r36175110 = r36175096 * r36175109;
        double r36175111 = r36175092 - r36175109;
        double r36175112 = r36175095 * r36175111;
        double r36175113 = r36175110 + r36175112;
        double r36175114 = r36175103 ? r36175108 : r36175113;
        double r36175115 = r36175094 ? r36175101 : r36175114;
        return r36175115;
}

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.5
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. Using strategy rm
    3. Applied sub-neg0.1

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

      \[\leadsto \color{blue}{1.0 \cdot x + \left(-\left(1.0 - y\right) \cdot z\right) \cdot x}\]
    5. Using strategy rm
    6. Applied distribute-rgt-out0.1

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

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

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

    1. Initial program 5.2

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

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

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

    if 4.962820235479597e-135 < x

    1. Initial program 1.3

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

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

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

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

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

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

Reproduce

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