| Alternative 1 | |
|---|---|
| Accuracy | 95.9% |
| Cost | 968 |

(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
(if (<= x.im -2.05e+133)
(* (* x.im (* x.im x.re)) -3.0)
(if (<= x.im 7.6e+153)
(* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0))))
(* x.im (* (* x.im x.re) -3.0)))))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) {
double tmp;
if (x_46_im <= -2.05e+133) {
tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0;
} else if (x_46_im <= 7.6e+153) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = x_46_im * ((x_46_im * x_46_re) * -3.0);
}
return tmp;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if (x_46im <= (-2.05d+133)) then
tmp = (x_46im * (x_46im * x_46re)) * (-3.0d0)
else if (x_46im <= 7.6d+153) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = x_46im * ((x_46im * x_46re) * (-3.0d0))
end if
code = tmp
end function
public static 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);
}
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= -2.05e+133) {
tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0;
} else if (x_46_im <= 7.6e+153) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = x_46_im * ((x_46_im * x_46_re) * -3.0);
}
return tmp;
}
def code(x_46_re, 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)
def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= -2.05e+133: tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0 elif x_46_im <= 7.6e+153: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) else: tmp = x_46_im * ((x_46_im * x_46_re) * -3.0) return tmp
function code(x_46_re, x_46_im) return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im)) end
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= -2.05e+133) tmp = Float64(Float64(x_46_im * Float64(x_46_im * x_46_re)) * -3.0); elseif (x_46_im <= 7.6e+153) tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * Float64(x_46_im * -3.0)))); else tmp = Float64(x_46_im * Float64(Float64(x_46_im * x_46_re) * -3.0)); end return tmp end
function tmp = code(x_46_re, x_46_im) tmp = (((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); end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= -2.05e+133) tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0; elseif (x_46_im <= 7.6e+153) tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); else tmp = x_46_im * ((x_46_im * x_46_re) * -3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -2.05e+133], N[(N[(x$46$im * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision], If[LessEqual[x$46$im, 7.6e+153], N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$im * x$46$re), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]]]
\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
\begin{array}{l}
\mathbf{if}\;x.im \leq -2.05 \cdot 10^{+133}:\\
\;\;\;\;\left(x.im \cdot \left(x.im \cdot x.re\right)\right) \cdot -3\\
\mathbf{elif}\;x.im \leq 7.6 \cdot 10^{+153}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(\left(x.im \cdot x.re\right) \cdot -3\right)\\
\end{array}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 82.5% |
|---|---|
| Target | 86.8% |
| Herbie | 95.9% |
if x.im < -2.05000000000000002e133Initial program 64.3%
Simplified73.5%
[Start]64.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
\] |
|---|---|
*-commutative [<=]64.3% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im
\] |
distribute-lft-out [=>]64.3% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im
\] |
associate-*l* [=>]64.3% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)}
\] |
*-commutative [=>]64.3% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re}
\] |
distribute-rgt-out-- [=>]64.2% | \[ \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}
\] |
associate--l- [=>]64.2% | \[ x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)}
\] |
associate--l- [<=]64.2% | \[ x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}
\] |
sub-neg [=>]64.2% | \[ x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right)
\] |
associate--l+ [=>]64.2% | \[ x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)}
\] |
fma-udef [<=]73.5% | \[ x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}
\] |
neg-mul-1 [=>]73.5% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right)
\] |
count-2 [=>]73.5% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right)
\] |
associate-*l* [=>]73.5% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right)
\] |
distribute-rgt-out-- [=>]73.5% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right)
\] |
associate-*r* [<=]73.5% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right)
\] |
metadata-eval [=>]73.5% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right)
\] |
Taylor expanded in x.re around 0 73.6%
Simplified73.5%
[Start]73.6% | \[ -3 \cdot \left(x.re \cdot {x.im}^{2}\right)
\] |
|---|---|
associate-*r* [=>]73.5% | \[ \color{blue}{\left(-3 \cdot x.re\right) \cdot {x.im}^{2}}
\] |
*-commutative [=>]73.5% | \[ \color{blue}{{x.im}^{2} \cdot \left(-3 \cdot x.re\right)}
\] |
*-commutative [=>]73.5% | \[ {x.im}^{2} \cdot \color{blue}{\left(x.re \cdot -3\right)}
\] |
metadata-eval [<=]73.5% | \[ {x.im}^{2} \cdot \left(x.re \cdot \color{blue}{\left(-2 + -1\right)}\right)
\] |
distribute-rgt-out [<=]73.5% | \[ {x.im}^{2} \cdot \color{blue}{\left(-2 \cdot x.re + -1 \cdot x.re\right)}
\] |
distribute-lft-in [=>]73.6% | \[ \color{blue}{{x.im}^{2} \cdot \left(-2 \cdot x.re\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)}
\] |
metadata-eval [<=]73.6% | \[ {x.im}^{2} \cdot \left(\color{blue}{\left(-2\right)} \cdot x.re\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-lft-neg-in [<=]73.6% | \[ {x.im}^{2} \cdot \color{blue}{\left(-2 \cdot x.re\right)} + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
count-2 [<=]73.6% | \[ {x.im}^{2} \cdot \left(-\color{blue}{\left(x.re + x.re\right)}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-rgt-neg-in [<=]73.6% | \[ \color{blue}{\left(-{x.im}^{2} \cdot \left(x.re + x.re\right)\right)} + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-rgt-out [<=]73.6% | \[ \left(-\color{blue}{\left(x.re \cdot {x.im}^{2} + x.re \cdot {x.im}^{2}\right)}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-lft-out [=>]73.6% | \[ \left(-\color{blue}{x.re \cdot \left({x.im}^{2} + {x.im}^{2}\right)}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-rgt-neg-in [=>]73.6% | \[ \color{blue}{x.re \cdot \left(-\left({x.im}^{2} + {x.im}^{2}\right)\right)} + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
count-2 [=>]73.6% | \[ x.re \cdot \left(-\color{blue}{2 \cdot {x.im}^{2}}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-lft-neg-in [=>]73.6% | \[ x.re \cdot \color{blue}{\left(\left(-2\right) \cdot {x.im}^{2}\right)} + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
metadata-eval [=>]73.6% | \[ x.re \cdot \left(\color{blue}{-2} \cdot {x.im}^{2}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
mul-1-neg [=>]73.6% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + {x.im}^{2} \cdot \color{blue}{\left(-x.re\right)}
\] |
distribute-rgt-neg-in [<=]73.6% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{\left(-{x.im}^{2} \cdot x.re\right)}
\] |
distribute-lft-neg-in [=>]73.6% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{\left(-{x.im}^{2}\right) \cdot x.re}
\] |
unpow2 [=>]73.6% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \left(-\color{blue}{x.im \cdot x.im}\right) \cdot x.re
\] |
distribute-rgt-neg-out [<=]73.6% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)} \cdot x.re
\] |
*-commutative [<=]73.6% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)}
\] |
Applied egg-rr46.4%
[Start]73.5% | \[ x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)
\] |
|---|---|
add-sqr-sqrt [=>]35.8% | \[ \color{blue}{\sqrt{x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)} \cdot \sqrt{x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)}}
\] |
pow2 [=>]35.8% | \[ \color{blue}{{\left(\sqrt{x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)}\right)}^{2}}
\] |
associate-*r* [=>]35.8% | \[ {\left(\sqrt{\color{blue}{\left(x.re \cdot -3\right) \cdot \left(x.im \cdot x.im\right)}}\right)}^{2}
\] |
sqrt-prod [=>]35.8% | \[ {\color{blue}{\left(\sqrt{x.re \cdot -3} \cdot \sqrt{x.im \cdot x.im}\right)}}^{2}
\] |
sqrt-prod [=>]0.0% | \[ {\left(\sqrt{x.re \cdot -3} \cdot \color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)}\right)}^{2}
\] |
add-sqr-sqrt [<=]46.4% | \[ {\left(\sqrt{x.re \cdot -3} \cdot \color{blue}{x.im}\right)}^{2}
\] |
Applied egg-rr93.0%
[Start]46.4% | \[ {\left(\sqrt{x.re \cdot -3} \cdot x.im\right)}^{2}
\] |
|---|---|
unpow2 [=>]46.4% | \[ \color{blue}{\left(\sqrt{x.re \cdot -3} \cdot x.im\right) \cdot \left(\sqrt{x.re \cdot -3} \cdot x.im\right)}
\] |
swap-sqr [=>]35.7% | \[ \color{blue}{\left(\sqrt{x.re \cdot -3} \cdot \sqrt{x.re \cdot -3}\right) \cdot \left(x.im \cdot x.im\right)}
\] |
add-sqr-sqrt [<=]73.5% | \[ \color{blue}{\left(x.re \cdot -3\right)} \cdot \left(x.im \cdot x.im\right)
\] |
*-commutative [=>]73.5% | \[ \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(x.re \cdot -3\right)}
\] |
associate-*l* [<=]73.6% | \[ \color{blue}{\left(\left(x.im \cdot x.im\right) \cdot x.re\right) \cdot -3}
\] |
*-commutative [<=]73.6% | \[ \color{blue}{\left(x.re \cdot \left(x.im \cdot x.im\right)\right)} \cdot -3
\] |
*-commutative [=>]73.6% | \[ \color{blue}{\left(\left(x.im \cdot x.im\right) \cdot x.re\right)} \cdot -3
\] |
associate-*l* [=>]93.0% | \[ \color{blue}{\left(x.im \cdot \left(x.im \cdot x.re\right)\right)} \cdot -3
\] |
if -2.05000000000000002e133 < x.im < 7.59999999999999933e153Initial program 91.9%
Simplified99.8%
[Start]91.9% | \[ \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
\] |
|---|---|
*-commutative [<=]91.9% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im
\] |
distribute-lft-out [=>]91.9% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im
\] |
associate-*l* [=>]91.9% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)}
\] |
*-commutative [=>]91.9% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re}
\] |
distribute-rgt-out-- [=>]99.8% | \[ \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}
\] |
associate--l- [=>]99.8% | \[ x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)}
\] |
associate--l- [<=]99.8% | \[ x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}
\] |
sub-neg [=>]99.8% | \[ x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right)
\] |
associate--l+ [=>]99.8% | \[ x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)}
\] |
fma-udef [<=]99.8% | \[ x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}
\] |
neg-mul-1 [=>]99.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right)
\] |
count-2 [=>]99.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right)
\] |
associate-*l* [=>]99.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right)
\] |
distribute-rgt-out-- [=>]99.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right)
\] |
associate-*r* [<=]99.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right)
\] |
metadata-eval [=>]99.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right)
\] |
Applied egg-rr99.8%
[Start]99.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)
\] |
|---|---|
fma-udef [=>]99.8% | \[ x.re \cdot \color{blue}{\left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)}
\] |
if 7.59999999999999933e153 < x.im Initial program 53.7%
Simplified66.8%
[Start]53.7% | \[ \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
\] |
|---|---|
*-commutative [<=]53.7% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + \color{blue}{x.re \cdot x.im}\right) \cdot x.im
\] |
distribute-lft-out [=>]53.7% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(x.re \cdot \left(x.im + x.im\right)\right)} \cdot x.im
\] |
associate-*l* [=>]53.7% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{x.re \cdot \left(\left(x.im + x.im\right) \cdot x.im\right)}
\] |
*-commutative [=>]53.7% | \[ \left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \color{blue}{\left(\left(x.im + x.im\right) \cdot x.im\right) \cdot x.re}
\] |
distribute-rgt-out-- [=>]53.7% | \[ \color{blue}{x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}
\] |
associate--l- [=>]53.7% | \[ x.re \cdot \color{blue}{\left(x.re \cdot x.re - \left(x.im \cdot x.im + \left(x.im + x.im\right) \cdot x.im\right)\right)}
\] |
associate--l- [<=]53.7% | \[ x.re \cdot \color{blue}{\left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}
\] |
sub-neg [=>]53.7% | \[ x.re \cdot \left(\color{blue}{\left(x.re \cdot x.re + \left(-x.im \cdot x.im\right)\right)} - \left(x.im + x.im\right) \cdot x.im\right)
\] |
associate--l+ [=>]53.7% | \[ x.re \cdot \color{blue}{\left(x.re \cdot x.re + \left(\left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)\right)}
\] |
fma-udef [<=]66.8% | \[ x.re \cdot \color{blue}{\mathsf{fma}\left(x.re, x.re, \left(-x.im \cdot x.im\right) - \left(x.im + x.im\right) \cdot x.im\right)}
\] |
neg-mul-1 [=>]66.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{-1 \cdot \left(x.im \cdot x.im\right)} - \left(x.im + x.im\right) \cdot x.im\right)
\] |
count-2 [=>]66.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{\left(2 \cdot x.im\right)} \cdot x.im\right)
\] |
associate-*l* [=>]66.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, -1 \cdot \left(x.im \cdot x.im\right) - \color{blue}{2 \cdot \left(x.im \cdot x.im\right)}\right)
\] |
distribute-rgt-out-- [=>]66.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{\left(x.im \cdot x.im\right) \cdot \left(-1 - 2\right)}\right)
\] |
associate-*r* [<=]66.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, \color{blue}{x.im \cdot \left(x.im \cdot \left(-1 - 2\right)\right)}\right)
\] |
metadata-eval [=>]66.8% | \[ x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot \color{blue}{-3}\right)\right)
\] |
Taylor expanded in x.re around 0 66.8%
Simplified66.8%
[Start]66.8% | \[ -3 \cdot \left(x.re \cdot {x.im}^{2}\right)
\] |
|---|---|
associate-*r* [=>]66.8% | \[ \color{blue}{\left(-3 \cdot x.re\right) \cdot {x.im}^{2}}
\] |
*-commutative [=>]66.8% | \[ \color{blue}{{x.im}^{2} \cdot \left(-3 \cdot x.re\right)}
\] |
*-commutative [=>]66.8% | \[ {x.im}^{2} \cdot \color{blue}{\left(x.re \cdot -3\right)}
\] |
metadata-eval [<=]66.8% | \[ {x.im}^{2} \cdot \left(x.re \cdot \color{blue}{\left(-2 + -1\right)}\right)
\] |
distribute-rgt-out [<=]66.8% | \[ {x.im}^{2} \cdot \color{blue}{\left(-2 \cdot x.re + -1 \cdot x.re\right)}
\] |
distribute-lft-in [=>]66.8% | \[ \color{blue}{{x.im}^{2} \cdot \left(-2 \cdot x.re\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)}
\] |
metadata-eval [<=]66.8% | \[ {x.im}^{2} \cdot \left(\color{blue}{\left(-2\right)} \cdot x.re\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-lft-neg-in [<=]66.8% | \[ {x.im}^{2} \cdot \color{blue}{\left(-2 \cdot x.re\right)} + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
count-2 [<=]66.8% | \[ {x.im}^{2} \cdot \left(-\color{blue}{\left(x.re + x.re\right)}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-rgt-neg-in [<=]66.8% | \[ \color{blue}{\left(-{x.im}^{2} \cdot \left(x.re + x.re\right)\right)} + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-rgt-out [<=]66.8% | \[ \left(-\color{blue}{\left(x.re \cdot {x.im}^{2} + x.re \cdot {x.im}^{2}\right)}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-lft-out [=>]66.8% | \[ \left(-\color{blue}{x.re \cdot \left({x.im}^{2} + {x.im}^{2}\right)}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-rgt-neg-in [=>]66.8% | \[ \color{blue}{x.re \cdot \left(-\left({x.im}^{2} + {x.im}^{2}\right)\right)} + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
count-2 [=>]66.8% | \[ x.re \cdot \left(-\color{blue}{2 \cdot {x.im}^{2}}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
distribute-lft-neg-in [=>]66.8% | \[ x.re \cdot \color{blue}{\left(\left(-2\right) \cdot {x.im}^{2}\right)} + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
metadata-eval [=>]66.8% | \[ x.re \cdot \left(\color{blue}{-2} \cdot {x.im}^{2}\right) + {x.im}^{2} \cdot \left(-1 \cdot x.re\right)
\] |
mul-1-neg [=>]66.8% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + {x.im}^{2} \cdot \color{blue}{\left(-x.re\right)}
\] |
distribute-rgt-neg-in [<=]66.8% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{\left(-{x.im}^{2} \cdot x.re\right)}
\] |
distribute-lft-neg-in [=>]66.8% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{\left(-{x.im}^{2}\right) \cdot x.re}
\] |
unpow2 [=>]66.8% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \left(-\color{blue}{x.im \cdot x.im}\right) \cdot x.re
\] |
distribute-rgt-neg-out [<=]66.8% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{\left(x.im \cdot \left(-x.im\right)\right)} \cdot x.re
\] |
*-commutative [<=]66.8% | \[ x.re \cdot \left(-2 \cdot {x.im}^{2}\right) + \color{blue}{x.re \cdot \left(x.im \cdot \left(-x.im\right)\right)}
\] |
Applied egg-rr34.7%
[Start]66.8% | \[ x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)
\] |
|---|---|
add-sqr-sqrt [=>]22.5% | \[ \color{blue}{\sqrt{x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)} \cdot \sqrt{x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)}}
\] |
pow2 [=>]22.5% | \[ \color{blue}{{\left(\sqrt{x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)}\right)}^{2}}
\] |
associate-*r* [=>]22.5% | \[ {\left(\sqrt{\color{blue}{\left(x.re \cdot -3\right) \cdot \left(x.im \cdot x.im\right)}}\right)}^{2}
\] |
sqrt-prod [=>]22.5% | \[ {\color{blue}{\left(\sqrt{x.re \cdot -3} \cdot \sqrt{x.im \cdot x.im}\right)}}^{2}
\] |
sqrt-prod [=>]34.7% | \[ {\left(\sqrt{x.re \cdot -3} \cdot \color{blue}{\left(\sqrt{x.im} \cdot \sqrt{x.im}\right)}\right)}^{2}
\] |
add-sqr-sqrt [<=]34.7% | \[ {\left(\sqrt{x.re \cdot -3} \cdot \color{blue}{x.im}\right)}^{2}
\] |
Applied egg-rr87.0%
[Start]34.7% | \[ {\left(\sqrt{x.re \cdot -3} \cdot x.im\right)}^{2}
\] |
|---|---|
unpow2 [=>]34.7% | \[ \color{blue}{\left(\sqrt{x.re \cdot -3} \cdot x.im\right) \cdot \left(\sqrt{x.re \cdot -3} \cdot x.im\right)}
\] |
swap-sqr [=>]22.5% | \[ \color{blue}{\left(\sqrt{x.re \cdot -3} \cdot \sqrt{x.re \cdot -3}\right) \cdot \left(x.im \cdot x.im\right)}
\] |
add-sqr-sqrt [<=]66.8% | \[ \color{blue}{\left(x.re \cdot -3\right)} \cdot \left(x.im \cdot x.im\right)
\] |
associate-*r* [=>]86.8% | \[ \color{blue}{\left(\left(x.re \cdot -3\right) \cdot x.im\right) \cdot x.im}
\] |
*-commutative [=>]86.8% | \[ \left(\color{blue}{\left(-3 \cdot x.re\right)} \cdot x.im\right) \cdot x.im
\] |
associate-*r* [<=]87.0% | \[ \color{blue}{\left(-3 \cdot \left(x.re \cdot x.im\right)\right)} \cdot x.im
\] |
*-commutative [=>]87.0% | \[ \left(-3 \cdot \color{blue}{\left(x.im \cdot x.re\right)}\right) \cdot x.im
\] |
Final simplification97.5%
| Alternative 1 | |
|---|---|
| Accuracy | 95.9% |
| Cost | 968 |
| Alternative 2 | |
|---|---|
| Accuracy | 74.9% |
| Cost | 713 |
| Alternative 3 | |
|---|---|
| Accuracy | 80.1% |
| Cost | 713 |
| Alternative 4 | |
|---|---|
| Accuracy | 80.1% |
| Cost | 713 |
| Alternative 5 | |
|---|---|
| Accuracy | 59.1% |
| Cost | 320 |
herbie shell --seed 2023178
(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)))