Average Error: 6.8 → 0.2
Time: 1.3m
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} - x.im \cdot \left(3 \cdot \left(x.im \cdot x.re\right)\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} - x.im \cdot \left(3 \cdot \left(x.im \cdot x.re\right)\right)
double f(double x_re, double x_im) {
        double r41816170 = x_re;
        double r41816171 = r41816170 * r41816170;
        double r41816172 = x_im;
        double r41816173 = r41816172 * r41816172;
        double r41816174 = r41816171 - r41816173;
        double r41816175 = r41816174 * r41816170;
        double r41816176 = r41816170 * r41816172;
        double r41816177 = r41816172 * r41816170;
        double r41816178 = r41816176 + r41816177;
        double r41816179 = r41816178 * r41816172;
        double r41816180 = r41816175 - r41816179;
        return r41816180;
}

double f(double x_re, double x_im) {
        double r41816181 = x_re;
        double r41816182 = 3.0;
        double r41816183 = pow(r41816181, r41816182);
        double r41816184 = x_im;
        double r41816185 = r41816184 * r41816181;
        double r41816186 = r41816182 * r41816185;
        double r41816187 = r41816184 * r41816186;
        double r41816188 = r41816183 - r41816187;
        return r41816188;
}

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.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 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 cube-unmult0.2

    \[\leadsto \color{blue}{{x.re}^{3}} - \left(x.re \cdot x.im\right) \cdot \left(x.im + \left(x.im + x.im\right)\right)\]
  5. Using strategy rm
  6. 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)\]
  7. 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)\]
  8. 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)}\]
  9. 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}\]
  10. Simplified0.2

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

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

Reproduce

herbie shell --seed 2019128 +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)))