Average Error: 2.0 → 0.3
Time: 4.8s
Precision: 64
\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;a \le -5.57450219563927614 \cdot 10^{29} \lor \neg \left(a \le 1.6207224568773726 \cdot 10^{-99}\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + {\left(a \cdot \left(z \cdot b\right)\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)\\ \end{array}\]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\begin{array}{l}
\mathbf{if}\;a \le -5.57450219563927614 \cdot 10^{29} \lor \neg \left(a \le 1.6207224568773726 \cdot 10^{-99}\right):\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + {\left(a \cdot \left(z \cdot b\right)\right)}^{1}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r485659 = x;
        double r485660 = y;
        double r485661 = z;
        double r485662 = r485660 * r485661;
        double r485663 = r485659 + r485662;
        double r485664 = t;
        double r485665 = a;
        double r485666 = r485664 * r485665;
        double r485667 = r485663 + r485666;
        double r485668 = r485665 * r485661;
        double r485669 = b;
        double r485670 = r485668 * r485669;
        double r485671 = r485667 + r485670;
        return r485671;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r485672 = a;
        double r485673 = -5.574502195639276e+29;
        bool r485674 = r485672 <= r485673;
        double r485675 = 1.6207224568773726e-99;
        bool r485676 = r485672 <= r485675;
        double r485677 = !r485676;
        bool r485678 = r485674 || r485677;
        double r485679 = x;
        double r485680 = y;
        double r485681 = z;
        double r485682 = r485680 * r485681;
        double r485683 = r485679 + r485682;
        double r485684 = t;
        double r485685 = r485684 * r485672;
        double r485686 = r485683 + r485685;
        double r485687 = b;
        double r485688 = r485681 * r485687;
        double r485689 = r485672 * r485688;
        double r485690 = 1.0;
        double r485691 = pow(r485689, r485690);
        double r485692 = r485686 + r485691;
        double r485693 = fma(r485672, r485687, r485680);
        double r485694 = fma(r485672, r485684, r485679);
        double r485695 = fma(r485693, r485681, r485694);
        double r485696 = r485678 ? r485692 : r485695;
        return r485696;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Target

Original2.0
Target0.4
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;z \lt -11820553527347888000:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.75897431883642871 \cdot 10^{-122}:\\ \;\;\;\;\left(b \cdot z + t\right) \cdot a + \left(z \cdot y + x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if a < -5.574502195639276e+29 or 1.6207224568773726e-99 < a

    1. Initial program 4.2

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied pow14.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot \color{blue}{{b}^{1}}\]
    4. Applied pow14.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot \color{blue}{{z}^{1}}\right) \cdot {b}^{1}\]
    5. Applied pow14.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\color{blue}{{a}^{1}} \cdot {z}^{1}\right) \cdot {b}^{1}\]
    6. Applied pow-prod-down4.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{{\left(a \cdot z\right)}^{1}} \cdot {b}^{1}\]
    7. Applied pow-prod-down4.2

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{{\left(\left(a \cdot z\right) \cdot b\right)}^{1}}\]
    8. Simplified0.6

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + {\color{blue}{\left(a \cdot \left(z \cdot b\right)\right)}}^{1}\]

    if -5.574502195639276e+29 < a < 1.6207224568773726e-99

    1. Initial program 0.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -5.57450219563927614 \cdot 10^{29} \lor \neg \left(a \le 1.6207224568773726 \cdot 10^{-99}\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + {\left(a \cdot \left(z \cdot b\right)\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020034 +o rules:numerics
(FPCore (x y z t a b)
  :name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
  :precision binary64

  :herbie-target
  (if (< z -11820553527347888000) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 4.7589743188364287e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))

  (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))