
(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}
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
:precision binary64
(if (<= x.im 1.95e+153)
(* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0))))
(fma
(- x.re x.im)
(* x.re (+ x.im x.re))
(* x.im (* (+ x.im x.im) (- x.re))))))x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 1.95e+153) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = fma((x_46_re - x_46_im), (x_46_re * (x_46_im + x_46_re)), (x_46_im * ((x_46_im + x_46_im) * -x_46_re)));
}
return tmp;
}
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 1.95e+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 = fma(Float64(x_46_re - x_46_im), Float64(x_46_re * Float64(x_46_im + x_46_re)), Float64(x_46_im * Float64(Float64(x_46_im + x_46_im) * Float64(-x_46_re)))); end return tmp end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 1.95e+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[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision] + N[(x$46$im * N[(N[(x$46$im + x$46$im), $MachinePrecision] * (-x$46$re)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1.95 \cdot 10^{+153}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x.re - x.im, x.re \cdot \left(x.im + x.re\right), x.im \cdot \left(\left(x.im + x.im\right) \cdot \left(-x.re\right)\right)\right)\\
\end{array}
\end{array}
if x.im < 1.94999999999999992e153Initial program 87.0%
sqr-neg87.0%
difference-of-squares88.4%
sub-neg88.4%
associate-*l*92.6%
sub-neg92.6%
remove-double-neg92.6%
+-commutative92.6%
*-commutative92.6%
*-commutative92.6%
distribute-rgt-out92.6%
Simplified92.6%
add-cube-cbrt92.3%
pow392.3%
*-commutative92.3%
Applied egg-rr92.3%
cancel-sign-sub-inv92.3%
unpow392.3%
add-cube-cbrt92.6%
*-commutative92.6%
fma-def92.6%
*-commutative92.6%
Applied egg-rr92.6%
Taylor expanded in x.re around 0 68.1%
Simplified94.3%
fma-udef92.9%
associate-*l*92.9%
+-commutative92.9%
associate-*l*92.9%
Applied egg-rr92.9%
if 1.94999999999999992e153 < x.im Initial program 65.0%
sqr-neg65.0%
difference-of-squares73.6%
sub-neg73.6%
associate-*l*99.8%
sub-neg99.8%
remove-double-neg99.8%
+-commutative99.8%
*-commutative99.8%
*-commutative99.8%
distribute-rgt-out99.8%
Simplified99.8%
add-cube-cbrt99.8%
pow399.7%
*-commutative99.7%
Applied egg-rr99.7%
cancel-sign-sub-inv99.7%
unpow399.8%
add-cube-cbrt99.8%
*-commutative99.8%
fma-def100.0%
*-commutative100.0%
Applied egg-rr100.0%
Final simplification93.9%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (or (<= x.im 1300.0) (and (not (<= x.im 2.8e+60)) (<= x.im 2.05e+96))) (* x.re (* x.re x.re)) (* -3.0 (* x.im (* x.im x.re)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= 1300.0) || (!(x_46_im <= 2.8e+60) && (x_46_im <= 2.05e+96))) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_im * (x_46_im * x_46_re));
}
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 <= 1300.0d0) .or. (.not. (x_46im <= 2.8d+60)) .and. (x_46im <= 2.05d+96)) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (-3.0d0) * (x_46im * (x_46im * x_46re))
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 <= 1300.0) || (!(x_46_im <= 2.8e+60) && (x_46_im <= 2.05e+96))) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_im * (x_46_im * x_46_re));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= 1300.0) or (not (x_46_im <= 2.8e+60) and (x_46_im <= 2.05e+96)): tmp = x_46_re * (x_46_re * x_46_re) else: tmp = -3.0 * (x_46_im * (x_46_im * x_46_re)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= 1300.0) || (!(x_46_im <= 2.8e+60) && (x_46_im <= 2.05e+96))) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(-3.0 * Float64(x_46_im * Float64(x_46_im * x_46_re))); 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 <= 1300.0) || (~((x_46_im <= 2.8e+60)) && (x_46_im <= 2.05e+96))) tmp = x_46_re * (x_46_re * x_46_re); else tmp = -3.0 * (x_46_im * (x_46_im * x_46_re)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, 1300.0], And[N[Not[LessEqual[x$46$im, 2.8e+60]], $MachinePrecision], LessEqual[x$46$im, 2.05e+96]]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$im * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1300 \lor \neg \left(x.im \leq 2.8 \cdot 10^{+60}\right) \land x.im \leq 2.05 \cdot 10^{+96}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 1300 or 2.8e60 < x.im < 2.04999999999999999e96Initial program 87.1%
sqr-neg87.1%
difference-of-squares88.6%
sub-neg88.6%
associate-*l*93.3%
sub-neg93.3%
remove-double-neg93.3%
+-commutative93.3%
*-commutative93.3%
*-commutative93.3%
distribute-rgt-out93.3%
Simplified93.3%
add-cube-cbrt93.0%
pow393.0%
*-commutative93.0%
Applied egg-rr93.0%
cancel-sign-sub-inv93.0%
unpow393.0%
add-cube-cbrt93.3%
*-commutative93.3%
fma-def93.3%
*-commutative93.3%
Applied egg-rr93.3%
Taylor expanded in x.re around 0 67.0%
Simplified93.7%
Taylor expanded in x.im around 0 71.4%
unpow271.4%
Simplified71.4%
if 1300 < x.im < 2.8e60 or 2.04999999999999999e96 < x.im Initial program 73.6%
sqr-neg73.6%
difference-of-squares78.7%
sub-neg78.7%
associate-*l*94.5%
sub-neg94.5%
remove-double-neg94.5%
+-commutative94.5%
*-commutative94.5%
*-commutative94.5%
distribute-rgt-out94.5%
Simplified94.5%
add-cube-cbrt94.3%
pow394.3%
*-commutative94.3%
Applied egg-rr94.3%
cancel-sign-sub-inv94.3%
unpow394.3%
add-cube-cbrt94.5%
*-commutative94.5%
fma-def94.6%
*-commutative94.6%
Applied egg-rr94.6%
Taylor expanded in x.re around 0 59.7%
Simplified78.6%
Taylor expanded in x.re around 0 73.5%
unpow273.5%
associate-*r*89.4%
Simplified89.4%
Final simplification75.5%
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.re (* x.re x.re))))
(if (<= x.im 420.0)
t_0
(if (<= x.im 2.45e+61)
(* x.re (* -3.0 (* x.im x.im)))
(if (<= x.im 2.02e+96) t_0 (* -3.0 (* x.im (* x.im x.re))))))))x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double t_0 = x_46_re * (x_46_re * x_46_re);
double tmp;
if (x_46_im <= 420.0) {
tmp = t_0;
} else if (x_46_im <= 2.45e+61) {
tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
} else if (x_46_im <= 2.02e+96) {
tmp = t_0;
} else {
tmp = -3.0 * (x_46_im * (x_46_im * x_46_re));
}
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) :: t_0
real(8) :: tmp
t_0 = x_46re * (x_46re * x_46re)
if (x_46im <= 420.0d0) then
tmp = t_0
else if (x_46im <= 2.45d+61) then
tmp = x_46re * ((-3.0d0) * (x_46im * x_46im))
else if (x_46im <= 2.02d+96) then
tmp = t_0
else
tmp = (-3.0d0) * (x_46im * (x_46im * x_46re))
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 t_0 = x_46_re * (x_46_re * x_46_re);
double tmp;
if (x_46_im <= 420.0) {
tmp = t_0;
} else if (x_46_im <= 2.45e+61) {
tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
} else if (x_46_im <= 2.02e+96) {
tmp = t_0;
} else {
tmp = -3.0 * (x_46_im * (x_46_im * x_46_re));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): t_0 = x_46_re * (x_46_re * x_46_re) tmp = 0 if x_46_im <= 420.0: tmp = t_0 elif x_46_im <= 2.45e+61: tmp = x_46_re * (-3.0 * (x_46_im * x_46_im)) elif x_46_im <= 2.02e+96: tmp = t_0 else: tmp = -3.0 * (x_46_im * (x_46_im * x_46_re)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) t_0 = Float64(x_46_re * Float64(x_46_re * x_46_re)) tmp = 0.0 if (x_46_im <= 420.0) tmp = t_0; elseif (x_46_im <= 2.45e+61) tmp = Float64(x_46_re * Float64(-3.0 * Float64(x_46_im * x_46_im))); elseif (x_46_im <= 2.02e+96) tmp = t_0; else tmp = Float64(-3.0 * Float64(x_46_im * Float64(x_46_im * x_46_re))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) t_0 = x_46_re * (x_46_re * x_46_re); tmp = 0.0; if (x_46_im <= 420.0) tmp = t_0; elseif (x_46_im <= 2.45e+61) tmp = x_46_re * (-3.0 * (x_46_im * x_46_im)); elseif (x_46_im <= 2.02e+96) tmp = t_0; else tmp = -3.0 * (x_46_im * (x_46_im * x_46_re)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, 420.0], t$95$0, If[LessEqual[x$46$im, 2.45e+61], N[(x$46$re * N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 2.02e+96], t$95$0, N[(-3.0 * N[(x$46$im * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{if}\;x.im \leq 420:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.im \leq 2.45 \cdot 10^{+61}:\\
\;\;\;\;x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\\
\mathbf{elif}\;x.im \leq 2.02 \cdot 10^{+96}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 420 or 2.45000000000000013e61 < x.im < 2.02000000000000006e96Initial program 87.1%
sqr-neg87.1%
difference-of-squares88.6%
sub-neg88.6%
associate-*l*93.3%
sub-neg93.3%
remove-double-neg93.3%
+-commutative93.3%
*-commutative93.3%
*-commutative93.3%
distribute-rgt-out93.3%
Simplified93.3%
add-cube-cbrt93.0%
pow393.0%
*-commutative93.0%
Applied egg-rr93.0%
cancel-sign-sub-inv93.0%
unpow393.0%
add-cube-cbrt93.3%
*-commutative93.3%
fma-def93.3%
*-commutative93.3%
Applied egg-rr93.3%
Taylor expanded in x.re around 0 67.0%
Simplified93.7%
Taylor expanded in x.im around 0 71.4%
unpow271.4%
Simplified71.4%
if 420 < x.im < 2.45000000000000013e61Initial program 92.5%
sqr-neg92.5%
difference-of-squares92.5%
sub-neg92.5%
associate-*l*92.5%
sub-neg92.5%
remove-double-neg92.5%
+-commutative92.5%
*-commutative92.5%
*-commutative92.5%
distribute-rgt-out92.5%
Simplified92.5%
add-cube-cbrt91.8%
pow391.9%
*-commutative91.9%
Applied egg-rr91.9%
cancel-sign-sub-inv91.9%
unpow391.8%
add-cube-cbrt92.5%
*-commutative92.5%
fma-def92.4%
*-commutative92.4%
Applied egg-rr92.4%
Taylor expanded in x.re around 0 70.9%
distribute-rgt-out70.9%
unpow270.9%
metadata-eval70.9%
Simplified70.9%
if 2.02000000000000006e96 < x.im Initial program 67.5%
sqr-neg67.5%
difference-of-squares74.3%
sub-neg74.3%
associate-*l*95.2%
sub-neg95.2%
remove-double-neg95.2%
+-commutative95.2%
*-commutative95.2%
*-commutative95.2%
distribute-rgt-out95.2%
Simplified95.2%
add-cube-cbrt95.1%
pow395.1%
*-commutative95.1%
Applied egg-rr95.1%
cancel-sign-sub-inv95.1%
unpow395.1%
add-cube-cbrt95.2%
*-commutative95.2%
fma-def95.3%
*-commutative95.3%
Applied egg-rr95.3%
Taylor expanded in x.re around 0 53.8%
Simplified72.0%
Taylor expanded in x.re around 0 74.3%
unpow274.3%
associate-*r*95.2%
Simplified95.2%
Final simplification75.5%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 1.95e+153) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0)))) (* -3.0 (* x.im (* x.im x.re)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 1.95e+153) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = -3.0 * (x_46_im * (x_46_im * x_46_re));
}
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 <= 1.95d+153) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = (-3.0d0) * (x_46im * (x_46im * x_46re))
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 <= 1.95e+153) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = -3.0 * (x_46_im * (x_46_im * x_46_re));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 1.95e+153: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) else: tmp = -3.0 * (x_46_im * (x_46_im * x_46_re)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 1.95e+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(-3.0 * Float64(x_46_im * Float64(x_46_im * x_46_re))); 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 <= 1.95e+153) tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); else tmp = -3.0 * (x_46_im * (x_46_im * x_46_re)); 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, 1.95e+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[(-3.0 * N[(x$46$im * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1.95 \cdot 10^{+153}:\\
\;\;\;\;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.im \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 1.94999999999999992e153Initial program 87.0%
sqr-neg87.0%
difference-of-squares88.4%
sub-neg88.4%
associate-*l*92.6%
sub-neg92.6%
remove-double-neg92.6%
+-commutative92.6%
*-commutative92.6%
*-commutative92.6%
distribute-rgt-out92.6%
Simplified92.6%
add-cube-cbrt92.3%
pow392.3%
*-commutative92.3%
Applied egg-rr92.3%
cancel-sign-sub-inv92.3%
unpow392.3%
add-cube-cbrt92.6%
*-commutative92.6%
fma-def92.6%
*-commutative92.6%
Applied egg-rr92.6%
Taylor expanded in x.re around 0 68.1%
Simplified94.3%
fma-udef92.9%
associate-*l*92.9%
+-commutative92.9%
associate-*l*92.9%
Applied egg-rr92.9%
if 1.94999999999999992e153 < x.im Initial program 65.0%
sqr-neg65.0%
difference-of-squares73.6%
sub-neg73.6%
associate-*l*99.8%
sub-neg99.8%
remove-double-neg99.8%
+-commutative99.8%
*-commutative99.8%
*-commutative99.8%
distribute-rgt-out99.8%
Simplified99.8%
add-cube-cbrt99.8%
pow399.7%
*-commutative99.7%
Applied egg-rr99.7%
cancel-sign-sub-inv99.7%
unpow399.8%
add-cube-cbrt99.8%
*-commutative99.8%
fma-def100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x.re around 0 47.8%
Simplified65.0%
Taylor expanded in x.re around 0 73.6%
unpow273.6%
associate-*r*99.8%
Simplified99.8%
Final simplification93.9%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 4.2e+169) (* x.re (* x.re x.re)) (* x.re x.re)))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 4.2e+169) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_re * x_46_re;
}
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.2d+169) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = x_46re * x_46re
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.2e+169) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_re * x_46_re;
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 4.2e+169: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = x_46_re * x_46_re return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 4.2e+169) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(x_46_re * x_46_re); 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.2e+169) tmp = x_46_re * (x_46_re * x_46_re); else tmp = x_46_re * x_46_re; 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.2e+169], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$re * x$46$re), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 4.2 \cdot 10^{+169}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot x.re\\
\end{array}
\end{array}
if x.im < 4.2000000000000002e169Initial program 86.4%
sqr-neg86.4%
difference-of-squares87.8%
sub-neg87.8%
associate-*l*92.7%
sub-neg92.7%
remove-double-neg92.7%
+-commutative92.7%
*-commutative92.7%
*-commutative92.7%
distribute-rgt-out92.7%
Simplified92.7%
add-cube-cbrt92.4%
pow392.4%
*-commutative92.4%
Applied egg-rr92.4%
cancel-sign-sub-inv92.4%
unpow392.4%
add-cube-cbrt92.7%
*-commutative92.7%
fma-def92.7%
*-commutative92.7%
Applied egg-rr92.7%
Taylor expanded in x.re around 0 67.8%
Simplified93.5%
Taylor expanded in x.im around 0 65.8%
unpow265.8%
Simplified65.8%
if 4.2000000000000002e169 < x.im Initial program 66.7%
Simplified47.3%
Taylor expanded in x.re around inf 0.8%
Simplified8.9%
Final simplification58.9%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 1.2e+170) (* x.re (* x.re x.re)) (* (* x.im x.im) -2.0)))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 1.2e+170) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = (x_46_im * x_46_im) * -2.0;
}
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 <= 1.2d+170) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (x_46im * x_46im) * (-2.0d0)
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 <= 1.2e+170) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = (x_46_im * x_46_im) * -2.0;
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 1.2e+170: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = (x_46_im * x_46_im) * -2.0 return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 1.2e+170) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(Float64(x_46_im * x_46_im) * -2.0); 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 <= 1.2e+170) tmp = x_46_re * (x_46_re * x_46_re); else tmp = (x_46_im * x_46_im) * -2.0; 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, 1.2e+170], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * x$46$im), $MachinePrecision] * -2.0), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1.2 \cdot 10^{+170}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.im \cdot x.im\right) \cdot -2\\
\end{array}
\end{array}
if x.im < 1.2e170Initial program 86.1%
sqr-neg86.1%
difference-of-squares87.4%
sub-neg87.4%
associate-*l*92.7%
sub-neg92.7%
remove-double-neg92.7%
+-commutative92.7%
*-commutative92.7%
*-commutative92.7%
distribute-rgt-out92.7%
Simplified92.7%
add-cube-cbrt92.4%
pow392.5%
*-commutative92.5%
Applied egg-rr92.5%
cancel-sign-sub-inv92.5%
unpow392.4%
add-cube-cbrt92.7%
*-commutative92.7%
fma-def92.8%
*-commutative92.8%
Applied egg-rr92.8%
Taylor expanded in x.re around 0 67.5%
Simplified93.1%
Taylor expanded in x.im around 0 65.5%
unpow265.5%
Simplified65.5%
if 1.2e170 < x.im Initial program 68.7%
sqr-neg68.7%
difference-of-squares78.7%
sub-neg78.7%
associate-*l*99.8%
sub-neg99.8%
remove-double-neg99.8%
+-commutative99.8%
*-commutative99.8%
*-commutative99.8%
distribute-rgt-out99.8%
Simplified99.8%
distribute-lft-in99.8%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+31.8%
Applied egg-rr31.8%
Taylor expanded in x.re around 0 31.8%
*-commutative31.8%
unpow231.8%
Simplified31.8%
Final simplification61.5%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (* 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;
}
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
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.im = abs(x.im) def code(x_46_re, x_46_im): return x_46_re * x_46_re
x.im = abs(x.im) function code(x_46_re, x_46_im) return 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; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := N[(x$46$re * x$46$re), $MachinePrecision]
\begin{array}{l}
x.im = |x.im|\\
\\
x.re \cdot x.re
\end{array}
Initial program 84.0%
Simplified80.5%
Taylor expanded in x.re around inf 57.9%
Simplified27.9%
Final simplification27.9%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 1.0)
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
return 1.0;
}
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 = 1.0d0
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
return 1.0;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): return 1.0
x.im = abs(x.im) function code(x_46_re, x_46_im) return 1.0 end
x.im = abs(x.im) function tmp = code(x_46_re, x_46_im) tmp = 1.0; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := 1.0
\begin{array}{l}
x.im = |x.im|\\
\\
1
\end{array}
Initial program 84.0%
Simplified80.5%
associate-*r*80.5%
associate-*l*80.5%
+-commutative80.5%
flip-+17.7%
pow217.7%
associate-*l*17.6%
associate-*r*17.6%
associate-*r*17.6%
pow-prod-up17.6%
metadata-eval17.6%
associate-*l*17.6%
associate-*r*17.6%
associate-*r*19.7%
Applied egg-rr19.7%
Simplified2.2%
Taylor expanded in x.re around 0 2.6%
Final simplification2.6%
(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 2023292
(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)))