
(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 5 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.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) {
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
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) {
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): 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) 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_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_] := 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]]]
\begin{array}{l}
\\
\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}
\end{array}
if x.im < -2.05000000000000002e133Initial program 64.3%
*-commutative64.3%
distribute-lft-out64.3%
associate-*l*64.3%
*-commutative64.3%
distribute-rgt-out--64.2%
associate--l-64.2%
associate--l-64.2%
sub-neg64.2%
associate--l+64.2%
fma-udef73.5%
neg-mul-173.5%
count-273.5%
associate-*l*73.5%
distribute-rgt-out--73.5%
associate-*r*73.5%
metadata-eval73.5%
Simplified73.5%
Taylor expanded in x.re around 0 73.6%
associate-*r*73.5%
*-commutative73.5%
*-commutative73.5%
metadata-eval73.5%
distribute-rgt-out73.5%
distribute-lft-in73.6%
metadata-eval73.6%
distribute-lft-neg-in73.6%
count-273.6%
distribute-rgt-neg-in73.6%
distribute-rgt-out73.6%
distribute-lft-out73.6%
distribute-rgt-neg-in73.6%
count-273.6%
distribute-lft-neg-in73.6%
metadata-eval73.6%
mul-1-neg73.6%
distribute-rgt-neg-in73.6%
distribute-lft-neg-in73.6%
unpow273.6%
distribute-rgt-neg-out73.6%
*-commutative73.6%
Simplified73.5%
add-sqr-sqrt35.8%
pow235.8%
associate-*r*35.8%
sqrt-prod35.8%
sqrt-prod0.0%
add-sqr-sqrt46.4%
Applied egg-rr46.4%
unpow246.4%
swap-sqr35.7%
add-sqr-sqrt73.5%
*-commutative73.5%
associate-*l*73.6%
*-commutative73.6%
*-commutative73.6%
associate-*l*93.0%
Applied egg-rr93.0%
if -2.05000000000000002e133 < x.im < 7.59999999999999933e153Initial program 91.9%
*-commutative91.9%
distribute-lft-out91.9%
associate-*l*91.9%
*-commutative91.9%
distribute-rgt-out--99.8%
associate--l-99.8%
associate--l-99.8%
sub-neg99.8%
associate--l+99.8%
fma-udef99.8%
neg-mul-199.8%
count-299.8%
associate-*l*99.8%
distribute-rgt-out--99.8%
associate-*r*99.8%
metadata-eval99.8%
Simplified99.8%
fma-udef99.8%
Applied egg-rr99.8%
if 7.59999999999999933e153 < x.im Initial program 53.7%
*-commutative53.7%
distribute-lft-out53.7%
associate-*l*53.7%
*-commutative53.7%
distribute-rgt-out--53.7%
associate--l-53.7%
associate--l-53.7%
sub-neg53.7%
associate--l+53.7%
fma-udef66.8%
neg-mul-166.8%
count-266.8%
associate-*l*66.8%
distribute-rgt-out--66.8%
associate-*r*66.8%
metadata-eval66.8%
Simplified66.8%
Taylor expanded in x.re around 0 66.8%
associate-*r*66.8%
*-commutative66.8%
*-commutative66.8%
metadata-eval66.8%
distribute-rgt-out66.8%
distribute-lft-in66.8%
metadata-eval66.8%
distribute-lft-neg-in66.8%
count-266.8%
distribute-rgt-neg-in66.8%
distribute-rgt-out66.8%
distribute-lft-out66.8%
distribute-rgt-neg-in66.8%
count-266.8%
distribute-lft-neg-in66.8%
metadata-eval66.8%
mul-1-neg66.8%
distribute-rgt-neg-in66.8%
distribute-lft-neg-in66.8%
unpow266.8%
distribute-rgt-neg-out66.8%
*-commutative66.8%
Simplified66.8%
add-sqr-sqrt22.5%
pow222.5%
associate-*r*22.5%
sqrt-prod22.5%
sqrt-prod34.7%
add-sqr-sqrt34.7%
Applied egg-rr34.7%
unpow234.7%
swap-sqr22.5%
add-sqr-sqrt66.8%
associate-*r*86.8%
*-commutative86.8%
associate-*r*87.0%
*-commutative87.0%
Applied egg-rr87.0%
Final simplification97.5%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -2.4e+109) (not (<= x.im 1.4e-57))) (* -3.0 (* x.re (* x.im x.im))) (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -2.4e+109) || !(x_46_im <= 1.4e-57)) {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
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 <= (-2.4d+109)) .or. (.not. (x_46im <= 1.4d-57))) then
tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
else
tmp = x_46re * (x_46re * x_46re)
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -2.4e+109) || !(x_46_im <= 1.4e-57)) {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -2.4e+109) or not (x_46_im <= 1.4e-57): tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)) else: tmp = x_46_re * (x_46_re * x_46_re) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -2.4e+109) || !(x_46_im <= 1.4e-57)) tmp = Float64(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im))); else tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_im <= -2.4e+109) || ~((x_46_im <= 1.4e-57))) tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)); else tmp = x_46_re * (x_46_re * x_46_re); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -2.4e+109], N[Not[LessEqual[x$46$im, 1.4e-57]], $MachinePrecision]], N[(-3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -2.4 \cdot 10^{+109} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-57}\right):\\
\;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\end{array}
\end{array}
if x.im < -2.39999999999999987e109 or 1.4e-57 < x.im Initial program 70.6%
*-commutative70.6%
distribute-lft-out70.6%
associate-*l*70.5%
*-commutative70.5%
distribute-rgt-out--77.4%
associate--l-77.4%
associate--l-77.4%
sub-neg77.4%
associate--l+77.4%
fma-udef83.4%
neg-mul-183.4%
count-283.4%
associate-*l*83.4%
distribute-rgt-out--83.4%
associate-*r*83.4%
metadata-eval83.4%
Simplified83.4%
Taylor expanded in x.re around 0 73.2%
unpow273.2%
Simplified73.2%
if -2.39999999999999987e109 < x.im < 1.4e-57Initial program 94.9%
*-commutative94.9%
distribute-lft-out94.9%
associate-*l*94.9%
*-commutative94.9%
distribute-rgt-out--99.8%
associate--l-99.8%
associate--l-99.8%
sub-neg99.8%
associate--l+99.8%
fma-udef99.8%
neg-mul-199.8%
count-299.8%
associate-*l*99.8%
distribute-rgt-out--99.8%
associate-*r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x.re around inf 89.5%
unpow289.5%
Simplified89.5%
Final simplification82.1%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -4e+109) (not (<= x.im 5.2e-58))) (* x.im (* (* x.im x.re) -3.0)) (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -4e+109) || !(x_46_im <= 5.2e-58)) {
tmp = x_46_im * ((x_46_im * x_46_re) * -3.0);
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
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 <= (-4d+109)) .or. (.not. (x_46im <= 5.2d-58))) then
tmp = x_46im * ((x_46im * x_46re) * (-3.0d0))
else
tmp = x_46re * (x_46re * x_46re)
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -4e+109) || !(x_46_im <= 5.2e-58)) {
tmp = x_46_im * ((x_46_im * x_46_re) * -3.0);
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -4e+109) or not (x_46_im <= 5.2e-58): tmp = x_46_im * ((x_46_im * x_46_re) * -3.0) else: tmp = x_46_re * (x_46_re * x_46_re) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -4e+109) || !(x_46_im <= 5.2e-58)) tmp = Float64(x_46_im * Float64(Float64(x_46_im * x_46_re) * -3.0)); else tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_im <= -4e+109) || ~((x_46_im <= 5.2e-58))) tmp = x_46_im * ((x_46_im * x_46_re) * -3.0); else tmp = x_46_re * (x_46_re * x_46_re); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -4e+109], N[Not[LessEqual[x$46$im, 5.2e-58]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$im * x$46$re), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -4 \cdot 10^{+109} \lor \neg \left(x.im \leq 5.2 \cdot 10^{-58}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.im \cdot x.re\right) \cdot -3\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\end{array}
\end{array}
if x.im < -3.99999999999999993e109 or 5.20000000000000013e-58 < x.im Initial program 70.6%
*-commutative70.6%
distribute-lft-out70.6%
associate-*l*70.5%
*-commutative70.5%
distribute-rgt-out--77.4%
associate--l-77.4%
associate--l-77.4%
sub-neg77.4%
associate--l+77.4%
fma-udef83.4%
neg-mul-183.4%
count-283.4%
associate-*l*83.4%
distribute-rgt-out--83.4%
associate-*r*83.4%
metadata-eval83.4%
Simplified83.4%
Taylor expanded in x.re around 0 73.2%
associate-*r*73.1%
*-commutative73.1%
*-commutative73.1%
metadata-eval73.1%
distribute-rgt-out73.1%
distribute-lft-in73.2%
metadata-eval73.2%
distribute-lft-neg-in73.2%
count-273.2%
distribute-rgt-neg-in73.2%
distribute-rgt-out73.2%
distribute-lft-out73.2%
distribute-rgt-neg-in73.2%
count-273.2%
distribute-lft-neg-in73.2%
metadata-eval73.2%
mul-1-neg73.2%
distribute-rgt-neg-in73.2%
distribute-lft-neg-in73.2%
unpow273.2%
distribute-rgt-neg-out73.2%
*-commutative73.2%
Simplified73.1%
add-sqr-sqrt36.6%
pow236.6%
associate-*r*36.5%
sqrt-prod33.9%
sqrt-prod21.2%
add-sqr-sqrt40.3%
Applied egg-rr40.3%
unpow240.3%
swap-sqr34.0%
add-sqr-sqrt73.1%
associate-*r*84.2%
*-commutative84.2%
associate-*r*84.2%
*-commutative84.2%
Applied egg-rr84.2%
if -3.99999999999999993e109 < x.im < 5.20000000000000013e-58Initial program 94.9%
*-commutative94.9%
distribute-lft-out94.9%
associate-*l*94.9%
*-commutative94.9%
distribute-rgt-out--99.8%
associate--l-99.8%
associate--l-99.8%
sub-neg99.8%
associate--l+99.8%
fma-udef99.8%
neg-mul-199.8%
count-299.8%
associate-*l*99.8%
distribute-rgt-out--99.8%
associate-*r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x.re around inf 89.5%
unpow289.5%
Simplified89.5%
Final simplification87.1%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -2e+109) (not (<= x.im 1.4e-57))) (* (* x.im (* x.im x.re)) -3.0) (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -2e+109) || !(x_46_im <= 1.4e-57)) {
tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0;
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
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 <= (-2d+109)) .or. (.not. (x_46im <= 1.4d-57))) then
tmp = (x_46im * (x_46im * x_46re)) * (-3.0d0)
else
tmp = x_46re * (x_46re * x_46re)
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -2e+109) || !(x_46_im <= 1.4e-57)) {
tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0;
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -2e+109) or not (x_46_im <= 1.4e-57): tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0 else: tmp = x_46_re * (x_46_re * x_46_re) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -2e+109) || !(x_46_im <= 1.4e-57)) tmp = Float64(Float64(x_46_im * Float64(x_46_im * x_46_re)) * -3.0); else tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_im <= -2e+109) || ~((x_46_im <= 1.4e-57))) tmp = (x_46_im * (x_46_im * x_46_re)) * -3.0; else tmp = x_46_re * (x_46_re * x_46_re); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -2e+109], N[Not[LessEqual[x$46$im, 1.4e-57]], $MachinePrecision]], N[(N[(x$46$im * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -2 \cdot 10^{+109} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-57}\right):\\
\;\;\;\;\left(x.im \cdot \left(x.im \cdot x.re\right)\right) \cdot -3\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\end{array}
\end{array}
if x.im < -1.99999999999999996e109 or 1.4e-57 < x.im Initial program 70.6%
*-commutative70.6%
distribute-lft-out70.6%
associate-*l*70.5%
*-commutative70.5%
distribute-rgt-out--77.4%
associate--l-77.4%
associate--l-77.4%
sub-neg77.4%
associate--l+77.4%
fma-udef83.4%
neg-mul-183.4%
count-283.4%
associate-*l*83.4%
distribute-rgt-out--83.4%
associate-*r*83.4%
metadata-eval83.4%
Simplified83.4%
Taylor expanded in x.re around 0 73.2%
associate-*r*73.1%
*-commutative73.1%
*-commutative73.1%
metadata-eval73.1%
distribute-rgt-out73.1%
distribute-lft-in73.2%
metadata-eval73.2%
distribute-lft-neg-in73.2%
count-273.2%
distribute-rgt-neg-in73.2%
distribute-rgt-out73.2%
distribute-lft-out73.2%
distribute-rgt-neg-in73.2%
count-273.2%
distribute-lft-neg-in73.2%
metadata-eval73.2%
mul-1-neg73.2%
distribute-rgt-neg-in73.2%
distribute-lft-neg-in73.2%
unpow273.2%
distribute-rgt-neg-out73.2%
*-commutative73.2%
Simplified73.1%
add-sqr-sqrt36.6%
pow236.6%
associate-*r*36.5%
sqrt-prod33.9%
sqrt-prod21.2%
add-sqr-sqrt40.3%
Applied egg-rr40.3%
unpow240.3%
swap-sqr34.0%
add-sqr-sqrt73.1%
*-commutative73.1%
associate-*l*73.2%
*-commutative73.2%
*-commutative73.2%
associate-*l*84.3%
Applied egg-rr84.3%
if -1.99999999999999996e109 < x.im < 1.4e-57Initial program 94.9%
*-commutative94.9%
distribute-lft-out94.9%
associate-*l*94.9%
*-commutative94.9%
distribute-rgt-out--99.8%
associate--l-99.8%
associate--l-99.8%
sub-neg99.8%
associate--l+99.8%
fma-udef99.8%
neg-mul-199.8%
count-299.8%
associate-*l*99.8%
distribute-rgt-out--99.8%
associate-*r*99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x.re around inf 89.5%
unpow289.5%
Simplified89.5%
Final simplification87.2%
(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 83.9%
*-commutative83.9%
distribute-lft-out83.9%
associate-*l*83.8%
*-commutative83.8%
distribute-rgt-out--89.7%
associate--l-89.7%
associate--l-89.7%
sub-neg89.7%
associate--l+89.7%
fma-udef92.4%
neg-mul-192.4%
count-292.4%
associate-*l*92.4%
distribute-rgt-out--92.4%
associate-*r*92.4%
metadata-eval92.4%
Simplified92.4%
Taylor expanded in x.re around inf 57.8%
unpow257.8%
Simplified57.8%
Final simplification57.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 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)))