Average Error: 6.8 → 0.2
Time: 15.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(\left(x.im \cdot x.re\right) \cdot -3\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(\left(x.im \cdot x.re\right) \cdot -3\right) \cdot x.im + {x.re}^{3}
double f(double x_re, double x_im) {
        double r74058 = x_re;
        double r74059 = r74058 * r74058;
        double r74060 = x_im;
        double r74061 = r74060 * r74060;
        double r74062 = r74059 - r74061;
        double r74063 = r74062 * r74058;
        double r74064 = r74058 * r74060;
        double r74065 = r74060 * r74058;
        double r74066 = r74064 + r74065;
        double r74067 = r74066 * r74060;
        double r74068 = r74063 - r74067;
        return r74068;
}

double f(double x_re, double x_im) {
        double r74069 = x_im;
        double r74070 = x_re;
        double r74071 = r74069 * r74070;
        double r74072 = -3.0;
        double r74073 = r74071 * r74072;
        double r74074 = r74073 * r74069;
        double r74075 = 3.0;
        double r74076 = pow(r74070, r74075);
        double r74077 = r74074 + r74076;
        return r74077;
}

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}{\mathsf{fma}\left(-x.re \cdot x.im, 3 \cdot x.im, {x.re}^{3}\right)}\]
  3. Using strategy rm
  4. Applied fma-udef0.2

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

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

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

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

Reproduce

herbie shell --seed 2019194 +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.0 x.im))))

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