Average Error: 7.3 → 0.3
Time: 24.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(x.re - x.im\right) \cdot \left(x.re \cdot x.im\right) + \left(\left(x.re \cdot \left(x.im + x.im\right)\right) \cdot x.re + \left(x.im \cdot x.im\right) \cdot \left(x.re - 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
\left(x.re - x.im\right) \cdot \left(x.re \cdot x.im\right) + \left(\left(x.re \cdot \left(x.im + x.im\right)\right) \cdot x.re + \left(x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)\right)
double f(double x_re, double x_im) {
        double r155745 = x_re;
        double r155746 = r155745 * r155745;
        double r155747 = x_im;
        double r155748 = r155747 * r155747;
        double r155749 = r155746 - r155748;
        double r155750 = r155749 * r155747;
        double r155751 = r155745 * r155747;
        double r155752 = r155747 * r155745;
        double r155753 = r155751 + r155752;
        double r155754 = r155753 * r155745;
        double r155755 = r155750 + r155754;
        return r155755;
}

double f(double x_re, double x_im) {
        double r155756 = x_re;
        double r155757 = x_im;
        double r155758 = r155756 - r155757;
        double r155759 = r155756 * r155757;
        double r155760 = r155758 * r155759;
        double r155761 = r155757 + r155757;
        double r155762 = r155756 * r155761;
        double r155763 = r155762 * r155756;
        double r155764 = r155757 * r155757;
        double r155765 = r155764 * r155758;
        double r155766 = r155763 + r155765;
        double r155767 = r155760 + r155766;
        return r155767;
}

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.3
Target0.3
Herbie0.3
\[\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.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\]
  2. Using strategy rm
  3. Applied difference-of-squares7.3

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

    \[\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. Taylor expanded around 0 7.2

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

    \[\leadsto \color{blue}{\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.re + x.im\right)\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  7. Using strategy rm
  8. Applied distribute-rgt-in0.3

    \[\leadsto \left(x.re - x.im\right) \cdot \color{blue}{\left(x.re \cdot x.im + x.im \cdot x.im\right)} + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re\]
  9. Applied distribute-lft-in0.3

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

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

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

    \[\leadsto \left(x.re - x.im\right) \cdot \left(x.re \cdot x.im\right) + \left(\left(x.re \cdot \left(x.im + x.im\right)\right) \cdot x.re + \left(x.im \cdot x.im\right) \cdot \left(x.re - x.im\right)\right)\]

Reproduce

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