Average Error: 7.0 → 0.6
Time: 41.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\]
\[x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \left(x.im + x.re\right) \cdot \left(\frac{\sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.im\right) \cdot \left(x.im + x.re\right)}}{\sqrt[3]{x.im + x.re}} \cdot \left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right)\right)\]
\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
x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) + \left(x.im + x.re\right) \cdot \left(\frac{\sqrt[3]{\left(\left(x.re - x.im\right) \cdot x.im\right) \cdot \left(x.im + x.re\right)}}{\sqrt[3]{x.im + x.re}} \cdot \left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right)\right)
double f(double x_re, double x_im) {
        double r7198655 = x_re;
        double r7198656 = r7198655 * r7198655;
        double r7198657 = x_im;
        double r7198658 = r7198657 * r7198657;
        double r7198659 = r7198656 - r7198658;
        double r7198660 = r7198659 * r7198657;
        double r7198661 = r7198655 * r7198657;
        double r7198662 = r7198657 * r7198655;
        double r7198663 = r7198661 + r7198662;
        double r7198664 = r7198663 * r7198655;
        double r7198665 = r7198660 + r7198664;
        return r7198665;
}

double f(double x_re, double x_im) {
        double r7198666 = x_re;
        double r7198667 = x_im;
        double r7198668 = r7198666 * r7198667;
        double r7198669 = r7198668 + r7198668;
        double r7198670 = r7198666 * r7198669;
        double r7198671 = r7198667 + r7198666;
        double r7198672 = r7198666 - r7198667;
        double r7198673 = r7198672 * r7198667;
        double r7198674 = r7198673 * r7198671;
        double r7198675 = cbrt(r7198674);
        double r7198676 = cbrt(r7198671);
        double r7198677 = r7198675 / r7198676;
        double r7198678 = cbrt(r7198673);
        double r7198679 = r7198678 * r7198678;
        double r7198680 = r7198677 * r7198679;
        double r7198681 = r7198671 * r7198680;
        double r7198682 = r7198670 + r7198681;
        return r7198682;
}

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

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

    \[\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 \left(x.re + x.im\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right) \cdot \sqrt[3]{\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. Using strategy rm
  8. Applied flip--7.5

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right) \cdot \sqrt[3]{\color{blue}{\frac{x.re \cdot x.re - x.im \cdot x.im}{x.re + x.im}} \cdot x.im}\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  9. Applied associate-*l/7.4

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right) \cdot \sqrt[3]{\color{blue}{\frac{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}{x.re + x.im}}}\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  10. Applied cbrt-div7.4

    \[\leadsto \left(x.re + x.im\right) \cdot \left(\left(\sqrt[3]{\left(x.re - x.im\right) \cdot x.im} \cdot \sqrt[3]{\left(x.re - x.im\right) \cdot x.im}\right) \cdot \color{blue}{\frac{\sqrt[3]{\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im}}{\sqrt[3]{x.re + x.im}}}\right) + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  11. Simplified0.6

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

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

Reproduce

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

  :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)))