Average Error: 6.8 → 0.2
Time: 54.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 r25336959 = x_re;
        double r25336960 = r25336959 * r25336959;
        double r25336961 = x_im;
        double r25336962 = r25336961 * r25336961;
        double r25336963 = r25336960 - r25336962;
        double r25336964 = r25336963 * r25336959;
        double r25336965 = r25336959 * r25336961;
        double r25336966 = r25336961 * r25336959;
        double r25336967 = r25336965 + r25336966;
        double r25336968 = r25336967 * r25336961;
        double r25336969 = r25336964 - r25336968;
        return r25336969;
}

double f(double x_re, double x_im) {
        double r25336970 = x_re;
        double r25336971 = 3.0;
        double r25336972 = pow(r25336970, r25336971);
        double r25336973 = x_im;
        double r25336974 = r25336973 * r25336970;
        double r25336975 = r25336971 * r25336974;
        double r25336976 = r25336975 * r25336973;
        double r25336977 = r25336972 - r25336976;
        return r25336977;
}

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

Original6.8
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 6.8

    \[\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 \cdot \left(x.re \cdot x.re\right) - \left(x.re \cdot x.im\right) \cdot \left(x.im + \left(x.im + x.im\right)\right)}\]
  3. Using strategy rm
  4. Applied pow10.2

    \[\leadsto x.re \cdot \left(\color{blue}{{x.re}^{1}} \cdot x.re\right) - \left(x.re \cdot x.im\right) \cdot \left(x.im + \left(x.im + x.im\right)\right)\]
  5. Applied pow-plus0.2

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

    \[\leadsto \color{blue}{{x.re}^{1}} \cdot {x.re}^{\left(1 + 1\right)} - \left(x.re \cdot x.im\right) \cdot \left(x.im + \left(x.im + x.im\right)\right)\]
  7. Applied pow-prod-up0.2

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

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

    \[\leadsto {x.re}^{3} - \left(x.re \cdot x.im\right) \cdot \left(x.im + \left(\color{blue}{1 \cdot x.im} + x.im\right)\right)\]
  11. Applied distribute-lft1-in0.2

    \[\leadsto {x.re}^{3} - \left(x.re \cdot x.im\right) \cdot \left(x.im + \color{blue}{\left(1 + 1\right) \cdot x.im}\right)\]
  12. Applied distribute-rgt1-in0.2

    \[\leadsto {x.re}^{3} - \left(x.re \cdot x.im\right) \cdot \color{blue}{\left(\left(\left(1 + 1\right) + 1\right) \cdot x.im\right)}\]
  13. Applied associate-*r*0.2

    \[\leadsto {x.re}^{3} - \color{blue}{\left(\left(x.re \cdot x.im\right) \cdot \left(\left(1 + 1\right) + 1\right)\right) \cdot x.im}\]
  14. 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 2019124 +o rules:numerics
(FPCore (x.re x.im)
  :name "math.cube on complex, real part"

  :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)))