Average Error: 3.5 → 0.1
Time: 16.0s
Precision: 64
\[x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -4.194512825229324040414611934367407088033 \cdot 10^{-71}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right) + x \cdot 1\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 2.494010892277929670817330989669207182789 \cdot 10^{221}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right) + x \cdot 1\\ \end{array}\]
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -4.194512825229324040414611934367407088033 \cdot 10^{-71}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right) + x \cdot 1\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r26142549 = x;
        double r26142550 = 1.0;
        double r26142551 = y;
        double r26142552 = r26142550 - r26142551;
        double r26142553 = z;
        double r26142554 = r26142552 * r26142553;
        double r26142555 = r26142550 - r26142554;
        double r26142556 = r26142549 * r26142555;
        return r26142556;
}

double f(double x, double y, double z) {
        double r26142557 = x;
        double r26142558 = 1.0;
        double r26142559 = y;
        double r26142560 = r26142558 - r26142559;
        double r26142561 = z;
        double r26142562 = r26142560 * r26142561;
        double r26142563 = r26142558 - r26142562;
        double r26142564 = r26142557 * r26142563;
        double r26142565 = -4.194512825229324e-71;
        bool r26142566 = r26142564 <= r26142565;
        double r26142567 = r26142561 * r26142557;
        double r26142568 = r26142559 - r26142558;
        double r26142569 = r26142567 * r26142568;
        double r26142570 = r26142557 * r26142558;
        double r26142571 = r26142569 + r26142570;
        double r26142572 = 2.4940108922779297e+221;
        bool r26142573 = r26142564 <= r26142572;
        double r26142574 = r26142573 ? r26142564 : r26142571;
        double r26142575 = r26142566 ? r26142571 : r26142574;
        return r26142575;
}

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.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 (* x (- 1.0 (* (- 1.0 y) z))) < -4.194512825229324e-71 or 2.4940108922779297e+221 < (* x (- 1.0 (* (- 1.0 y) z)))

    1. Initial program 7.7

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

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \left(1 - \left(1 - y\right) \cdot z\right)\right)}\]
    5. 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)}\]
    6. Simplified0.2

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

    if -4.194512825229324e-71 < (* x (- 1.0 (* (- 1.0 y) z))) < 2.4940108922779297e+221

    1. Initial program 0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le -4.194512825229324040414611934367407088033 \cdot 10^{-71}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right) + x \cdot 1\\ \mathbf{elif}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \le 2.494010892277929670817330989669207182789 \cdot 10^{221}:\\ \;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right) + x \cdot 1\\ \end{array}\]

Reproduce

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