Average Error: 7.0 → 0.2
Time: 2.1s
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\]
\[\left(-3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.im + {x.re}^{3}\]
\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
\left(-3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.im + {x.re}^{3}
double f(double x_re, double x_im) {
        double r293024 = x_re;
        double r293025 = r293024 * r293024;
        double r293026 = x_im;
        double r293027 = r293026 * r293026;
        double r293028 = r293025 - r293027;
        double r293029 = r293028 * r293024;
        double r293030 = r293024 * r293026;
        double r293031 = r293026 * r293024;
        double r293032 = r293030 + r293031;
        double r293033 = r293032 * r293026;
        double r293034 = r293029 - r293033;
        return r293034;
}

double f(double x_re, double x_im) {
        double r293035 = -3.0;
        double r293036 = x_re;
        double r293037 = x_im;
        double r293038 = r293036 * r293037;
        double r293039 = r293035 * r293038;
        double r293040 = r293039 * r293037;
        double r293041 = 3.0;
        double r293042 = pow(r293036, r293041);
        double r293043 = r293040 + r293042;
        return r293043;
}

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. Simplified6.9

    \[\leadsto \color{blue}{\mathsf{fma}\left(3, x.re \cdot \left(-x.im \cdot x.im\right), {x.re}^{3}\right)}\]
  3. Using strategy rm
  4. Applied distribute-rgt-neg-in6.9

    \[\leadsto \mathsf{fma}\left(3, x.re \cdot \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)}, {x.re}^{3}\right)\]
  5. Applied associate-*r*0.2

    \[\leadsto \mathsf{fma}\left(3, \color{blue}{\left(x.re \cdot x.im\right) \cdot \left(-x.im\right)}, {x.re}^{3}\right)\]
  6. Using strategy rm
  7. Applied fma-udef0.2

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

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

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

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

Reproduce

herbie shell --seed 2020056 +o rules:numerics
(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)))