| Alternative 1 | |
|---|---|
| Accuracy | 92.7% |
| Cost | 27344 |

(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))
(FPCore (x.re x.im y.re y.im) :precision binary64 (- (* (/ 1.0 (hypot y.re y.im)) (/ y.re (/ (hypot y.re y.im) x.im))) (* (/ y.im (hypot y.im y.re)) (/ x.re (hypot y.im y.re)))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((1.0 / hypot(y_46_re, y_46_im)) * (y_46_re / (hypot(y_46_re, y_46_im) / x_46_im))) - ((y_46_im / hypot(y_46_im, y_46_re)) * (x_46_re / hypot(y_46_im, y_46_re)));
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im));
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return ((1.0 / Math.hypot(y_46_re, y_46_im)) * (y_46_re / (Math.hypot(y_46_re, y_46_im) / x_46_im))) - ((y_46_im / Math.hypot(y_46_im, y_46_re)) * (x_46_re / Math.hypot(y_46_im, y_46_re)));
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im))
def code(x_46_re, x_46_im, y_46_re, y_46_im): return ((1.0 / math.hypot(y_46_re, y_46_im)) * (y_46_re / (math.hypot(y_46_re, y_46_im) / x_46_im))) - ((y_46_im / math.hypot(y_46_im, y_46_re)) * (x_46_re / math.hypot(y_46_im, y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(x_46_im * y_46_re) - Float64(x_46_re * y_46_im)) / Float64(Float64(y_46_re * y_46_re) + Float64(y_46_im * y_46_im))) end
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(Float64(1.0 / hypot(y_46_re, y_46_im)) * Float64(y_46_re / Float64(hypot(y_46_re, y_46_im) / x_46_im))) - Float64(Float64(y_46_im / hypot(y_46_im, y_46_re)) * Float64(x_46_re / hypot(y_46_im, y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((x_46_im * y_46_re) - (x_46_re * y_46_im)) / ((y_46_re * y_46_re) + (y_46_im * y_46_im)); end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = ((1.0 / hypot(y_46_re, y_46_im)) * (y_46_re / (hypot(y_46_re, y_46_im) / x_46_im))) - ((y_46_im / hypot(y_46_im, y_46_re)) * (x_46_re / hypot(y_46_im, y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(x$46$im * y$46$re), $MachinePrecision] - N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision] / N[(N[(y$46$re * y$46$re), $MachinePrecision] + N[(y$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(N[(1.0 / N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision]), $MachinePrecision] * N[(y$46$re / N[(N[Sqrt[y$46$re ^ 2 + y$46$im ^ 2], $MachinePrecision] / x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y$46$im / N[Sqrt[y$46$im ^ 2 + y$46$re ^ 2], $MachinePrecision]), $MachinePrecision] * N[(x$46$re / N[Sqrt[y$46$im ^ 2 + y$46$re ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}
Results
Initial program 63.3%
Applied egg-rr72.5%
[Start]63.3 | \[ \frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\] |
|---|---|
div-sub [=>]61.2 | \[ \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}}
\] |
*-un-lft-identity [=>]61.2 | \[ \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re\right)}}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\] |
add-sqr-sqrt [=>]61.2 | \[ \frac{1 \cdot \left(x.im \cdot y.re\right)}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\] |
times-frac [=>]61.3 | \[ \color{blue}{\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}
\] |
fma-neg [=>]61.3 | \[ \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right)}
\] |
hypot-def [=>]61.3 | \[ \mathsf{fma}\left(\frac{1}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, \frac{x.im \cdot y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right)
\] |
hypot-def [=>]68.3 | \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)}}, -\frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\right)
\] |
associate-/l* [=>]72.5 | \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\color{blue}{\frac{x.re}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.im}}}\right)
\] |
add-sqr-sqrt [=>]72.5 | \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}{y.im}}\right)
\] |
pow2 [=>]72.5 | \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{\color{blue}{{\left(\sqrt{y.re \cdot y.re + y.im \cdot y.im}\right)}^{2}}}{y.im}}\right)
\] |
hypot-def [=>]72.5 | \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\color{blue}{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}}^{2}}{y.im}}\right)
\] |
Simplified76.9%
[Start]72.5 | \[ \mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)}, \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)}, -\frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}\right)
\] |
|---|---|
fma-neg [<=]72.5 | \[ \color{blue}{\frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{x.im \cdot y.re}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}}
\] |
*-commutative [<=]72.5 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{\color{blue}{y.re \cdot x.im}}{\mathsf{hypot}\left(y.re, y.im\right)} - \frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}
\] |
associate-/l* [=>]81.8 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \color{blue}{\frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}}} - \frac{x.re}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{y.im}}
\] |
associate-/l* [<=]76.4 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \color{blue}{\frac{x.re \cdot y.im}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}}
\] |
*-commutative [=>]76.4 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{\color{blue}{y.im \cdot x.re}}{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}
\] |
associate-/l* [=>]76.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \color{blue}{\frac{y.im}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{x.re}}}
\] |
Applied egg-rr83.9%
[Start]76.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\frac{{\left(\mathsf{hypot}\left(y.re, y.im\right)\right)}^{2}}{x.re}}
\] |
|---|---|
unpow2 [=>]76.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\frac{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right) \cdot \mathsf{hypot}\left(y.re, y.im\right)}}{x.re}}
\] |
*-un-lft-identity [=>]76.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\frac{\mathsf{hypot}\left(y.re, y.im\right) \cdot \mathsf{hypot}\left(y.re, y.im\right)}{\color{blue}{1 \cdot x.re}}}
\] |
times-frac [=>]83.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\color{blue}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{1} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}}}
\] |
/-rgt-identity [=>]83.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\color{blue}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}}
\] |
hypot-udef [=>]76.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}}
\] |
+-commutative [=>]76.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}}
\] |
hypot-def [=>]83.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\color{blue}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.re}}
\] |
hypot-udef [=>]76.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}{x.re}}
\] |
+-commutative [=>]76.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\sqrt{\color{blue}{y.im \cdot y.im + y.re \cdot y.re}}}{x.re}}
\] |
hypot-def [=>]83.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\color{blue}{\mathsf{hypot}\left(y.im, y.re\right)}}{x.re}}
\] |
Applied egg-rr98.7%
[Start]83.9 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right) \cdot \frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.re}}
\] |
|---|---|
associate-/r* [=>]98.1 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \color{blue}{\frac{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)}}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.re}}}
\] |
div-inv [=>]98.1 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \color{blue}{\frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \frac{1}{\frac{\mathsf{hypot}\left(y.im, y.re\right)}{x.re}}}
\] |
clear-num [<=]98.7 | \[ \frac{1}{\mathsf{hypot}\left(y.re, y.im\right)} \cdot \frac{y.re}{\frac{\mathsf{hypot}\left(y.re, y.im\right)}{x.im}} - \frac{y.im}{\mathsf{hypot}\left(y.im, y.re\right)} \cdot \color{blue}{\frac{x.re}{\mathsf{hypot}\left(y.im, y.re\right)}}
\] |
Final simplification98.7%
| Alternative 1 | |
|---|---|
| Accuracy | 92.7% |
| Cost | 27344 |
| Alternative 2 | |
|---|---|
| Accuracy | 89.6% |
| Cost | 27080 |
| Alternative 3 | |
|---|---|
| Accuracy | 89.1% |
| Cost | 14788 |
| Alternative 4 | |
|---|---|
| Accuracy | 86.2% |
| Cost | 14288 |
| Alternative 5 | |
|---|---|
| Accuracy | 84.5% |
| Cost | 14160 |
| Alternative 6 | |
|---|---|
| Accuracy | 83.0% |
| Cost | 1488 |
| Alternative 7 | |
|---|---|
| Accuracy | 71.3% |
| Cost | 1106 |
| Alternative 8 | |
|---|---|
| Accuracy | 72.0% |
| Cost | 1105 |
| Alternative 9 | |
|---|---|
| Accuracy | 78.0% |
| Cost | 969 |
| Alternative 10 | |
|---|---|
| Accuracy | 63.1% |
| Cost | 521 |
| Alternative 11 | |
|---|---|
| Accuracy | 42.4% |
| Cost | 192 |
herbie shell --seed 2023159
(FPCore (x.re x.im y.re y.im)
:name "_divideComplex, imaginary part"
:precision binary64
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))