Average Error: 0.2 → 0.1
Time: 17.4s
Precision: 64
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
\[\left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), {a}^{4}\right)\right) + 4 \cdot \left(\left(1 - a \cdot 3\right) \cdot \left(b \cdot b\right) + \left(1 + a\right) \cdot \left(a \cdot a\right)\right)\right) - 1\]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), {a}^{4}\right)\right) + 4 \cdot \left(\left(1 - a \cdot 3\right) \cdot \left(b \cdot b\right) + \left(1 + a\right) \cdot \left(a \cdot a\right)\right)\right) - 1
double f(double a, double b) {
        double r4834944 = a;
        double r4834945 = r4834944 * r4834944;
        double r4834946 = b;
        double r4834947 = r4834946 * r4834946;
        double r4834948 = r4834945 + r4834947;
        double r4834949 = 2.0;
        double r4834950 = pow(r4834948, r4834949);
        double r4834951 = 4.0;
        double r4834952 = 1.0;
        double r4834953 = r4834952 + r4834944;
        double r4834954 = r4834945 * r4834953;
        double r4834955 = 3.0;
        double r4834956 = r4834955 * r4834944;
        double r4834957 = r4834952 - r4834956;
        double r4834958 = r4834947 * r4834957;
        double r4834959 = r4834954 + r4834958;
        double r4834960 = r4834951 * r4834959;
        double r4834961 = r4834950 + r4834960;
        double r4834962 = r4834961 - r4834952;
        return r4834962;
}

double f(double a, double b) {
        double r4834963 = b;
        double r4834964 = r4834963 * r4834963;
        double r4834965 = 2.0;
        double r4834966 = a;
        double r4834967 = r4834966 * r4834966;
        double r4834968 = r4834964 * r4834967;
        double r4834969 = 4.0;
        double r4834970 = pow(r4834966, r4834969);
        double r4834971 = fma(r4834965, r4834968, r4834970);
        double r4834972 = fma(r4834964, r4834964, r4834971);
        double r4834973 = 1.0;
        double r4834974 = 3.0;
        double r4834975 = r4834966 * r4834974;
        double r4834976 = r4834973 - r4834975;
        double r4834977 = r4834976 * r4834964;
        double r4834978 = r4834973 + r4834966;
        double r4834979 = r4834978 * r4834967;
        double r4834980 = r4834977 + r4834979;
        double r4834981 = r4834969 * r4834980;
        double r4834982 = r4834972 + r4834981;
        double r4834983 = r4834982 - r4834973;
        return r4834983;
}

Error

Bits error versus a

Bits error versus b

Derivation

  1. Initial program 0.2

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  2. Taylor expanded around 0 0.0

    \[\leadsto \left(\color{blue}{\left({b}^{4} + \left(2 \cdot \left({a}^{2} \cdot {b}^{2}\right) + {a}^{4}\right)\right)} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  3. Simplified0.2

    \[\leadsto \left(\color{blue}{\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), \left(a \cdot a\right) \cdot \left(a \cdot a\right)\right)\right)} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  4. Using strategy rm
  5. Applied pow10.2

    \[\leadsto \left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), \left(a \cdot a\right) \cdot \left(a \cdot \color{blue}{{a}^{1}}\right)\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  6. Applied pow10.2

    \[\leadsto \left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), \left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{1}} \cdot {a}^{1}\right)\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  7. Applied pow-prod-up0.2

    \[\leadsto \left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), \left(a \cdot a\right) \cdot \color{blue}{{a}^{\left(1 + 1\right)}}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  8. Applied pow10.2

    \[\leadsto \left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), \left(a \cdot \color{blue}{{a}^{1}}\right) \cdot {a}^{\left(1 + 1\right)}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  9. Applied pow10.2

    \[\leadsto \left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), \left(\color{blue}{{a}^{1}} \cdot {a}^{1}\right) \cdot {a}^{\left(1 + 1\right)}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  10. Applied pow-prod-up0.2

    \[\leadsto \left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), \color{blue}{{a}^{\left(1 + 1\right)}} \cdot {a}^{\left(1 + 1\right)}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  11. Applied pow-prod-up0.1

    \[\leadsto \left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), \color{blue}{{a}^{\left(\left(1 + 1\right) + \left(1 + 1\right)\right)}}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  12. Simplified0.1

    \[\leadsto \left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), {a}^{\color{blue}{4}}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\]
  13. Final simplification0.1

    \[\leadsto \left(\mathsf{fma}\left(b \cdot b, b \cdot b, \mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), {a}^{4}\right)\right) + 4 \cdot \left(\left(1 - a \cdot 3\right) \cdot \left(b \cdot b\right) + \left(1 + a\right) \cdot \left(a \cdot a\right)\right)\right) - 1\]

Reproduce

herbie shell --seed 2019153 +o rules:numerics
(FPCore (a b)
  :name "Bouland and Aaronson, Equation (25)"
  (- (+ (pow (+ (* a a) (* b b)) 2) (* 4 (+ (* (* a a) (+ 1 a)) (* (* b b) (- 1 (* 3 a)))))) 1))