
(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)))
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);
}
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
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);
}
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)
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 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
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]
\begin{array}{l}
\\
\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
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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)))
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);
}
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
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);
}
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)
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 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
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]
\begin{array}{l}
\\
\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
\end{array}
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* x.re (- (* x.re x.re) (* x.im x.im)))
(* x.im (+ (* x.re x.im) (* x.re x.im))))
INFINITY)
(fma
(- x.re x.im)
(* x.re (+ x.re x.im))
(* (- x.im) (* x.re (+ x.im x.im))))
(* x.re (fma x.im (* x.im -3.0) (* x.re x.re)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
tmp = fma((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_im))));
} else {
tmp = x_46_re * fma(x_46_im, (x_46_im * -3.0), (x_46_re * x_46_re));
}
return tmp;
}
function code(x_46_re, x_46_im) tmp = 0.0 if (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf) tmp = fma(Float64(x_46_re - x_46_im), Float64(x_46_re * Float64(x_46_re + x_46_im)), Float64(Float64(-x_46_im) * Float64(x_46_re * Float64(x_46_im + x_46_im)))); else tmp = Float64(x_46_re * fma(x_46_im, Float64(x_46_im * -3.0), Float64(x_46_re * x_46_re))); end return tmp end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] + N[((-x$46$im) * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;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) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im, x.re \cdot \left(x.re + x.im\right), \left(-x.im\right) \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) < +inf.0Initial program 93.5%
sqr-neg93.5%
difference-of-squares93.5%
sub-neg93.5%
associate-*l*99.7%
sub-neg99.7%
remove-double-neg99.7%
+-commutative99.7%
*-commutative99.7%
*-commutative99.7%
distribute-rgt-out99.7%
Simplified99.7%
cancel-sign-sub-inv99.7%
fma-def99.8%
*-commutative99.8%
Applied egg-rr99.8%
if +inf.0 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) Initial program 0.0%
sqr-neg0.0%
difference-of-squares22.9%
sub-neg22.9%
associate-*l*22.9%
sub-neg22.9%
remove-double-neg22.9%
+-commutative22.9%
*-commutative22.9%
*-commutative22.9%
distribute-rgt-out22.9%
Simplified22.9%
sub-neg22.9%
*-commutative22.9%
associate-*r*22.9%
*-commutative22.9%
Applied egg-rr22.9%
unsub-neg22.9%
*-commutative22.9%
associate-*r*22.9%
*-commutative22.9%
difference-of-squares0.0%
*-commutative0.0%
associate-*l*0.0%
distribute-lft-out--45.7%
Simplified45.7%
Taylor expanded in x.re around 0 45.7%
unpow245.7%
mul-1-neg45.7%
distribute-rgt1-in45.7%
metadata-eval45.7%
unpow245.7%
Simplified45.7%
+-commutative45.7%
distribute-lft-neg-in45.7%
metadata-eval45.7%
*-commutative45.7%
associate-*l*45.7%
fma-def74.3%
Applied egg-rr74.3%
Final simplification96.3%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 3.2e+164) (* x.re (fma x.im (* x.im -3.0) (* x.re x.re))) (* x.im (* x.im (* x.re -3.0)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 3.2e+164) {
tmp = x_46_re * fma(x_46_im, (x_46_im * -3.0), (x_46_re * x_46_re));
} else {
tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
}
return tmp;
}
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 3.2e+164) tmp = Float64(x_46_re * fma(x_46_im, Float64(x_46_im * -3.0), Float64(x_46_re * x_46_re))); else tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0))); end return tmp end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 3.2e+164], N[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 3.2 \cdot 10^{+164}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\
\end{array}
\end{array}
if x.im < 3.1999999999999998e164Initial program 83.8%
sqr-neg83.8%
difference-of-squares85.6%
sub-neg85.6%
associate-*l*89.6%
sub-neg89.6%
remove-double-neg89.6%
+-commutative89.6%
*-commutative89.6%
*-commutative89.6%
distribute-rgt-out89.6%
Simplified89.6%
sub-neg89.6%
*-commutative89.6%
associate-*r*89.6%
*-commutative89.6%
Applied egg-rr89.6%
unsub-neg89.6%
*-commutative89.6%
associate-*r*85.6%
*-commutative85.6%
difference-of-squares83.8%
*-commutative83.8%
associate-*l*83.8%
distribute-lft-out--90.8%
Simplified90.8%
Taylor expanded in x.re around 0 90.8%
unpow290.8%
mul-1-neg90.8%
distribute-rgt1-in90.8%
metadata-eval90.8%
unpow290.8%
Simplified90.8%
+-commutative90.8%
distribute-lft-neg-in90.8%
metadata-eval90.8%
*-commutative90.8%
associate-*l*90.8%
fma-def93.5%
Applied egg-rr93.5%
if 3.1999999999999998e164 < x.im Initial program 56.1%
sqr-neg56.1%
difference-of-squares69.9%
sub-neg69.9%
associate-*l*86.1%
sub-neg86.1%
remove-double-neg86.1%
+-commutative86.1%
*-commutative86.1%
*-commutative86.1%
distribute-rgt-out86.1%
Simplified86.1%
cancel-sign-sub-inv86.1%
fma-def86.2%
*-commutative86.2%
Applied egg-rr86.2%
Taylor expanded in x.re around 0 69.9%
distribute-rgt-out69.9%
metadata-eval69.9%
associate-*r*69.9%
*-commutative69.9%
unpow269.9%
associate-*l*86.2%
associate-*r*86.1%
Simplified86.1%
pow186.1%
associate-*l*86.2%
Applied egg-rr86.2%
Final simplification92.6%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 4.5e+152) (* x.re (- (- (* x.re x.re) (* x.im x.im)) (* x.im (+ x.im x.im)))) (* x.im (* (* x.re x.im) -3.0))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.5e+152) {
tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im)));
} else {
tmp = x_46_im * ((x_46_re * x_46_im) * -3.0);
}
return tmp;
}
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 <= 4.5d+152) then
tmp = x_46re * (((x_46re * x_46re) - (x_46im * x_46im)) - (x_46im * (x_46im + x_46im)))
else
tmp = x_46im * ((x_46re * x_46im) * (-3.0d0))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.5e+152) {
tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im)));
} else {
tmp = x_46_im * ((x_46_re * x_46_im) * -3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 4.5e+152: tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im))) else: tmp = x_46_im * ((x_46_re * x_46_im) * -3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 4.5e+152) tmp = Float64(x_46_re * Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) - Float64(x_46_im * Float64(x_46_im + x_46_im)))); else tmp = Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * -3.0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 4.5e+152) tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im))); else tmp = x_46_im * ((x_46_re * x_46_im) * -3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 4.5e+152], N[(x$46$re * N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 4.5 \cdot 10^{+152}:\\
\;\;\;\;x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.im + x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\
\end{array}
\end{array}
if x.im < 4.5000000000000001e152Initial program 83.8%
sqr-neg83.8%
difference-of-squares85.6%
sub-neg85.6%
associate-*l*89.6%
sub-neg89.6%
remove-double-neg89.6%
+-commutative89.6%
*-commutative89.6%
*-commutative89.6%
distribute-rgt-out89.6%
Simplified89.6%
sub-neg89.6%
*-commutative89.6%
associate-*r*89.6%
*-commutative89.6%
Applied egg-rr89.6%
unsub-neg89.6%
*-commutative89.6%
associate-*r*85.6%
*-commutative85.6%
difference-of-squares83.8%
*-commutative83.8%
associate-*l*83.8%
distribute-lft-out--90.8%
Simplified90.8%
if 4.5000000000000001e152 < x.im Initial program 56.1%
sqr-neg56.1%
difference-of-squares69.9%
sub-neg69.9%
associate-*l*86.1%
sub-neg86.1%
remove-double-neg86.1%
+-commutative86.1%
*-commutative86.1%
*-commutative86.1%
distribute-rgt-out86.1%
Simplified86.1%
cancel-sign-sub-inv86.1%
fma-def86.2%
*-commutative86.2%
Applied egg-rr86.2%
Taylor expanded in x.re around 0 69.9%
distribute-rgt-out69.9%
metadata-eval69.9%
associate-*r*69.9%
*-commutative69.9%
unpow269.9%
associate-*l*86.2%
associate-*r*86.1%
Simplified86.1%
Final simplification90.3%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 4.5e+152) (* x.re (- (- (* x.re x.re) (* x.im x.im)) (* x.im (+ x.im x.im)))) (* x.im (* x.im (* x.re -3.0)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.5e+152) {
tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im)));
} 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
real(8) :: tmp
if (x_46im <= 4.5d+152) then
tmp = x_46re * (((x_46re * x_46re) - (x_46im * x_46im)) - (x_46im * (x_46im + x_46im)))
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) {
double tmp;
if (x_46_im <= 4.5e+152) {
tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im)));
} else {
tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 4.5e+152: tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im))) else: tmp = x_46_im * (x_46_im * (x_46_re * -3.0)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 4.5e+152) tmp = Float64(x_46_re * Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) - Float64(x_46_im * Float64(x_46_im + x_46_im)))); else tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 4.5e+152) tmp = x_46_re * (((x_46_re * x_46_re) - (x_46_im * x_46_im)) - (x_46_im * (x_46_im + x_46_im))); 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_] := If[LessEqual[x$46$im, 4.5e+152], N[(x$46$re * N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 4.5 \cdot 10^{+152}:\\
\;\;\;\;x.re \cdot \left(\left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.im + x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\
\end{array}
\end{array}
if x.im < 4.5000000000000001e152Initial program 83.8%
sqr-neg83.8%
difference-of-squares85.6%
sub-neg85.6%
associate-*l*89.6%
sub-neg89.6%
remove-double-neg89.6%
+-commutative89.6%
*-commutative89.6%
*-commutative89.6%
distribute-rgt-out89.6%
Simplified89.6%
sub-neg89.6%
*-commutative89.6%
associate-*r*89.6%
*-commutative89.6%
Applied egg-rr89.6%
unsub-neg89.6%
*-commutative89.6%
associate-*r*85.6%
*-commutative85.6%
difference-of-squares83.8%
*-commutative83.8%
associate-*l*83.8%
distribute-lft-out--90.8%
Simplified90.8%
if 4.5000000000000001e152 < x.im Initial program 56.1%
sqr-neg56.1%
difference-of-squares69.9%
sub-neg69.9%
associate-*l*86.1%
sub-neg86.1%
remove-double-neg86.1%
+-commutative86.1%
*-commutative86.1%
*-commutative86.1%
distribute-rgt-out86.1%
Simplified86.1%
cancel-sign-sub-inv86.1%
fma-def86.2%
*-commutative86.2%
Applied egg-rr86.2%
Taylor expanded in x.re around 0 69.9%
distribute-rgt-out69.9%
metadata-eval69.9%
associate-*r*69.9%
*-commutative69.9%
unpow269.9%
associate-*l*86.2%
associate-*r*86.1%
Simplified86.1%
pow186.1%
associate-*l*86.2%
Applied egg-rr86.2%
Final simplification90.3%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 4.5e+152) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0)))) (* x.im (* (* x.re x.im) -3.0))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.5e+152) {
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_re * x_46_im) * -3.0);
}
return tmp;
}
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 <= 4.5d+152) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = x_46im * ((x_46re * x_46im) * (-3.0d0))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.5e+152) {
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_re * x_46_im) * -3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 4.5e+152: 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_re * x_46_im) * -3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 4.5e+152) 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_re * x_46_im) * -3.0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 4.5e+152) 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_re * x_46_im) * -3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 4.5e+152], 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$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 4.5 \cdot 10^{+152}:\\
\;\;\;\;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.re \cdot x.im\right) \cdot -3\right)\\
\end{array}
\end{array}
if x.im < 4.5000000000000001e152Initial program 83.8%
sqr-neg83.8%
difference-of-squares85.6%
sub-neg85.6%
associate-*l*89.6%
sub-neg89.6%
remove-double-neg89.6%
+-commutative89.6%
*-commutative89.6%
*-commutative89.6%
distribute-rgt-out89.6%
Simplified89.6%
sub-neg89.6%
*-commutative89.6%
associate-*r*89.6%
*-commutative89.6%
Applied egg-rr89.6%
unsub-neg89.6%
*-commutative89.6%
associate-*r*85.6%
*-commutative85.6%
difference-of-squares83.8%
*-commutative83.8%
associate-*l*83.8%
distribute-lft-out--90.8%
Simplified90.8%
Taylor expanded in x.re around 0 90.8%
unpow290.8%
mul-1-neg90.8%
distribute-rgt1-in90.8%
metadata-eval90.8%
unpow290.8%
Simplified90.8%
+-commutative90.8%
distribute-lft-neg-in90.8%
metadata-eval90.8%
*-commutative90.8%
associate-*l*90.8%
fma-def93.5%
Applied egg-rr93.5%
fma-udef90.8%
Applied egg-rr90.8%
if 4.5000000000000001e152 < x.im Initial program 56.1%
sqr-neg56.1%
difference-of-squares69.9%
sub-neg69.9%
associate-*l*86.1%
sub-neg86.1%
remove-double-neg86.1%
+-commutative86.1%
*-commutative86.1%
*-commutative86.1%
distribute-rgt-out86.1%
Simplified86.1%
cancel-sign-sub-inv86.1%
fma-def86.2%
*-commutative86.2%
Applied egg-rr86.2%
Taylor expanded in x.re around 0 69.9%
distribute-rgt-out69.9%
metadata-eval69.9%
associate-*r*69.9%
*-commutative69.9%
unpow269.9%
associate-*l*86.2%
associate-*r*86.1%
Simplified86.1%
Final simplification90.3%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 4.5e+152) (* x.re (- (* x.re x.re) (* (* x.im x.im) 3.0))) (* x.im (* (* x.re x.im) -3.0))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.5e+152) {
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_re * x_46_im) * -3.0);
}
return tmp;
}
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 <= 4.5d+152) then
tmp = x_46re * ((x_46re * x_46re) - ((x_46im * x_46im) * 3.0d0))
else
tmp = x_46im * ((x_46re * x_46im) * (-3.0d0))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.5e+152) {
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_re * x_46_im) * -3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 4.5e+152: 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_re * x_46_im) * -3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 4.5e+152) tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(Float64(x_46_im * x_46_im) * 3.0))); else tmp = Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * -3.0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 4.5e+152) 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_re * x_46_im) * -3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 4.5e+152], N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(N[(x$46$im * x$46$im), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 4.5 \cdot 10^{+152}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re - \left(x.im \cdot x.im\right) \cdot 3\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\
\end{array}
\end{array}
if x.im < 4.5000000000000001e152Initial program 83.8%
sqr-neg83.8%
difference-of-squares85.6%
sub-neg85.6%
associate-*l*89.6%
sub-neg89.6%
remove-double-neg89.6%
+-commutative89.6%
*-commutative89.6%
*-commutative89.6%
distribute-rgt-out89.6%
Simplified89.6%
sub-neg89.6%
*-commutative89.6%
associate-*r*89.6%
*-commutative89.6%
Applied egg-rr89.6%
unsub-neg89.6%
*-commutative89.6%
associate-*r*85.6%
*-commutative85.6%
difference-of-squares83.8%
*-commutative83.8%
associate-*l*83.8%
distribute-lft-out--90.8%
Simplified90.8%
Taylor expanded in x.re around 0 90.8%
unpow290.8%
mul-1-neg90.8%
distribute-rgt1-in90.8%
metadata-eval90.8%
unpow290.8%
Simplified90.8%
unsub-neg90.8%
Applied egg-rr90.8%
if 4.5000000000000001e152 < x.im Initial program 56.1%
sqr-neg56.1%
difference-of-squares69.9%
sub-neg69.9%
associate-*l*86.1%
sub-neg86.1%
remove-double-neg86.1%
+-commutative86.1%
*-commutative86.1%
*-commutative86.1%
distribute-rgt-out86.1%
Simplified86.1%
cancel-sign-sub-inv86.1%
fma-def86.2%
*-commutative86.2%
Applied egg-rr86.2%
Taylor expanded in x.re around 0 69.9%
distribute-rgt-out69.9%
metadata-eval69.9%
associate-*r*69.9%
*-commutative69.9%
unpow269.9%
associate-*l*86.2%
associate-*r*86.1%
Simplified86.1%
Final simplification90.3%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.re -8.8e+16) (not (<= x.re 6e-28))) (* x.re (* x.re x.re)) (* -3.0 (* x.im (* x.re x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -8.8e+16) || !(x_46_re <= 6e-28)) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
}
return tmp;
}
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_46re <= (-8.8d+16)) .or. (.not. (x_46re <= 6d-28))) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (-3.0d0) * (x_46im * (x_46re * x_46im))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -8.8e+16) || !(x_46_re <= 6e-28)) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_re <= -8.8e+16) or not (x_46_re <= 6e-28): tmp = x_46_re * (x_46_re * x_46_re) else: tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_re <= -8.8e+16) || !(x_46_re <= 6e-28)) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(-3.0 * Float64(x_46_im * Float64(x_46_re * x_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_re <= -8.8e+16) || ~((x_46_re <= 6e-28))) tmp = x_46_re * (x_46_re * x_46_re); else tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -8.8e+16], N[Not[LessEqual[x$46$re, 6e-28]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -8.8 \cdot 10^{+16} \lor \neg \left(x.re \leq 6 \cdot 10^{-28}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.re < -8.8e16 or 6.00000000000000005e-28 < x.re Initial program 74.4%
sqr-neg74.4%
difference-of-squares80.2%
sub-neg80.2%
associate-*l*80.2%
sub-neg80.2%
remove-double-neg80.2%
+-commutative80.2%
*-commutative80.2%
*-commutative80.2%
distribute-rgt-out80.2%
Simplified80.2%
sub-neg80.2%
*-commutative80.2%
associate-*r*80.2%
*-commutative80.2%
Applied egg-rr80.2%
unsub-neg80.2%
*-commutative80.2%
associate-*r*80.2%
*-commutative80.2%
difference-of-squares74.4%
*-commutative74.4%
associate-*l*74.4%
distribute-lft-out--86.0%
Simplified86.0%
Taylor expanded in x.re around 0 86.0%
unpow286.0%
mul-1-neg86.0%
distribute-rgt1-in86.0%
metadata-eval86.0%
unpow286.0%
Simplified86.0%
+-commutative86.0%
distribute-lft-neg-in86.0%
metadata-eval86.0%
*-commutative86.0%
associate-*l*86.0%
fma-def93.3%
Applied egg-rr93.3%
Taylor expanded in x.im around 0 76.6%
unpow276.6%
Simplified76.6%
if -8.8e16 < x.re < 6.00000000000000005e-28Initial program 88.0%
Simplified88.0%
Taylor expanded in x.re around 0 77.8%
unpow277.8%
Simplified77.8%
Taylor expanded in x.re around 0 77.8%
*-commutative77.8%
unpow277.8%
associate-*l*89.5%
Simplified89.5%
Final simplification82.6%
(FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.re)))
double code(double x_46_re, double x_46_im) {
return x_46_re * (x_46_re * x_46_re);
}
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_46re)
end function
public static double code(double x_46_re, double x_46_im) {
return x_46_re * (x_46_re * x_46_re);
}
def code(x_46_re, x_46_im): return x_46_re * (x_46_re * x_46_re)
function code(x_46_re, x_46_im) return Float64(x_46_re * Float64(x_46_re * x_46_re)) end
function tmp = code(x_46_re, x_46_im) tmp = x_46_re * (x_46_re * x_46_re); end
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Initial program 80.7%
sqr-neg80.7%
difference-of-squares83.8%
sub-neg83.8%
associate-*l*89.2%
sub-neg89.2%
remove-double-neg89.2%
+-commutative89.2%
*-commutative89.2%
*-commutative89.2%
distribute-rgt-out89.2%
Simplified89.2%
sub-neg89.2%
*-commutative89.2%
associate-*r*89.2%
*-commutative89.2%
Applied egg-rr89.2%
unsub-neg89.2%
*-commutative89.2%
associate-*r*83.8%
*-commutative83.8%
difference-of-squares80.7%
*-commutative80.7%
associate-*l*80.7%
distribute-lft-out--86.9%
Simplified86.9%
Taylor expanded in x.re around 0 86.9%
unpow286.9%
mul-1-neg86.9%
distribute-rgt1-in86.9%
metadata-eval86.9%
unpow286.9%
Simplified86.9%
+-commutative86.9%
distribute-lft-neg-in86.9%
metadata-eval86.9%
*-commutative86.9%
associate-*l*86.9%
fma-def90.8%
Applied egg-rr90.8%
Taylor expanded in x.im around 0 59.4%
unpow259.4%
Simplified59.4%
Final simplification59.4%
(FPCore (x.re x.im) :precision binary64 (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im)))))
double code(double x_46_re, double x_46_im) {
return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)));
}
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_46re - x_46im)) + ((x_46re * x_46im) * (x_46re - (3.0d0 * x_46im)))
end function
public static double code(double x_46_re, double x_46_im) {
return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)));
}
def code(x_46_re, x_46_im): return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)))
function code(x_46_re, x_46_im) return Float64(Float64(Float64(x_46_re * x_46_re) * Float64(x_46_re - x_46_im)) + Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re - Float64(3.0 * x_46_im)))) end
function tmp = code(x_46_re, x_46_im) tmp = ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im))); end
code[x$46$re_, x$46$im_] := N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re - N[(3.0 * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\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)
\end{array}
herbie shell --seed 2023274
(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)))