Average Error: 7.7 → 0.2
Time: 2.3s
Precision: 64
\[\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
\[{x.re}^{3} - 3 \cdot \left(\left(x.re \cdot x.im\right) \cdot x.im\right)\]
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
{x.re}^{3} - 3 \cdot \left(\left(x.re \cdot x.im\right) \cdot x.im\right)
double f(double x_re, double x_im) {
        double r272030 = x_re;
        double r272031 = r272030 * r272030;
        double r272032 = x_im;
        double r272033 = r272032 * r272032;
        double r272034 = r272031 - r272033;
        double r272035 = r272034 * r272030;
        double r272036 = r272030 * r272032;
        double r272037 = r272032 * r272030;
        double r272038 = r272036 + r272037;
        double r272039 = r272038 * r272032;
        double r272040 = r272035 - r272039;
        return r272040;
}

double f(double x_re, double x_im) {
        double r272041 = x_re;
        double r272042 = 3.0;
        double r272043 = pow(r272041, r272042);
        double r272044 = x_im;
        double r272045 = r272041 * r272044;
        double r272046 = r272045 * r272044;
        double r272047 = r272042 * r272046;
        double r272048 = r272043 - r272047;
        return r272048;
}

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.7
Target0.3
Herbie0.2
\[\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right)\]

Derivation

  1. Initial program 7.7

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

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2020060 
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"
  :precision binary64

  :herbie-target
  (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3 x.im))))

  (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))