Average Error: 3.0 → 0.1
Time: 10.1s
Precision: 64
\[x \cdot \left(1 - y \cdot z\right)\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z \le -1.781188037029892726100866951239417080919 \cdot 10^{241}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x \cdot z}{\sqrt{1}} \cdot y, -1, \sqrt{1} \cdot x\right)\\ \mathbf{elif}\;y \cdot z \le 1.300768254442167389121124281248940722324 \cdot 10^{258}:\\ \;\;\;\;\left(1 - y \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{\frac{\sqrt{1}}{x \cdot y}}, -1, \sqrt{1} \cdot x\right)\\ \end{array}\]
x \cdot \left(1 - y \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \cdot z \le -1.781188037029892726100866951239417080919 \cdot 10^{241}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x \cdot z}{\sqrt{1}} \cdot y, -1, \sqrt{1} \cdot x\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\frac{\sqrt{1}}{x \cdot y}}, -1, \sqrt{1} \cdot x\right)\\

\end{array}
double f(double x, double y, double z) {
        double r173600 = x;
        double r173601 = 1.0;
        double r173602 = y;
        double r173603 = z;
        double r173604 = r173602 * r173603;
        double r173605 = r173601 - r173604;
        double r173606 = r173600 * r173605;
        return r173606;
}

double f(double x, double y, double z) {
        double r173607 = y;
        double r173608 = z;
        double r173609 = r173607 * r173608;
        double r173610 = -1.7811880370298927e+241;
        bool r173611 = r173609 <= r173610;
        double r173612 = x;
        double r173613 = r173612 * r173608;
        double r173614 = 1.0;
        double r173615 = sqrt(r173614);
        double r173616 = r173613 / r173615;
        double r173617 = r173616 * r173607;
        double r173618 = -r173614;
        double r173619 = r173615 * r173612;
        double r173620 = fma(r173617, r173618, r173619);
        double r173621 = 1.3007682544421674e+258;
        bool r173622 = r173609 <= r173621;
        double r173623 = r173614 - r173609;
        double r173624 = r173623 * r173612;
        double r173625 = r173612 * r173607;
        double r173626 = r173615 / r173625;
        double r173627 = r173608 / r173626;
        double r173628 = fma(r173627, r173618, r173619);
        double r173629 = r173622 ? r173624 : r173628;
        double r173630 = r173611 ? r173620 : r173629;
        return r173630;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Split input into 3 regimes
  2. if (* y z) < -1.7811880370298927e+241

    1. Initial program 34.1

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

      \[\leadsto \color{blue}{\left(1 - y \cdot z\right) \cdot x}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt34.3

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

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

      \[\leadsto \sqrt{1 - y \cdot z} \cdot \color{blue}{\left(\sqrt{\mathsf{fma}\left(-y, z, 1\right)} \cdot x\right)}\]
    7. Taylor expanded around 0 34.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z \cdot x}{\frac{\sqrt{1}}{y}}, -1, \sqrt{1} \cdot x\right)}\]
    9. Using strategy rm
    10. Applied associate-/r/0.6

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z \cdot x}{\sqrt{1}} \cdot y}, -1, \sqrt{1} \cdot x\right)\]

    if -1.7811880370298927e+241 < (* y z) < 1.3007682544421674e+258

    1. Initial program 0.1

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

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

    if 1.3007682544421674e+258 < (* y z)

    1. Initial program 38.9

      \[x \cdot \left(1 - y \cdot z\right)\]
    2. Simplified38.9

      \[\leadsto \color{blue}{\left(1 - y \cdot z\right) \cdot x}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt64.0

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

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

      \[\leadsto \sqrt{1 - y \cdot z} \cdot \color{blue}{\left(\sqrt{\mathsf{fma}\left(-y, z, 1\right)} \cdot x\right)}\]
    7. Taylor expanded around 0 38.9

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{z \cdot x}{\frac{\sqrt{1}}{y}}, -1, \sqrt{1} \cdot x\right)}\]
    9. Using strategy rm
    10. Applied associate-/l*0.3

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{\frac{\frac{\sqrt{1}}{y}}{x}}}, -1, \sqrt{1} \cdot x\right)\]
    11. Simplified0.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z \le -1.781188037029892726100866951239417080919 \cdot 10^{241}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x \cdot z}{\sqrt{1}} \cdot y, -1, \sqrt{1} \cdot x\right)\\ \mathbf{elif}\;y \cdot z \le 1.300768254442167389121124281248940722324 \cdot 10^{258}:\\ \;\;\;\;\left(1 - y \cdot z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{\frac{\sqrt{1}}{x \cdot y}}, -1, \sqrt{1} \cdot x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
  (* x (- 1.0 (* y z))))