Average Error: 7.3 → 0.3
Time: 9.6s
Precision: binary64
Cost: 1216
\[\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(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\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
\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)
(FPCore (x.re x.im)
 :precision binary64
 (-
  (* (- (* x.re x.re) (* x.im x.im)) x.re)
  (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
(FPCore (x.re x.im)
 :precision binary64
 (-
  (* (+ x.re x.im) (* x.re (- x.re x.im)))
  (* x.im (+ (* x.re x.im) (* x.re x.im)))))
double code(double x_46_re, double x_46_im) {
	return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
double code(double x_46_re, double x_46_im) {
	return ((x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)));
}

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.3
Target0.3
Herbie0.3
\[\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)\]

Alternatives

Alternative 1
Error7.7
Cost59712
\[\sqrt[3]{{x.re}^{3} - x.re \cdot {x.im}^{2}} \cdot \left(\sqrt[3]{{x.re}^{3} - x.re \cdot {x.im}^{2}} \cdot \sqrt[3]{{x.re}^{3} - x.re \cdot {x.im}^{2}}\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 2
Error27.9
Cost40384
\[\sqrt{\left({x.re}^{3} - x.re \cdot {x.im}^{2}\right) - x.im \cdot \left(x.re \cdot \left(x.im \cdot 2\right)\right)} \cdot \sqrt{\left({x.re}^{3} - x.re \cdot {x.im}^{2}\right) - x.im \cdot \left(x.re \cdot \left(x.im \cdot 2\right)\right)}\]
Alternative 3
Error7.8
Cost27776
\[\left(\sqrt[3]{x.re \cdot x.re - x.im \cdot x.im} \cdot \sqrt[3]{x.re \cdot x.re - x.im \cdot x.im}\right) \cdot \left(x.re \cdot \sqrt[3]{x.re \cdot x.re - {x.im}^{2}}\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 4
Error7.8
Cost27008
\[\sqrt[3]{x.re} \cdot \left(\left(x.re \cdot x.re - {x.im}^{2}\right) \cdot \left(\sqrt[3]{x.re} \cdot \sqrt[3]{x.re}\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 5
Error32.1
Cost26752
\[\sqrt[3]{{\left({x.re}^{3} - x.re \cdot {x.im}^{2}\right)}^{3}} - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 6
Error7.6
Cost21312
\[x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - \sqrt[3]{x.im \cdot \left(x.re \cdot \left(x.im \cdot 2\right)\right)} \cdot \left(\sqrt[3]{x.im \cdot \left(x.re \cdot \left(x.im \cdot 2\right)\right)} \cdot \sqrt[3]{x.im \cdot \left(x.re \cdot \left(x.im \cdot 2\right)\right)}\right)\]
Alternative 7
Error0.6
Cost21312
\[\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - \sqrt[3]{x.im \cdot \left(2 \cdot \left(x.re \cdot x.im\right)\right)} \cdot \left(\sqrt[3]{x.im \cdot \left(2 \cdot \left(x.re \cdot x.im\right)\right)} \cdot \sqrt[3]{x.im \cdot \left(2 \cdot \left(x.re \cdot x.im\right)\right)}\right)\]
Alternative 8
Error0.8
Cost21184
\[\left(x.re + x.im\right) \cdot \left(\sqrt[3]{x.re \cdot \left(x.re - x.im\right)} \cdot \left(\sqrt[3]{x.re \cdot \left(x.re - x.im\right)} \cdot \sqrt[3]{x.re \cdot \left(x.re - x.im\right)}\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 9
Error0.7
Cost20928
\[\left(\sqrt[3]{x.re + x.im} \cdot \sqrt[3]{x.re + x.im}\right) \cdot \left(\left(x.re \cdot \left(x.re - x.im\right)\right) \cdot \sqrt[3]{x.re + x.im}\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 10
Error0.7
Cost20672
\[\left(x.re + x.im\right) \cdot \left(\left(\sqrt[3]{x.re} \cdot \sqrt[3]{x.re}\right) \cdot \left(\sqrt[3]{x.re} \cdot \left(x.re - x.im\right)\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 11
Error0.6
Cost20544
\[\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - \sqrt[3]{x.im} \cdot \left(\left(2 \cdot \left(x.re \cdot x.im\right)\right) \cdot \left(\sqrt[3]{x.im} \cdot \sqrt[3]{x.im}\right)\right)\]
Alternative 12
Error29.7
Cost14400
\[x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - \sqrt{x.re \cdot x.im + x.re \cdot x.im} \cdot \left(x.im \cdot \sqrt{x.re \cdot \left(x.im \cdot 2\right)}\right)\]
Alternative 13
Error32.1
Cost14400
\[\frac{x.re \cdot \left({x.re}^{4} - {x.im}^{4}\right)}{x.re \cdot x.re + x.im \cdot x.im} - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 14
Error26.0
Cost14400
\[\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - \sqrt{x.re \cdot x.im + x.re \cdot x.im} \cdot \left(x.im \cdot \sqrt{2 \cdot \left(x.re \cdot x.im\right)}\right)\]
Alternative 15
Error20.5
Cost14400
\[\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - \sqrt{x.im \cdot \left(2 \cdot \left(x.re \cdot x.im\right)\right)} \cdot \sqrt{x.im \cdot \left(2 \cdot \left(x.re \cdot x.im\right)\right)}\]
Alternative 16
Error29.7
Cost14272
\[x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(\sqrt{x.re \cdot \left(x.im \cdot 2\right)} \cdot \sqrt{x.re \cdot \left(x.im \cdot 2\right)}\right)\]
Alternative 17
Error31.9
Cost14272
\[\sqrt{x.re + x.im} \cdot \left(\left(x.re \cdot \left(x.re - x.im\right)\right) \cdot \sqrt{x.re + x.im}\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 18
Error32.5
Cost14144
\[\left(x.re \cdot x.re\right) \cdot \left(x.re + x.im\right) + \sqrt{-x.im} \cdot \left(\sqrt{-x.im} \cdot \left(x.re \cdot \left(x.re + 3 \cdot x.im\right)\right)\right)\]
Alternative 19
Error32.8
Cost14144
\[\left(x.re + x.im\right) \cdot \left(\sqrt{x.re} \cdot \left(\left(x.re - x.im\right) \cdot \sqrt{x.re}\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 20
Error21.3
Cost14080
\[\left(x.re + x.im\right) \cdot \sqrt[3]{{\left(x.re \cdot \left(x.re - x.im\right)\right)}^{3}} - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 21
Error31.8
Cost14016
\[\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - \sqrt{x.im} \cdot \left(\left(2 \cdot \left(x.re \cdot x.im\right)\right) \cdot \sqrt{x.im}\right)\]
Alternative 22
Error19.1
Cost13952
\[x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \sqrt[3]{{\left(x.re \cdot x.im\right)}^{3} \cdot 8}\]
Alternative 23
Error20.6
Cost13952
\[x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - \sqrt[3]{{\left(x.im \cdot \left(x.re \cdot \left(x.im \cdot 2\right)\right)\right)}^{3}}\]
Alternative 24
Error45.9
Cost9088
\[x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - \frac{x.im \cdot \left(2 \cdot {\left(x.re \cdot x.im\right)}^{3}\right)}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) + \left(\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)\right)}\]
Alternative 25
Error41.5
Cost9088
\[\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - \frac{x.im \cdot \left(2 \cdot {\left(x.re \cdot x.im\right)}^{3}\right)}{\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) + \left(\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right) - \left(x.re \cdot x.im\right) \cdot \left(x.re \cdot x.im\right)\right)}\]
Alternative 26
Error23.9
Cost8704
\[\left(x.re \cdot x.re\right) \cdot \left(x.re + x.im\right) + \frac{x.im \cdot \left(\left(x.re \cdot \left(x.re + 3 \cdot x.im\right)\right) \cdot \left(x.re \cdot x.im - {x.re}^{2}\right)\right)}{x.re \cdot \left(x.re + x.im\right) - 2 \cdot \left(x.re \cdot x.im\right)}\]
Alternative 27
Error7.3
Cost7040
\[{x.re}^{3} + x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\]
Alternative 28
Error25.8
Cost6784
\[{x.im}^{2} \cdot \left(x.re \cdot -3\right)\]
Alternative 29
Error28.7
Cost6528
\[{x.re}^{3}\]
Alternative 30
Error0.2
Cost1344
\[\left(x.re \cdot x.re\right) \cdot \left(x.re + x.im\right) - x.im \cdot \left(x.re \cdot \left(x.re + x.im\right) + 2 \cdot \left(x.re \cdot x.im\right)\right)\]
Alternative 31
Error0.2
Cost1216
\[\left(x.re \cdot x.re\right) \cdot \left(x.re + x.im\right) + x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right) - x.re \cdot x.re\right)\]
Alternative 32
Error7.3
Cost1216
\[x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 33
Error18.7
Cost1152
\[\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(-x.im\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]
Alternative 34
Error7.3
Cost1088
\[x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot \left(x.im \cdot 2\right)\right)\]
Alternative 35
Error7.4
Cost1088
\[\left(x.re \cdot x.re\right) \cdot \left(x.re + x.im\right) - x.re \cdot \left(x.im \cdot \left(x.re + 3 \cdot x.im\right)\right)\]
Alternative 36
Error0.3
Cost1088
\[\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - x.im \cdot \left(2 \cdot \left(x.re \cdot x.im\right)\right)\]
Alternative 37
Error0.2
Cost1088
\[\left(x.re \cdot x.re\right) \cdot \left(x.re + x.im\right) - x.im \cdot \left(x.re \cdot \left(x.re + 3 \cdot x.im\right)\right)\]
Alternative 38
Error1.0
Cost960
\[\left(x.re \cdot x.re\right) \cdot \left(x.re + x.im\right) + x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\]
Alternative 39
Error1.0
Cost960
\[\left(x.re \cdot x.re\right) \cdot \left(x.re + x.im\right) - x.im \cdot \left(x.re \cdot \left(3 \cdot x.im\right)\right)\]
Alternative 40
Error28.7
Cost832
\[\left(x.re \cdot x.re\right) \cdot \left(x.re + x.im\right) - x.im \cdot \left(x.re \cdot x.re\right)\]
Alternative 41
Error61.8
Cost64
\[1\]
Alternative 42
Error46.7
Cost64
\[0\]
Alternative 43
Error61.9
Cost64
\[-1\]

Error

Derivation

  1. Initial program 7.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\]
  2. Using strategy rm
  3. Applied difference-of-squares_binary64_31167.3

    \[\leadsto \color{blue}{\left(\left(x.re + x.im\right) \cdot \left(x.re - x.im\right)\right)} \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\]
  4. Applied associate-*l*_binary64_30880.3

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

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

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

    \[\leadsto \left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\]

Reproduce

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

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