Average Error: 7.4 → 0.7
Time: 21.9s
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(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)}\right) \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
\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(\sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)}\right) \cdot \sqrt[3]{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
double f(double x_re, double x_im) {
        double r146578 = x_re;
        double r146579 = r146578 * r146578;
        double r146580 = x_im;
        double r146581 = r146580 * r146580;
        double r146582 = r146579 - r146581;
        double r146583 = r146582 * r146580;
        double r146584 = r146578 * r146580;
        double r146585 = r146580 * r146578;
        double r146586 = r146584 + r146585;
        double r146587 = r146586 * r146578;
        double r146588 = r146583 + r146587;
        return r146588;
}

double f(double x_re, double x_im) {
        double r146589 = x_re;
        double r146590 = x_im;
        double r146591 = r146589 + r146590;
        double r146592 = r146589 - r146590;
        double r146593 = r146592 * r146590;
        double r146594 = r146591 * r146593;
        double r146595 = cbrt(r146594);
        double r146596 = r146595 * r146595;
        double r146597 = r146596 * r146595;
        double r146598 = r146589 * r146590;
        double r146599 = r146590 * r146589;
        double r146600 = r146598 + r146599;
        double r146601 = r146600 * r146589;
        double r146602 = r146597 + r146601;
        return r146602;
}

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

    \[\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. Using strategy rm
  3. Applied difference-of-squares7.4

    \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  4. Applied associate-*l*0.2

    \[\leadsto \color{blue}{\left(x.re + x.im\right) \cdot \left(\left(x.re - x.im\right) \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.7

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

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

Reproduce

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