Average Error: 0.0 → 0.0
Time: 1.4s
Precision: 64
\[\left(x + y\right) \cdot \left(1 - z\right)\]
\[\mathsf{fma}\left(x, -z, \mathsf{fma}\left(1, x, 1 \cdot y\right)\right) + y \cdot \left(-z\right)\]
\left(x + y\right) \cdot \left(1 - z\right)
\mathsf{fma}\left(x, -z, \mathsf{fma}\left(1, x, 1 \cdot y\right)\right) + y \cdot \left(-z\right)
double f(double x, double y, double z) {
        double r48599 = x;
        double r48600 = y;
        double r48601 = r48599 + r48600;
        double r48602 = 1.0;
        double r48603 = z;
        double r48604 = r48602 - r48603;
        double r48605 = r48601 * r48604;
        return r48605;
}

double f(double x, double y, double z) {
        double r48606 = x;
        double r48607 = z;
        double r48608 = -r48607;
        double r48609 = 1.0;
        double r48610 = y;
        double r48611 = r48609 * r48610;
        double r48612 = fma(r48609, r48606, r48611);
        double r48613 = fma(r48606, r48608, r48612);
        double r48614 = r48610 * r48608;
        double r48615 = r48613 + r48614;
        return r48615;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.0

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

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

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

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

    \[\leadsto \mathsf{fma}\left(1, x, 1 \cdot y\right) + \color{blue}{\left(-z\right) \cdot \left(x + y\right)}\]
  7. Using strategy rm
  8. Applied distribute-rgt-in0.0

    \[\leadsto \mathsf{fma}\left(1, x, 1 \cdot y\right) + \color{blue}{\left(x \cdot \left(-z\right) + y \cdot \left(-z\right)\right)}\]
  9. Applied associate-+r+0.0

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(1, x, 1 \cdot y\right) + x \cdot \left(-z\right)\right) + y \cdot \left(-z\right)}\]
  10. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, -z, \mathsf{fma}\left(1, x, 1 \cdot y\right)\right)} + y \cdot \left(-z\right)\]
  11. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(x, -z, \mathsf{fma}\left(1, x, 1 \cdot y\right)\right) + y \cdot \left(-z\right)\]

Reproduce

herbie shell --seed 2019356 +o rules:numerics
(FPCore (x y z)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, H"
  :precision binary64
  (* (+ x y) (- 1 z)))