Average Error: 7.2 → 0.2
Time: 8.9s
Precision: 64
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
\[\left(-3 \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) + {x.re}^{3}\]
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\left(-3 \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) + {x.re}^{3}
double f(double x_re, double x_im) {
        double r181023 = x_re;
        double r181024 = r181023 * r181023;
        double r181025 = x_im;
        double r181026 = r181025 * r181025;
        double r181027 = r181024 - r181026;
        double r181028 = r181027 * r181023;
        double r181029 = r181023 * r181025;
        double r181030 = r181025 * r181023;
        double r181031 = r181029 + r181030;
        double r181032 = r181031 * r181025;
        double r181033 = r181028 - r181032;
        return r181033;
}

double f(double x_re, double x_im) {
        double r181034 = -3.0;
        double r181035 = x_im;
        double r181036 = r181034 * r181035;
        double r181037 = x_re;
        double r181038 = r181037 * r181035;
        double r181039 = r181036 * r181038;
        double r181040 = 3.0;
        double r181041 = pow(r181037, r181040);
        double r181042 = r181039 + r181041;
        return r181042;
}

Error

Bits error versus x.re

Bits error versus x.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.2
Target0.3
Herbie0.2
\[\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right)\]

Derivation

  1. Initial program 7.2

    \[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  2. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(x.im, -3 \cdot \left(x.re \cdot x.im\right), {x.re}^{3}\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.2

    \[\leadsto \color{blue}{x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right) + {x.re}^{3}}\]
  5. Simplified0.2

    \[\leadsto \color{blue}{-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)} + {x.re}^{3}\]
  6. Using strategy rm
  7. Applied associate-*r*0.2

    \[\leadsto \color{blue}{\left(-3 \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)} + {x.re}^{3}\]
  8. Final simplification0.2

    \[\leadsto \left(-3 \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) + {x.re}^{3}\]

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"
  :precision binary64

  :herbie-target
  (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3 x.im))))

  (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))