
(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 6 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}
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 2.1e+151) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0)))) (- (* x.im (* x.im (- x.re))) (* x.im (* x.re (+ x.im x.im))))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 2.1e+151) {
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)) - (x_46_im * (x_46_re * (x_46_im + x_46_im)));
}
return tmp;
}
NOTE: x.im should be positive before calling this 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.1d+151) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = (x_46im * (x_46im * -x_46re)) - (x_46im * (x_46re * (x_46im + x_46im)))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 2.1e+151) {
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)) - (x_46_im * (x_46_re * (x_46_im + x_46_im)));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 2.1e+151: 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)) - (x_46_im * (x_46_re * (x_46_im + x_46_im))) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 2.1e+151) 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(Float64(x_46_im * Float64(x_46_im * Float64(-x_46_re))) - Float64(x_46_im * Float64(x_46_re * Float64(x_46_im + x_46_im)))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 2.1e+151) 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)) - (x_46_im * (x_46_re * (x_46_im + x_46_im))); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 2.1e+151], 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[(N[(x$46$im * N[(x$46$im * (-x$46$re)), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 2.1 \cdot 10^{+151}:\\
\;\;\;\;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(x.im \cdot \left(-x.re\right)\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\\
\end{array}
\end{array}
if x.im < 2.1000000000000001e151Initial program 91.9%
*-commutative91.9%
distribute-lft-out91.9%
associate-*l*91.8%
*-commutative91.8%
distribute-rgt-out--94.9%
associate--l-94.9%
associate--l-94.9%
sub-neg94.9%
associate--l+94.9%
fma-udef95.7%
neg-mul-195.7%
count-295.7%
associate-*l*95.7%
distribute-rgt-out--95.7%
associate-*r*95.7%
metadata-eval95.7%
Simplified95.7%
fma-udef94.8%
Applied egg-rr94.8%
if 2.1000000000000001e151 < x.im Initial program 50.1%
*-commutative50.1%
*-commutative50.1%
*-commutative50.1%
distribute-lft-out50.1%
Simplified50.1%
Taylor expanded in x.re around 0 70.1%
associate-*r*70.1%
mul-1-neg70.1%
unpow270.1%
Simplified70.1%
Taylor expanded in x.re around 0 70.1%
associate-*r*70.1%
neg-mul-170.1%
unpow270.1%
associate-*r*95.7%
*-commutative95.7%
distribute-lft-neg-out95.7%
distribute-rgt-neg-in95.7%
Simplified95.7%
Final simplification94.9%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 7.8e+153) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0)))) (* (/ (* x.re -3.0) (/ x.re x.im)) (/ x.re (/ 1.0 x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 7.8e+153) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = ((x_46_re * -3.0) / (x_46_re / x_46_im)) * (x_46_re / (1.0 / x_46_im));
}
return tmp;
}
NOTE: x.im should be positive before calling this 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 <= 7.8d+153) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = ((x_46re * (-3.0d0)) / (x_46re / x_46im)) * (x_46re / (1.0d0 / x_46im))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 7.8e+153) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = ((x_46_re * -3.0) / (x_46_re / x_46_im)) * (x_46_re / (1.0 / x_46_im));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 7.8e+153: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) else: tmp = ((x_46_re * -3.0) / (x_46_re / x_46_im)) * (x_46_re / (1.0 / x_46_im)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 7.8e+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(Float64(Float64(x_46_re * -3.0) / Float64(x_46_re / x_46_im)) * Float64(x_46_re / Float64(1.0 / x_46_im))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 7.8e+153) tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); else tmp = ((x_46_re * -3.0) / (x_46_re / x_46_im)) * (x_46_re / (1.0 / x_46_im)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 7.8e+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[(N[(N[(x$46$re * -3.0), $MachinePrecision] / N[(x$46$re / x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re / N[(1.0 / x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 7.8 \cdot 10^{+153}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x.re \cdot -3}{\frac{x.re}{x.im}} \cdot \frac{x.re}{\frac{1}{x.im}}\\
\end{array}
\end{array}
if x.im < 7.79999999999999966e153Initial program 91.9%
*-commutative91.9%
distribute-lft-out91.9%
associate-*l*91.8%
*-commutative91.8%
distribute-rgt-out--94.9%
associate--l-94.9%
associate--l-94.9%
sub-neg94.9%
associate--l+94.9%
fma-udef95.7%
neg-mul-195.7%
count-295.7%
associate-*l*95.7%
distribute-rgt-out--95.7%
associate-*r*95.7%
metadata-eval95.7%
Simplified95.7%
fma-udef94.8%
Applied egg-rr94.8%
if 7.79999999999999966e153 < x.im Initial program 48.0%
*-commutative48.0%
*-commutative48.0%
*-commutative48.0%
distribute-lft-out48.0%
Simplified48.0%
sub-neg48.0%
flip-+0.0%
pow20.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
Applied egg-rr0.0%
Taylor expanded in x.im around inf 43.0%
associate-/l*43.0%
unpow243.0%
unpow243.0%
cancel-sign-sub-inv43.0%
metadata-eval43.0%
distribute-rgt-out--43.0%
metadata-eval43.0%
unpow243.0%
Simplified43.0%
Taylor expanded in x.re around 0 63.8%
unpow263.8%
*-commutative63.8%
associate-*l*63.8%
Simplified63.8%
*-commutative63.8%
times-frac63.8%
times-frac73.9%
Applied egg-rr73.9%
Final simplification92.9%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 2.8e+162) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0)))) (* -3.0 (* x.re (* x.im x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 2.8e+162) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
}
return tmp;
}
NOTE: x.im should be positive before calling this 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.8d+162) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 2.8e+162) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 2.8e+162: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) else: tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 2.8e+162) 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(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 2.8e+162) tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); else tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 2.8e+162], 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[(-3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 2.8 \cdot 10^{+162}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.im < 2.79999999999999991e162Initial program 91.2%
*-commutative91.2%
distribute-lft-out91.2%
associate-*l*91.1%
*-commutative91.1%
distribute-rgt-out--94.1%
associate--l-94.1%
associate--l-94.1%
sub-neg94.1%
associate--l+94.1%
fma-udef95.0%
neg-mul-195.0%
count-295.0%
associate-*l*95.0%
distribute-rgt-out--95.0%
associate-*r*94.9%
metadata-eval94.9%
Simplified94.9%
fma-udef94.1%
Applied egg-rr94.1%
if 2.79999999999999991e162 < x.im Initial program 51.9%
*-commutative51.9%
distribute-lft-out51.9%
associate-*l*51.9%
*-commutative51.9%
distribute-rgt-out--51.9%
associate--l-51.9%
associate--l-51.9%
sub-neg51.9%
associate--l+51.9%
fma-udef74.6%
neg-mul-174.6%
count-274.6%
associate-*l*74.6%
distribute-rgt-out--74.6%
associate-*r*74.6%
metadata-eval74.6%
Simplified74.6%
fma-udef51.9%
Applied egg-rr51.9%
Taylor expanded in x.re around 0 74.6%
unpow274.6%
Simplified74.6%
Final simplification92.4%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 4.4e-15) (* x.re (* x.re x.re)) (* -3.0 (* x.re (* x.im x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.4e-15) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
}
return tmp;
}
NOTE: x.im should be positive before calling this 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 <= 4.4d-15) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.4e-15) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 4.4e-15: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 4.4e-15) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 4.4e-15) tmp = x_46_re * (x_46_re * x_46_re); else tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 4.4e-15], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 4.4 \cdot 10^{-15}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.im < 4.39999999999999971e-15Initial program 92.6%
*-commutative92.6%
distribute-lft-out92.6%
associate-*l*92.6%
*-commutative92.6%
distribute-rgt-out--94.1%
associate--l-94.1%
associate--l-94.1%
sub-neg94.1%
associate--l+94.1%
fma-udef95.1%
neg-mul-195.1%
count-295.1%
associate-*l*95.1%
distribute-rgt-out--95.1%
associate-*r*95.1%
metadata-eval95.1%
Simplified95.1%
Taylor expanded in x.re around inf 70.7%
unpow270.7%
Simplified70.7%
if 4.39999999999999971e-15 < x.im Initial program 70.4%
*-commutative70.4%
distribute-lft-out70.4%
associate-*l*70.3%
*-commutative70.3%
distribute-rgt-out--77.6%
associate--l-77.6%
associate--l-77.6%
sub-neg77.6%
associate--l+77.6%
fma-udef86.5%
neg-mul-186.5%
count-286.5%
associate-*l*86.5%
distribute-rgt-out--86.5%
associate-*r*86.4%
metadata-eval86.4%
Simplified86.4%
fma-udef77.4%
Applied egg-rr77.4%
Taylor expanded in x.re around 0 68.6%
unpow268.6%
Simplified68.6%
Final simplification70.3%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 5e-15) (* x.re (* x.re x.re)) (* x.re (* -3.0 (* x.im x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 5e-15) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
}
return tmp;
}
NOTE: x.im should be positive before calling this 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 <= 5d-15) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = x_46re * ((-3.0d0) * (x_46im * x_46im))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 5e-15) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 5e-15: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = x_46_re * (-3.0 * (x_46_im * x_46_im)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 5e-15) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(x_46_re * Float64(-3.0 * Float64(x_46_im * x_46_im))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 5e-15) tmp = x_46_re * (x_46_re * x_46_re); else tmp = x_46_re * (-3.0 * (x_46_im * x_46_im)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 5e-15], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 5 \cdot 10^{-15}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.im < 4.99999999999999999e-15Initial program 92.6%
*-commutative92.6%
distribute-lft-out92.6%
associate-*l*92.6%
*-commutative92.6%
distribute-rgt-out--94.1%
associate--l-94.1%
associate--l-94.1%
sub-neg94.1%
associate--l+94.1%
fma-udef95.1%
neg-mul-195.1%
count-295.1%
associate-*l*95.1%
distribute-rgt-out--95.1%
associate-*r*95.1%
metadata-eval95.1%
Simplified95.1%
Taylor expanded in x.re around inf 70.7%
unpow270.7%
Simplified70.7%
if 4.99999999999999999e-15 < x.im Initial program 70.4%
*-commutative70.4%
distribute-lft-out70.4%
associate-*l*70.3%
*-commutative70.3%
distribute-rgt-out--77.6%
associate--l-77.6%
associate--l-77.6%
sub-neg77.6%
associate--l+77.6%
fma-udef86.5%
neg-mul-186.5%
count-286.5%
associate-*l*86.5%
distribute-rgt-out--86.5%
associate-*r*86.4%
metadata-eval86.4%
Simplified86.4%
Taylor expanded in x.re around 0 68.6%
associate-*r*68.7%
*-commutative68.7%
metadata-eval68.7%
distribute-rgt-out68.7%
metadata-eval68.7%
cancel-sign-sub-inv68.7%
*-commutative68.7%
cancel-sign-sub-inv68.7%
metadata-eval68.7%
+-commutative68.7%
distribute-rgt-in68.6%
Simplified68.7%
Final simplification70.3%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.re)))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
return x_46_re * (x_46_re * x_46_re);
}
NOTE: x.im should be positive before calling this function
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
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
return x_46_re * (x_46_re * x_46_re);
}
x.im = abs(x.im) def code(x_46_re, x_46_im): return x_46_re * (x_46_re * x_46_re)
x.im = abs(x.im) function code(x_46_re, x_46_im) return Float64(x_46_re * Float64(x_46_re * x_46_re)) end
x.im = abs(x.im) function tmp = code(x_46_re, x_46_im) tmp = x_46_re * (x_46_re * x_46_re); end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im = |x.im|\\
\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Initial program 87.8%
*-commutative87.8%
distribute-lft-out87.8%
associate-*l*87.7%
*-commutative87.7%
distribute-rgt-out--90.5%
associate--l-90.5%
associate--l-90.5%
sub-neg90.5%
associate--l+90.5%
fma-udef93.2%
neg-mul-193.2%
count-293.2%
associate-*l*93.2%
distribute-rgt-out--93.2%
associate-*r*93.2%
metadata-eval93.2%
Simplified93.2%
Taylor expanded in x.re around inf 59.8%
unpow259.8%
Simplified59.8%
Final simplification59.8%
(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 2023199
(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)))