
(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}
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 1.6e+145) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0)))) (* x.im (* -3.0 (* 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.6e+145) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = x_46_im * (-3.0 * (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.6d+145) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = x_46im * ((-3.0d0) * (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.6e+145) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = x_46_im * (-3.0 * (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.6e+145: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) else: tmp = x_46_im * (-3.0 * (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.6e+145) 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(-3.0 * 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.6e+145) tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); else tmp = x_46_im * (-3.0 * (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.6e+145], 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[(-3.0 * 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.6 \cdot 10^{+145}:\\
\;\;\;\;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(-3 \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 1.60000000000000004e145Initial program 86.3%
*-commutative86.3%
distribute-lft-out86.3%
associate-*l*86.2%
*-commutative86.2%
distribute-rgt-out--93.4%
associate--l-93.4%
associate--l-93.4%
sub-neg93.4%
associate--l+93.4%
fma-udef94.7%
neg-mul-194.7%
count-294.7%
associate-*l*94.7%
distribute-rgt-out--94.7%
associate-*r*94.7%
metadata-eval94.7%
Simplified94.7%
fma-udef93.4%
Applied egg-rr93.4%
if 1.60000000000000004e145 < x.im Initial program 49.0%
*-commutative49.0%
distribute-lft-out49.0%
associate-*l*49.0%
*-commutative49.0%
distribute-rgt-out--49.0%
associate--l-49.0%
associate--l-49.0%
sub-neg49.0%
associate--l+49.0%
fma-udef61.5%
neg-mul-161.5%
count-261.5%
associate-*l*61.5%
distribute-rgt-out--61.5%
associate-*r*61.4%
metadata-eval61.4%
Simplified61.4%
Taylor expanded in x.re around 0 61.5%
associate-*r*61.5%
unpow261.5%
Simplified61.5%
add-sqr-sqrt35.9%
pow235.9%
*-commutative35.9%
sqrt-prod35.9%
sqrt-prod55.9%
add-sqr-sqrt56.0%
*-commutative56.0%
Applied egg-rr56.0%
unpow256.0%
swap-sqr35.9%
add-sqr-sqrt61.5%
associate-*l*61.5%
*-commutative61.5%
associate-*r*90.4%
associate-*r*90.5%
*-commutative90.5%
associate-*r*90.5%
Applied egg-rr90.5%
Final simplification93.0%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (or (<= x.im 3.1e+66) (and (not (<= x.im 1.2e+109)) (<= x.im 5.4e+127))) (* 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 <= 3.1e+66) || (!(x_46_im <= 1.2e+109) && (x_46_im <= 5.4e+127))) {
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 <= 3.1d+66) .or. (.not. (x_46im <= 1.2d+109)) .and. (x_46im <= 5.4d+127)) 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 <= 3.1e+66) || (!(x_46_im <= 1.2e+109) && (x_46_im <= 5.4e+127))) {
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 <= 3.1e+66) or (not (x_46_im <= 1.2e+109) and (x_46_im <= 5.4e+127)): 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 <= 3.1e+66) || (!(x_46_im <= 1.2e+109) && (x_46_im <= 5.4e+127))) 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 <= 3.1e+66) || (~((x_46_im <= 1.2e+109)) && (x_46_im <= 5.4e+127))) 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, 3.1e+66], And[N[Not[LessEqual[x$46$im, 1.2e+109]], $MachinePrecision], LessEqual[x$46$im, 5.4e+127]]], 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 3.1 \cdot 10^{+66} \lor \neg \left(x.im \leq 1.2 \cdot 10^{+109}\right) \land x.im \leq 5.4 \cdot 10^{+127}:\\
\;\;\;\;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 < 3.10000000000000019e66 or 1.19999999999999994e109 < x.im < 5.4000000000000004e127Initial program 86.6%
*-commutative86.6%
distribute-lft-out86.6%
associate-*l*86.5%
*-commutative86.5%
distribute-rgt-out--93.1%
associate--l-93.1%
associate--l-93.1%
sub-neg93.1%
associate--l+93.1%
fma-udef94.5%
neg-mul-194.5%
count-294.5%
associate-*l*94.5%
distribute-rgt-out--94.5%
associate-*r*94.5%
metadata-eval94.5%
Simplified94.5%
Taylor expanded in x.re around inf 70.4%
unpow270.4%
Simplified70.4%
if 3.10000000000000019e66 < x.im < 1.19999999999999994e109 or 5.4000000000000004e127 < x.im Initial program 56.3%
*-commutative56.3%
distribute-lft-out56.3%
associate-*l*56.2%
*-commutative56.2%
distribute-rgt-out--61.0%
associate--l-61.0%
associate--l-61.0%
sub-neg61.0%
associate--l+61.0%
fma-udef70.5%
neg-mul-170.5%
count-270.5%
associate-*l*70.5%
distribute-rgt-out--70.5%
associate-*r*70.4%
metadata-eval70.4%
Simplified70.4%
fma-udef60.9%
Applied egg-rr60.9%
Taylor expanded in x.re around 0 65.8%
unpow265.8%
*-commutative65.8%
associate-*r*87.8%
Simplified87.8%
Final simplification73.3%
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 3.1e+66)
t_0
(if (<= x.im 3.3e+109)
(* (* x.im -3.0) (* x.im x.re))
(if (<= x.im 5.4e+127) 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 <= 3.1e+66) {
tmp = t_0;
} else if (x_46_im <= 3.3e+109) {
tmp = (x_46_im * -3.0) * (x_46_im * x_46_re);
} else if (x_46_im <= 5.4e+127) {
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 <= 3.1d+66) then
tmp = t_0
else if (x_46im <= 3.3d+109) then
tmp = (x_46im * (-3.0d0)) * (x_46im * x_46re)
else if (x_46im <= 5.4d+127) 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 <= 3.1e+66) {
tmp = t_0;
} else if (x_46_im <= 3.3e+109) {
tmp = (x_46_im * -3.0) * (x_46_im * x_46_re);
} else if (x_46_im <= 5.4e+127) {
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 <= 3.1e+66: tmp = t_0 elif x_46_im <= 3.3e+109: tmp = (x_46_im * -3.0) * (x_46_im * x_46_re) elif x_46_im <= 5.4e+127: 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 <= 3.1e+66) tmp = t_0; elseif (x_46_im <= 3.3e+109) tmp = Float64(Float64(x_46_im * -3.0) * Float64(x_46_im * x_46_re)); elseif (x_46_im <= 5.4e+127) 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 <= 3.1e+66) tmp = t_0; elseif (x_46_im <= 3.3e+109) tmp = (x_46_im * -3.0) * (x_46_im * x_46_re); elseif (x_46_im <= 5.4e+127) 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, 3.1e+66], t$95$0, If[LessEqual[x$46$im, 3.3e+109], N[(N[(x$46$im * -3.0), $MachinePrecision] * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 5.4e+127], 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 3.1 \cdot 10^{+66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.im \leq 3.3 \cdot 10^{+109}:\\
\;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.im \cdot x.re\right)\\
\mathbf{elif}\;x.im \leq 5.4 \cdot 10^{+127}:\\
\;\;\;\;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 < 3.10000000000000019e66 or 3.2999999999999999e109 < x.im < 5.4000000000000004e127Initial program 86.6%
*-commutative86.6%
distribute-lft-out86.6%
associate-*l*86.5%
*-commutative86.5%
distribute-rgt-out--93.1%
associate--l-93.1%
associate--l-93.1%
sub-neg93.1%
associate--l+93.1%
fma-udef94.5%
neg-mul-194.5%
count-294.5%
associate-*l*94.5%
distribute-rgt-out--94.5%
associate-*r*94.5%
metadata-eval94.5%
Simplified94.5%
Taylor expanded in x.re around inf 70.4%
unpow270.4%
Simplified70.4%
if 3.10000000000000019e66 < x.im < 3.2999999999999999e109Initial program 88.5%
*-commutative88.5%
distribute-lft-out88.5%
associate-*l*88.4%
*-commutative88.4%
distribute-rgt-out--99.5%
associate--l-99.5%
associate--l-99.5%
sub-neg99.5%
associate--l+99.5%
fma-udef99.5%
neg-mul-199.5%
count-299.5%
associate-*l*99.5%
distribute-rgt-out--99.5%
associate-*r*99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in x.re around 0 88.4%
associate-*r*88.4%
unpow288.4%
Simplified88.4%
add-sqr-sqrt44.1%
pow244.1%
*-commutative44.1%
sqrt-prod44.1%
sqrt-prod43.5%
add-sqr-sqrt44.1%
*-commutative44.1%
Applied egg-rr44.1%
unpow244.1%
swap-sqr44.1%
add-sqr-sqrt88.4%
associate-*l*88.4%
*-commutative88.4%
associate-*r*88.4%
associate-*r*88.4%
Applied egg-rr88.4%
if 5.4000000000000004e127 < x.im Initial program 47.5%
*-commutative47.5%
distribute-lft-out47.5%
associate-*l*47.5%
*-commutative47.5%
distribute-rgt-out--50.5%
associate--l-50.5%
associate--l-50.5%
sub-neg50.5%
associate--l+50.5%
fma-udef62.6%
neg-mul-162.6%
count-262.6%
associate-*l*62.6%
distribute-rgt-out--62.6%
associate-*r*62.6%
metadata-eval62.6%
Simplified62.6%
fma-udef50.5%
Applied egg-rr50.5%
Taylor expanded in x.re around 0 59.6%
unpow259.6%
*-commutative59.6%
associate-*r*87.7%
Simplified87.7%
Final simplification73.3%
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 3.5e+66)
t_0
(if (<= x.im 1.25e+110)
(* (* x.im -3.0) (* x.im x.re))
(if (<= x.im 7.5e+127) t_0 (* x.im (* -3.0 (* 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 <= 3.5e+66) {
tmp = t_0;
} else if (x_46_im <= 1.25e+110) {
tmp = (x_46_im * -3.0) * (x_46_im * x_46_re);
} else if (x_46_im <= 7.5e+127) {
tmp = t_0;
} else {
tmp = x_46_im * (-3.0 * (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 <= 3.5d+66) then
tmp = t_0
else if (x_46im <= 1.25d+110) then
tmp = (x_46im * (-3.0d0)) * (x_46im * x_46re)
else if (x_46im <= 7.5d+127) then
tmp = t_0
else
tmp = x_46im * ((-3.0d0) * (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 <= 3.5e+66) {
tmp = t_0;
} else if (x_46_im <= 1.25e+110) {
tmp = (x_46_im * -3.0) * (x_46_im * x_46_re);
} else if (x_46_im <= 7.5e+127) {
tmp = t_0;
} else {
tmp = x_46_im * (-3.0 * (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 <= 3.5e+66: tmp = t_0 elif x_46_im <= 1.25e+110: tmp = (x_46_im * -3.0) * (x_46_im * x_46_re) elif x_46_im <= 7.5e+127: tmp = t_0 else: tmp = x_46_im * (-3.0 * (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 <= 3.5e+66) tmp = t_0; elseif (x_46_im <= 1.25e+110) tmp = Float64(Float64(x_46_im * -3.0) * Float64(x_46_im * x_46_re)); elseif (x_46_im <= 7.5e+127) tmp = t_0; else tmp = Float64(x_46_im * Float64(-3.0 * 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 <= 3.5e+66) tmp = t_0; elseif (x_46_im <= 1.25e+110) tmp = (x_46_im * -3.0) * (x_46_im * x_46_re); elseif (x_46_im <= 7.5e+127) tmp = t_0; else tmp = x_46_im * (-3.0 * (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, 3.5e+66], t$95$0, If[LessEqual[x$46$im, 1.25e+110], N[(N[(x$46$im * -3.0), $MachinePrecision] * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 7.5e+127], t$95$0, N[(x$46$im * N[(-3.0 * 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 3.5 \cdot 10^{+66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.im \leq 1.25 \cdot 10^{+110}:\\
\;\;\;\;\left(x.im \cdot -3\right) \cdot \left(x.im \cdot x.re\right)\\
\mathbf{elif}\;x.im \leq 7.5 \cdot 10^{+127}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(-3 \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 3.4999999999999997e66 or 1.24999999999999995e110 < x.im < 7.4999999999999996e127Initial program 86.6%
*-commutative86.6%
distribute-lft-out86.6%
associate-*l*86.5%
*-commutative86.5%
distribute-rgt-out--93.1%
associate--l-93.1%
associate--l-93.1%
sub-neg93.1%
associate--l+93.1%
fma-udef94.5%
neg-mul-194.5%
count-294.5%
associate-*l*94.5%
distribute-rgt-out--94.5%
associate-*r*94.5%
metadata-eval94.5%
Simplified94.5%
Taylor expanded in x.re around inf 70.4%
unpow270.4%
Simplified70.4%
if 3.4999999999999997e66 < x.im < 1.24999999999999995e110Initial program 88.5%
*-commutative88.5%
distribute-lft-out88.5%
associate-*l*88.4%
*-commutative88.4%
distribute-rgt-out--99.5%
associate--l-99.5%
associate--l-99.5%
sub-neg99.5%
associate--l+99.5%
fma-udef99.5%
neg-mul-199.5%
count-299.5%
associate-*l*99.5%
distribute-rgt-out--99.5%
associate-*r*99.1%
metadata-eval99.1%
Simplified99.1%
Taylor expanded in x.re around 0 88.4%
associate-*r*88.4%
unpow288.4%
Simplified88.4%
add-sqr-sqrt44.1%
pow244.1%
*-commutative44.1%
sqrt-prod44.1%
sqrt-prod43.5%
add-sqr-sqrt44.1%
*-commutative44.1%
Applied egg-rr44.1%
unpow244.1%
swap-sqr44.1%
add-sqr-sqrt88.4%
associate-*l*88.4%
*-commutative88.4%
associate-*r*88.4%
associate-*r*88.4%
Applied egg-rr88.4%
if 7.4999999999999996e127 < x.im Initial program 47.5%
*-commutative47.5%
distribute-lft-out47.5%
associate-*l*47.5%
*-commutative47.5%
distribute-rgt-out--50.5%
associate--l-50.5%
associate--l-50.5%
sub-neg50.5%
associate--l+50.5%
fma-udef62.6%
neg-mul-162.6%
count-262.6%
associate-*l*62.6%
distribute-rgt-out--62.6%
associate-*r*62.6%
metadata-eval62.6%
Simplified62.6%
Taylor expanded in x.re around 0 59.6%
associate-*r*59.6%
unpow259.6%
Simplified59.6%
add-sqr-sqrt34.8%
pow234.8%
*-commutative34.8%
sqrt-prod34.8%
sqrt-prod54.2%
add-sqr-sqrt54.3%
*-commutative54.3%
Applied egg-rr54.3%
unpow254.3%
swap-sqr34.8%
add-sqr-sqrt59.6%
associate-*l*59.6%
*-commutative59.6%
associate-*r*87.7%
associate-*r*87.7%
*-commutative87.7%
associate-*r*87.7%
Applied egg-rr87.7%
Final simplification73.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 81.6%
*-commutative81.6%
distribute-lft-out81.6%
associate-*l*81.6%
*-commutative81.6%
distribute-rgt-out--87.8%
associate--l-87.8%
associate--l-87.8%
sub-neg87.8%
associate--l+87.8%
fma-udef90.5%
neg-mul-190.5%
count-290.5%
associate-*l*90.5%
distribute-rgt-out--90.5%
associate-*r*90.6%
metadata-eval90.6%
Simplified90.6%
Taylor expanded in x.re around inf 61.0%
unpow261.0%
Simplified61.0%
Final simplification61.0%
(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 2023217
(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)))