Average Error: 3.2 → 0.1
Time: 13.4s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;z \le -0.9563389629198734143145088637538719922304 \lor \neg \left(z \le 1.472434426290467325820368081688675754304 \cdot 10^{-9}\right):\\ \;\;\;\;x \cdot \left(1 - 1 \cdot z\right) + \left(x \cdot z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(-\left(z \cdot \left(1 - y\right)\right) \cdot x\right) + x \cdot 1\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \le -0.9563389629198734143145088637538719922304 \lor \neg \left(z \le 1.472434426290467325820368081688675754304 \cdot 10^{-9}\right):\\
\;\;\;\;x \cdot \left(1 - 1 \cdot z\right) + \left(x \cdot z\right) \cdot y\\

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

\end{array}
double f(double x, double y, double z) {
        double r641730 = x;
        double r641731 = 1.0;
        double r641732 = y;
        double r641733 = r641731 - r641732;
        double r641734 = z;
        double r641735 = r641733 * r641734;
        double r641736 = r641731 - r641735;
        double r641737 = r641730 * r641736;
        return r641737;
}

double f(double x, double y, double z) {
        double r641738 = z;
        double r641739 = -0.9563389629198734;
        bool r641740 = r641738 <= r641739;
        double r641741 = 1.4724344262904673e-09;
        bool r641742 = r641738 <= r641741;
        double r641743 = !r641742;
        bool r641744 = r641740 || r641743;
        double r641745 = x;
        double r641746 = 1.0;
        double r641747 = r641746 * r641738;
        double r641748 = r641746 - r641747;
        double r641749 = r641745 * r641748;
        double r641750 = r641745 * r641738;
        double r641751 = y;
        double r641752 = r641750 * r641751;
        double r641753 = r641749 + r641752;
        double r641754 = r641746 - r641751;
        double r641755 = r641738 * r641754;
        double r641756 = r641755 * r641745;
        double r641757 = -r641756;
        double r641758 = r641745 * r641746;
        double r641759 = r641757 + r641758;
        double r641760 = r641744 ? r641753 : r641759;
        return r641760;
}

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.2
Target0.3
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 < -0.9563389629198734 or 1.4724344262904673e-09 < z

    1. Initial program 7.7

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

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

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

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

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

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

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

      \[\leadsto x \cdot 1 + \left(-\color{blue}{\left(\left(x \cdot z\right) \cdot 1 + \left(x \cdot z\right) \cdot \left(-y\right)\right)}\right)\]
    12. Applied distribute-neg-in0.1

      \[\leadsto x \cdot 1 + \color{blue}{\left(\left(-\left(x \cdot z\right) \cdot 1\right) + \left(-\left(x \cdot z\right) \cdot \left(-y\right)\right)\right)}\]
    13. Applied associate-+r+0.1

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

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

    if -0.9563389629198734 < z < 1.4724344262904673e-09

    1. Initial program 0.1

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

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

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

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

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

Reproduce

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