Average Error: 7.7 → 0.2
Time: 3.6s
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\]
\[3 \cdot \left(\left(x.im \cdot x.re\right) \cdot x.re\right) - {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
3 \cdot \left(\left(x.im \cdot x.re\right) \cdot x.re\right) - {x.im}^{3}
double f(double x_re, double x_im) {
        double r126032 = x_re;
        double r126033 = r126032 * r126032;
        double r126034 = x_im;
        double r126035 = r126034 * r126034;
        double r126036 = r126033 - r126035;
        double r126037 = r126036 * r126034;
        double r126038 = r126032 * r126034;
        double r126039 = r126034 * r126032;
        double r126040 = r126038 + r126039;
        double r126041 = r126040 * r126032;
        double r126042 = r126037 + r126041;
        return r126042;
}

double f(double x_re, double x_im) {
        double r126043 = 3.0;
        double r126044 = x_im;
        double r126045 = x_re;
        double r126046 = r126044 * r126045;
        double r126047 = r126046 * r126045;
        double r126048 = r126043 * r126047;
        double r126049 = pow(r126044, r126043);
        double r126050 = r126048 - r126049;
        return r126050;
}

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. Final simplification0.2

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

Reproduce

herbie shell --seed 2019344 
(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)))