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)));
}
Try it out
Enter valid numbers for all inputs
Target
| Original | 7.3 |
|---|
| Target | 0.3 |
|---|
| Herbie | 0.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 |
|---|
| Error | 7.7 |
|---|
| Cost | 59712 |
|---|
\[\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 |
|---|
| Error | 27.9 |
|---|
| Cost | 40384 |
|---|
\[\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 |
|---|
| Error | 7.8 |
|---|
| Cost | 27776 |
|---|
\[\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 |
|---|
| Error | 7.8 |
|---|
| Cost | 27008 |
|---|
\[\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 |
|---|
| Error | 32.1 |
|---|
| Cost | 26752 |
|---|
\[\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 |
|---|
| Error | 7.6 |
|---|
| Cost | 21312 |
|---|
\[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 |
|---|
| Error | 0.6 |
|---|
| Cost | 21312 |
|---|
\[\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 |
|---|
| Error | 0.8 |
|---|
| Cost | 21184 |
|---|
\[\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 |
|---|
| Error | 0.7 |
|---|
| Cost | 20928 |
|---|
\[\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 |
|---|
| Error | 0.7 |
|---|
| Cost | 20672 |
|---|
\[\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 |
|---|
| Error | 0.6 |
|---|
| Cost | 20544 |
|---|
\[\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 |
|---|
| Error | 29.7 |
|---|
| Cost | 14400 |
|---|
\[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 |
|---|
| Error | 32.1 |
|---|
| Cost | 14400 |
|---|
\[\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 |
|---|
| Error | 26.0 |
|---|
| Cost | 14400 |
|---|
\[\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 |
|---|
| Error | 20.5 |
|---|
| Cost | 14400 |
|---|
\[\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 |
|---|
| Error | 29.7 |
|---|
| Cost | 14272 |
|---|
\[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 |
|---|
| Error | 31.9 |
|---|
| Cost | 14272 |
|---|
\[\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 |
|---|
| Error | 32.5 |
|---|
| Cost | 14144 |
|---|
\[\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 |
|---|
| Error | 32.8 |
|---|
| Cost | 14144 |
|---|
\[\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 |
|---|
| Error | 21.3 |
|---|
| Cost | 14080 |
|---|
\[\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 |
|---|
| Error | 31.8 |
|---|
| Cost | 14016 |
|---|
\[\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 |
|---|
| Error | 19.1 |
|---|
| Cost | 13952 |
|---|
\[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 |
|---|
| Error | 20.6 |
|---|
| Cost | 13952 |
|---|
\[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 |
|---|
| Error | 45.9 |
|---|
| Cost | 9088 |
|---|
\[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 |
|---|
| Error | 41.5 |
|---|
| Cost | 9088 |
|---|
\[\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 |
|---|
| Error | 23.9 |
|---|
| Cost | 8704 |
|---|
\[\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 |
|---|
| Error | 7.3 |
|---|
| Cost | 7040 |
|---|
\[{x.re}^{3} + x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\]
| Alternative 28 |
|---|
| Error | 25.8 |
|---|
| Cost | 6784 |
|---|
\[{x.im}^{2} \cdot \left(x.re \cdot -3\right)\]
| Alternative 29 |
|---|
| Error | 28.7 |
|---|
| Cost | 6528 |
|---|
\[{x.re}^{3}\]
| Alternative 30 |
|---|
| Error | 0.2 |
|---|
| Cost | 1344 |
|---|
\[\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 |
|---|
| Error | 0.2 |
|---|
| Cost | 1216 |
|---|
\[\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 |
|---|
| Error | 7.3 |
|---|
| Cost | 1216 |
|---|
\[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 |
|---|
| Error | 18.7 |
|---|
| Cost | 1152 |
|---|
\[\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 |
|---|
| Error | 7.3 |
|---|
| Cost | 1088 |
|---|
\[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 |
|---|
| Error | 7.4 |
|---|
| Cost | 1088 |
|---|
\[\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 |
|---|
| Error | 0.3 |
|---|
| Cost | 1088 |
|---|
\[\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 |
|---|
| Error | 0.2 |
|---|
| Cost | 1088 |
|---|
\[\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 |
|---|
| Error | 1.0 |
|---|
| Cost | 960 |
|---|
\[\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 |
|---|
| Error | 1.0 |
|---|
| Cost | 960 |
|---|
\[\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 |
|---|
| Error | 28.7 |
|---|
| Cost | 832 |
|---|
\[\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 |
|---|
| Error | 61.8 |
|---|
| Cost | 64 |
|---|
\[1\]
| Alternative 42 |
|---|
| Error | 46.7 |
|---|
| Cost | 64 |
|---|
\[0\]
| Alternative 43 |
|---|
| Error | 61.9 |
|---|
| Cost | 64 |
|---|
\[-1\]
Error

Derivation
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\]
- Using strategy
rm 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\]
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\]
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\]
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)}\]
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)))