Average Error: 2.2 → 0.7
Time: 5.5s
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}\;b \le -2.24558631433967711172148725889707055088 \cdot 10^{54}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{elif}\;b \le 9.714895677894267435949745791546243509726 \cdot 10^{-77}:\\ \;\;\;\;1 \cdot \mathsf{fma}\left(a \cdot b, z, \mathsf{fma}\left(y, z, \mathsf{fma}\left(a, t, x\right)\right)\right)\\ \mathbf{elif}\;b \le 2.468328603260348445360326042849667669195 \cdot 10^{247}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + {\left(a \cdot \left(z \cdot b\right)\right)}^{1}\\ \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}\;b \le -2.24558631433967711172148725889707055088 \cdot 10^{54}:\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\

\mathbf{elif}\;b \le 9.714895677894267435949745791546243509726 \cdot 10^{-77}:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(a \cdot b, z, \mathsf{fma}\left(y, z, \mathsf{fma}\left(a, t, x\right)\right)\right)\\

\mathbf{elif}\;b \le 2.468328603260348445360326042849667669195 \cdot 10^{247}:\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\

\mathbf{else}:\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + {\left(a \cdot \left(z \cdot b\right)\right)}^{1}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r960257 = x;
        double r960258 = y;
        double r960259 = z;
        double r960260 = r960258 * r960259;
        double r960261 = r960257 + r960260;
        double r960262 = t;
        double r960263 = a;
        double r960264 = r960262 * r960263;
        double r960265 = r960261 + r960264;
        double r960266 = r960263 * r960259;
        double r960267 = b;
        double r960268 = r960266 * r960267;
        double r960269 = r960265 + r960268;
        return r960269;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r960270 = b;
        double r960271 = -2.245586314339677e+54;
        bool r960272 = r960270 <= r960271;
        double r960273 = x;
        double r960274 = y;
        double r960275 = z;
        double r960276 = r960274 * r960275;
        double r960277 = r960273 + r960276;
        double r960278 = t;
        double r960279 = a;
        double r960280 = r960278 * r960279;
        double r960281 = r960277 + r960280;
        double r960282 = r960279 * r960275;
        double r960283 = r960282 * r960270;
        double r960284 = r960281 + r960283;
        double r960285 = 9.714895677894267e-77;
        bool r960286 = r960270 <= r960285;
        double r960287 = 1.0;
        double r960288 = r960279 * r960270;
        double r960289 = fma(r960279, r960278, r960273);
        double r960290 = fma(r960274, r960275, r960289);
        double r960291 = fma(r960288, r960275, r960290);
        double r960292 = r960287 * r960291;
        double r960293 = 2.4683286032603484e+247;
        bool r960294 = r960270 <= r960293;
        double r960295 = r960275 * r960270;
        double r960296 = r960279 * r960295;
        double r960297 = pow(r960296, r960287);
        double r960298 = r960281 + r960297;
        double r960299 = r960294 ? r960284 : r960298;
        double r960300 = r960286 ? r960292 : r960299;
        double r960301 = r960272 ? r960284 : r960300;
        return r960301;
}

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.4
Herbie0.7
\[\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 3 regimes
  2. if b < -2.245586314339677e+54 or 9.714895677894267e-77 < b < 2.4683286032603484e+247

    1. Initial program 0.6

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]

    if -2.245586314339677e+54 < b < 9.714895677894267e-77

    1. Initial program 3.5

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

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

      \[\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 pow13.5

      \[\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-down3.5

      \[\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-down3.5

      \[\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.1

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + {\color{blue}{\left(a \cdot \left(z \cdot b\right)\right)}}^{1}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity0.1

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{1 \cdot {\left(a \cdot \left(z \cdot b\right)\right)}^{1}}\]
    11. Applied *-un-lft-identity0.1

      \[\leadsto \color{blue}{1 \cdot \left(\left(x + y \cdot z\right) + t \cdot a\right)} + 1 \cdot {\left(a \cdot \left(z \cdot b\right)\right)}^{1}\]
    12. Applied distribute-lft-out0.1

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

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

    if 2.4683286032603484e+247 < b

    1. Initial program 2.4

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

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

      \[\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 pow12.4

      \[\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-down2.4

      \[\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-down2.4

      \[\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. Simplified10.1

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + {\color{blue}{\left(a \cdot \left(z \cdot b\right)\right)}}^{1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.24558631433967711172148725889707055088 \cdot 10^{54}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{elif}\;b \le 9.714895677894267435949745791546243509726 \cdot 10^{-77}:\\ \;\;\;\;1 \cdot \mathsf{fma}\left(a \cdot b, z, \mathsf{fma}\left(y, z, \mathsf{fma}\left(a, t, x\right)\right)\right)\\ \mathbf{elif}\;b \le 2.468328603260348445360326042849667669195 \cdot 10^{247}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + {\left(a \cdot \left(z \cdot b\right)\right)}^{1}\\ \end{array}\]

Reproduce

herbie shell --seed 2019362 +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)))