Average Error: 7.0 → 0.2
Time: 2.0s
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} - \left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.im\]
\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} - \left(3 \cdot \left(x.im \cdot x.re\right)\right) \cdot x.im
double f(double x_re, double x_im) {
        double r209016 = x_re;
        double r209017 = r209016 * r209016;
        double r209018 = x_im;
        double r209019 = r209018 * r209018;
        double r209020 = r209017 - r209019;
        double r209021 = r209020 * r209016;
        double r209022 = r209016 * r209018;
        double r209023 = r209018 * r209016;
        double r209024 = r209022 + r209023;
        double r209025 = r209024 * r209018;
        double r209026 = r209021 - r209025;
        return r209026;
}

double f(double x_re, double x_im) {
        double r209027 = x_re;
        double r209028 = 3.0;
        double r209029 = pow(r209027, r209028);
        double r209030 = x_im;
        double r209031 = r209030 * r209027;
        double r209032 = r209028 * r209031;
        double r209033 = r209032 * r209030;
        double r209034 = r209029 - r209033;
        return r209034;
}

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

    \[\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. Final simplification0.2

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

Reproduce

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