Average Error: 2.1 → 1.2
Time: 16.7s
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 -1.633099719810372038924919515496326271933 \cdot 10^{-76} \lor \neg \left(a \le 9.108876548869236631679254363644611836499 \cdot 10^{-243}\right):\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \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 -1.633099719810372038924919515496326271933 \cdot 10^{-76} \lor \neg \left(a \le 9.108876548869236631679254363644611836499 \cdot 10^{-243}\right):\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r427124 = x;
        double r427125 = y;
        double r427126 = z;
        double r427127 = r427125 * r427126;
        double r427128 = r427124 + r427127;
        double r427129 = t;
        double r427130 = a;
        double r427131 = r427129 * r427130;
        double r427132 = r427128 + r427131;
        double r427133 = r427130 * r427126;
        double r427134 = b;
        double r427135 = r427133 * r427134;
        double r427136 = r427132 + r427135;
        return r427136;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r427137 = a;
        double r427138 = -1.633099719810372e-76;
        bool r427139 = r427137 <= r427138;
        double r427140 = 9.108876548869237e-243;
        bool r427141 = r427137 <= r427140;
        double r427142 = !r427141;
        bool r427143 = r427139 || r427142;
        double r427144 = z;
        double r427145 = y;
        double r427146 = b;
        double r427147 = t;
        double r427148 = fma(r427144, r427146, r427147);
        double r427149 = x;
        double r427150 = fma(r427148, r427137, r427149);
        double r427151 = fma(r427144, r427145, r427150);
        double r427152 = r427145 * r427144;
        double r427153 = r427149 + r427152;
        double r427154 = r427147 * r427137;
        double r427155 = r427153 + r427154;
        double r427156 = r427137 * r427144;
        double r427157 = r427156 * r427146;
        double r427158 = r427155 + r427157;
        double r427159 = r427143 ? r427151 : r427158;
        return r427159;
}

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.1
Target0.3
Herbie1.2
\[\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 a < -1.633099719810372e-76 or 9.108876548869237e-243 < a

    1. Initial program 2.8

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

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

    if -1.633099719810372e-76 < a < 9.108876548869237e-243

    1. Initial program 0.5

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.2

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

Reproduce

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