Average Error: 7.5 → 0.2
Time: 3.0s
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 x.re\right) \cdot \left(x.im \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
\left(3 \cdot x.re\right) \cdot \left(x.im \cdot x.re\right) - {x.im}^{3}
double f(double x_re, double x_im) {
        double r140532 = x_re;
        double r140533 = r140532 * r140532;
        double r140534 = x_im;
        double r140535 = r140534 * r140534;
        double r140536 = r140533 - r140535;
        double r140537 = r140536 * r140534;
        double r140538 = r140532 * r140534;
        double r140539 = r140534 * r140532;
        double r140540 = r140538 + r140539;
        double r140541 = r140540 * r140532;
        double r140542 = r140537 + r140541;
        return r140542;
}

double f(double x_re, double x_im) {
        double r140543 = 3.0;
        double r140544 = x_re;
        double r140545 = r140543 * r140544;
        double r140546 = x_im;
        double r140547 = r140546 * r140544;
        double r140548 = r140545 * r140547;
        double r140549 = pow(r140546, r140543);
        double r140550 = r140548 - r140549;
        return r140550;
}

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.5
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.5

    \[\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.4

    \[\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 add-cube-cbrt0.2

    \[\leadsto \color{blue}{\left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}\right)} \cdot \left(\left(x.im \cdot x.re\right) \cdot x.re\right) - {x.im}^{3}\]
  7. Applied associate-*l*0.3

    \[\leadsto \color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot \left(\left(x.im \cdot x.re\right) \cdot x.re\right)\right)} - {x.im}^{3}\]
  8. Taylor expanded around 0 7.4

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

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

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

Reproduce

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