Average Error: 7.7 → 0.2
Time: 3.7s
Precision: 64
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
\[\left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.re - {x.im}^{3}\]
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
\left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.re - {x.im}^{3}
double f(double x_re, double x_im) {
        double r881 = x_re;
        double r882 = r881 * r881;
        double r883 = x_im;
        double r884 = r883 * r883;
        double r885 = r882 - r884;
        double r886 = r885 * r883;
        double r887 = r881 * r883;
        double r888 = r883 * r881;
        double r889 = r887 + r888;
        double r890 = r889 * r881;
        double r891 = r886 + r890;
        return r891;
}

double f(double x_re, double x_im) {
        double r892 = 3.0;
        double r893 = x_im;
        double r894 = x_re;
        double r895 = r893 * r894;
        double r896 = r892 * r895;
        double r897 = r896 * r894;
        double r898 = pow(r893, r892);
        double r899 = r897 - r898;
        return r899;
}

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.7
Target0.2
Herbie0.2
\[\left(x.re \cdot x.im\right) \cdot \left(2 \cdot x.re\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)\]

Derivation

  1. Initial program 7.7

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

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

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

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

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

Reproduce

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

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

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