Average Error: 7.5 → 0.2
Time: 12.4s
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 r258779 = x_re;
        double r258780 = r258779 * r258779;
        double r258781 = x_im;
        double r258782 = r258781 * r258781;
        double r258783 = r258780 - r258782;
        double r258784 = r258783 * r258781;
        double r258785 = r258779 * r258781;
        double r258786 = r258781 * r258779;
        double r258787 = r258785 + r258786;
        double r258788 = r258787 * r258779;
        double r258789 = r258784 + r258788;
        return r258789;
}

double f(double x_re, double x_im) {
        double r258790 = 3.0;
        double r258791 = x_im;
        double r258792 = x_re;
        double r258793 = r258791 * r258792;
        double r258794 = r258790 * r258793;
        double r258795 = r258794 * r258792;
        double r258796 = pow(r258791, r258790);
        double r258797 = r258795 - r258796;
        return r258797;
}

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. Simplified0.2

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

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

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

    \[\leadsto \left(3 \cdot \color{blue}{\left(x.im \cdot x.re\right)}\right) \cdot x.re - {x.im}^{3}\]
  8. 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 2019209 
(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)))