Average Error: 2.2 → 0.4
Time: 14.2s
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}\;z \le -3.582737355568931258605138652643678872962 \cdot 10^{-21} \lor \neg \left(z \le 5.508327630323644327130679267730007262378 \cdot 10^{107}\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + z \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, 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}\;z \le -3.582737355568931258605138652643678872962 \cdot 10^{-21} \lor \neg \left(z \le 5.508327630323644327130679267730007262378 \cdot 10^{107}\right):\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + z \cdot \left(a \cdot b\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r418654 = x;
        double r418655 = y;
        double r418656 = z;
        double r418657 = r418655 * r418656;
        double r418658 = r418654 + r418657;
        double r418659 = t;
        double r418660 = a;
        double r418661 = r418659 * r418660;
        double r418662 = r418658 + r418661;
        double r418663 = r418660 * r418656;
        double r418664 = b;
        double r418665 = r418663 * r418664;
        double r418666 = r418662 + r418665;
        return r418666;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r418667 = z;
        double r418668 = -3.582737355568931e-21;
        bool r418669 = r418667 <= r418668;
        double r418670 = 5.5083276303236443e+107;
        bool r418671 = r418667 <= r418670;
        double r418672 = !r418671;
        bool r418673 = r418669 || r418672;
        double r418674 = x;
        double r418675 = y;
        double r418676 = r418675 * r418667;
        double r418677 = r418674 + r418676;
        double r418678 = t;
        double r418679 = a;
        double r418680 = r418678 * r418679;
        double r418681 = r418677 + r418680;
        double r418682 = b;
        double r418683 = r418679 * r418682;
        double r418684 = r418667 * r418683;
        double r418685 = r418681 + r418684;
        double r418686 = fma(r418667, r418682, r418678);
        double r418687 = fma(r418686, r418679, r418674);
        double r418688 = fma(r418667, r418675, r418687);
        double r418689 = r418673 ? r418685 : r418688;
        return r418689;
}

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.2
Target0.3
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;z \lt -11820553527347888128:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.758974318836428710669076838657752600596 \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 z < -3.582737355568931e-21 or 5.5083276303236443e+107 < z

    1. Initial program 5.6

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied add-cube-cbrt5.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot \color{blue}{\left(\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}\right)}\]
    4. Applied associate-*r*5.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(\left(a \cdot z\right) \cdot \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)\right) \cdot \sqrt[3]{b}}\]
    5. Simplified5.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \left(a \cdot z\right)\right)} \cdot \sqrt[3]{b}\]
    6. Using strategy rm
    7. Applied pow15.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \left(a \cdot z\right)\right) \cdot \color{blue}{{\left(\sqrt[3]{b}\right)}^{1}}\]
    8. Applied pow15.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \left(a \cdot \color{blue}{{z}^{1}}\right)\right) \cdot {\left(\sqrt[3]{b}\right)}^{1}\]
    9. Applied pow15.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \left(\color{blue}{{a}^{1}} \cdot {z}^{1}\right)\right) \cdot {\left(\sqrt[3]{b}\right)}^{1}\]
    10. Applied pow-prod-down5.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \color{blue}{{\left(a \cdot z\right)}^{1}}\right) \cdot {\left(\sqrt[3]{b}\right)}^{1}\]
    11. Applied pow15.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\left(\sqrt[3]{b} \cdot \color{blue}{{\left(\sqrt[3]{b}\right)}^{1}}\right) \cdot {\left(a \cdot z\right)}^{1}\right) \cdot {\left(\sqrt[3]{b}\right)}^{1}\]
    12. Applied pow15.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\left(\color{blue}{{\left(\sqrt[3]{b}\right)}^{1}} \cdot {\left(\sqrt[3]{b}\right)}^{1}\right) \cdot {\left(a \cdot z\right)}^{1}\right) \cdot {\left(\sqrt[3]{b}\right)}^{1}\]
    13. Applied pow-prod-down5.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\color{blue}{{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)}^{1}} \cdot {\left(a \cdot z\right)}^{1}\right) \cdot {\left(\sqrt[3]{b}\right)}^{1}\]
    14. Applied pow-prod-down5.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{{\left(\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \left(a \cdot z\right)\right)}^{1}} \cdot {\left(\sqrt[3]{b}\right)}^{1}\]
    15. Applied pow-prod-down5.9

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

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

    if -3.582737355568931e-21 < z < 5.5083276303236443e+107

    1. Initial program 0.7

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

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

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

Reproduce

herbie shell --seed 2019305 +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.75897431883642871e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))

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