Average Error: 0.1 → 0.1
Time: 16.9s
Precision: 64
\[\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z\]
\[\mathsf{fma}\left(y, x, z \cdot \left(3 \cdot z\right)\right)\]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\mathsf{fma}\left(y, x, z \cdot \left(3 \cdot z\right)\right)
double f(double x, double y, double z) {
        double r23070044 = x;
        double r23070045 = y;
        double r23070046 = r23070044 * r23070045;
        double r23070047 = z;
        double r23070048 = r23070047 * r23070047;
        double r23070049 = r23070046 + r23070048;
        double r23070050 = r23070049 + r23070048;
        double r23070051 = r23070050 + r23070048;
        return r23070051;
}

double f(double x, double y, double z) {
        double r23070052 = y;
        double r23070053 = x;
        double r23070054 = z;
        double r23070055 = 3.0;
        double r23070056 = r23070055 * r23070054;
        double r23070057 = r23070054 * r23070056;
        double r23070058 = fma(r23070052, r23070053, r23070057);
        return r23070058;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.1
Target0.1
Herbie0.1
\[\left(3 \cdot z\right) \cdot z + y \cdot x\]

Derivation

  1. Initial program 0.1

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(3, z \cdot z, x \cdot y\right)}\]
  3. Taylor expanded around 0 0.1

    \[\leadsto \color{blue}{3 \cdot {z}^{2} + x \cdot y}\]
  4. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, \left(3 \cdot z\right) \cdot z\right)}\]
  5. Final simplification0.1

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

Reproduce

herbie shell --seed 2019170 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"

  :herbie-target
  (+ (* (* 3.0 z) z) (* y x))

  (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))