
(FPCore (x.re x.im) :precision binary64 (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im): return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
function code(x_46_re, x_46_im) return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im)) end
function tmp = code(x_46_re, x_46_im) tmp = (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im); end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im) :precision binary64 (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im): return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
function code(x_46_re, x_46_im) return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im)) end
function tmp = code(x_46_re, x_46_im) tmp = (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im); end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\end{array}
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.re (fma x.re x.re (* x.im (* x.im -3.0))))))
(if (<= x.re -4e-144)
t_0
(if (<= x.re 5.9e-130)
(* x.im (* x.re (* x.im -3.0)))
(if (<= x.re 5e+177) t_0 (* x.re (* x.re x.re)))))))
double code(double x_46_re, double x_46_im) {
double t_0 = x_46_re * fma(x_46_re, x_46_re, (x_46_im * (x_46_im * -3.0)));
double tmp;
if (x_46_re <= -4e-144) {
tmp = t_0;
} else if (x_46_re <= 5.9e-130) {
tmp = x_46_im * (x_46_re * (x_46_im * -3.0));
} else if (x_46_re <= 5e+177) {
tmp = t_0;
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
return tmp;
}
function code(x_46_re, x_46_im) t_0 = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(x_46_im * Float64(x_46_im * -3.0)))) tmp = 0.0 if (x_46_re <= -4e-144) tmp = t_0; elseif (x_46_re <= 5.9e-130) tmp = Float64(x_46_im * Float64(x_46_re * Float64(x_46_im * -3.0))); elseif (x_46_re <= 5e+177) tmp = t_0; else tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); end return tmp end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(x$46$re * x$46$re + N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -4e-144], t$95$0, If[LessEqual[x$46$re, 5.9e-130], N[(x$46$im * N[(x$46$re * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 5e+177], t$95$0, N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{if}\;x.re \leq -4 \cdot 10^{-144}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.re \leq 5.9 \cdot 10^{-130}:\\
\;\;\;\;x.im \cdot \left(x.re \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{elif}\;x.re \leq 5 \cdot 10^{+177}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\end{array}
\end{array}
if x.re < -3.9999999999999998e-144 or 5.9000000000000003e-130 < x.re < 5.0000000000000003e177Initial program 90.8%
*-commutative90.8%
distribute-lft-out90.8%
associate-*l*90.8%
*-commutative90.8%
distribute-rgt-out--94.7%
associate--l-94.7%
associate--l-94.7%
sub-neg94.7%
associate--l+94.7%
fma-udef97.9%
neg-mul-197.9%
count-297.9%
associate-*l*97.9%
distribute-rgt-out--97.9%
associate-*r*98.0%
metadata-eval98.0%
Simplified98.0%
if -3.9999999999999998e-144 < x.re < 5.9000000000000003e-130Initial program 85.9%
*-commutative85.9%
distribute-lft-out85.9%
associate-*l*85.8%
*-commutative85.8%
distribute-rgt-out--85.9%
associate--l-85.9%
associate--l-85.9%
sub-neg85.9%
associate--l+85.9%
fma-udef85.9%
neg-mul-185.9%
count-285.9%
associate-*l*85.9%
distribute-rgt-out--85.9%
associate-*r*85.8%
metadata-eval85.8%
Simplified85.8%
Taylor expanded in x.re around 0 85.8%
associate-*r*85.8%
unpow285.8%
Simplified85.8%
pow185.8%
*-commutative85.8%
associate-*l*99.8%
*-commutative99.8%
*-commutative99.8%
associate-*l*99.8%
*-commutative99.8%
Applied egg-rr99.8%
if 5.0000000000000003e177 < x.re Initial program 53.6%
*-commutative53.6%
distribute-lft-out53.6%
associate-*l*53.6%
*-commutative53.6%
distribute-rgt-out--78.6%
associate--l-78.6%
associate--l-78.6%
sub-neg78.6%
associate--l+78.6%
fma-udef78.6%
neg-mul-178.6%
count-278.6%
associate-*l*78.6%
distribute-rgt-out--78.6%
associate-*r*78.6%
metadata-eval78.6%
Simplified78.6%
Taylor expanded in x.re around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification98.7%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* x.re (- (* x.re x.re) (* x.im x.im)))
(* x.im (+ (* x.re x.im) (* x.re x.im))))
INFINITY)
(fma (* x.re x.re) x.re (* (* x.re x.im) (* x.im -3.0)))
(* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
tmp = fma((x_46_re * x_46_re), x_46_re, ((x_46_re * x_46_im) * (x_46_im * -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 (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf) tmp = fma(Float64(x_46_re * x_46_re), x_46_re, Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0))); else tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); end return tmp end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$re + N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $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.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.re \cdot x.re, x.re, \left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) < +inf.0Initial program 95.0%
*-commutative95.0%
sub-neg95.0%
distribute-lft-in92.8%
associate--l+92.8%
cube-unmult92.8%
*-commutative92.8%
distribute-lft-out92.8%
associate-*l*92.8%
distribute-lft-out--92.8%
neg-mul-192.8%
count-292.8%
associate-*l*92.8%
distribute-rgt-out--92.8%
associate-*l*92.8%
metadata-eval92.8%
Simplified92.8%
add-sqr-sqrt65.3%
pow265.3%
*-commutative65.3%
sqrt-prod48.3%
sqrt-prod20.4%
add-sqr-sqrt50.3%
Applied egg-rr50.3%
*-commutative50.3%
unpow-prod-down48.2%
pow248.2%
add-sqr-sqrt92.8%
pow292.8%
associate-*r*97.7%
Applied egg-rr97.7%
unpow397.6%
fma-def99.8%
associate-*l*99.8%
Applied egg-rr99.8%
if +inf.0 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) Initial program 0.0%
*-commutative0.0%
distribute-lft-out0.0%
associate-*l*0.0%
*-commutative0.0%
distribute-rgt-out--50.0%
associate--l-50.0%
associate--l-50.0%
sub-neg50.0%
associate--l+50.0%
fma-udef69.2%
neg-mul-169.2%
count-269.2%
associate-*l*69.2%
distribute-rgt-out--69.2%
associate-*r*69.2%
metadata-eval69.2%
Simplified69.2%
Taylor expanded in x.re around inf 80.8%
unpow280.8%
Simplified80.8%
Final simplification97.8%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* x.re (- (* x.re x.re) (* x.im x.im)))
(* x.im (+ (* x.re x.im) (* x.re x.im))))
INFINITY)
(+ (pow x.re 3.0) (* -3.0 (* x.im (* x.re x.im))))
(* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
tmp = pow(x_46_re, 3.0) + (-3.0 * (x_46_im * (x_46_re * x_46_im)));
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
return tmp;
}
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Double.POSITIVE_INFINITY) {
tmp = Math.pow(x_46_re, 3.0) + (-3.0 * (x_46_im * (x_46_re * 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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= math.inf: tmp = math.pow(x_46_re, 3.0) + (-3.0 * (x_46_im * (x_46_re * 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 (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf) tmp = Float64((x_46_re ^ 3.0) + Float64(-3.0 * Float64(x_46_im * Float64(x_46_re * 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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= Inf) tmp = (x_46_re ^ 3.0) + (-3.0 * (x_46_im * (x_46_re * 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[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Power[x$46$re, 3.0], $MachinePrecision] + N[(-3.0 * N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $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.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;{x.re}^{3} + -3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) < +inf.0Initial program 95.0%
*-commutative95.0%
sub-neg95.0%
distribute-lft-in92.8%
associate--l+92.8%
cube-unmult92.8%
*-commutative92.8%
distribute-lft-out92.8%
associate-*l*92.8%
distribute-lft-out--92.8%
neg-mul-192.8%
count-292.8%
associate-*l*92.8%
distribute-rgt-out--92.8%
associate-*l*92.8%
metadata-eval92.8%
Simplified92.8%
add-sqr-sqrt65.3%
pow265.3%
*-commutative65.3%
sqrt-prod48.3%
sqrt-prod20.4%
add-sqr-sqrt50.3%
Applied egg-rr50.3%
*-commutative50.3%
unpow-prod-down48.2%
pow248.2%
add-sqr-sqrt92.8%
pow292.8%
associate-*r*97.7%
Applied egg-rr97.7%
if +inf.0 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) Initial program 0.0%
*-commutative0.0%
distribute-lft-out0.0%
associate-*l*0.0%
*-commutative0.0%
distribute-rgt-out--50.0%
associate--l-50.0%
associate--l-50.0%
sub-neg50.0%
associate--l+50.0%
fma-udef69.2%
neg-mul-169.2%
count-269.2%
associate-*l*69.2%
distribute-rgt-out--69.2%
associate-*r*69.2%
metadata-eval69.2%
Simplified69.2%
Taylor expanded in x.re around inf 80.8%
unpow280.8%
Simplified80.8%
Final simplification95.9%
(FPCore (x.re x.im)
:precision binary64
(if (or (<= x.re -1.95e-26)
(and (not (<= x.re 6.2e-49))
(or (<= x.re 2.3e-18) (not (<= x.re 1.36e+103)))))
(* x.re (* x.re x.re))
(* -3.0 (* x.re (* x.im x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -1.95e-26) || (!(x_46_re <= 6.2e-49) && ((x_46_re <= 2.3e-18) || !(x_46_re <= 1.36e+103)))) {
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;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if ((x_46re <= (-1.95d-26)) .or. (.not. (x_46re <= 6.2d-49)) .and. (x_46re <= 2.3d-18) .or. (.not. (x_46re <= 1.36d+103))) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -1.95e-26) || (!(x_46_re <= 6.2e-49) && ((x_46_re <= 2.3e-18) || !(x_46_re <= 1.36e+103)))) {
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;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_re <= -1.95e-26) or (not (x_46_re <= 6.2e-49) and ((x_46_re <= 2.3e-18) or not (x_46_re <= 1.36e+103))): 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
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_re <= -1.95e-26) || (!(x_46_re <= 6.2e-49) && ((x_46_re <= 2.3e-18) || !(x_46_re <= 1.36e+103)))) 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
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_re <= -1.95e-26) || (~((x_46_re <= 6.2e-49)) && ((x_46_re <= 2.3e-18) || ~((x_46_re <= 1.36e+103))))) 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
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -1.95e-26], And[N[Not[LessEqual[x$46$re, 6.2e-49]], $MachinePrecision], Or[LessEqual[x$46$re, 2.3e-18], N[Not[LessEqual[x$46$re, 1.36e+103]], $MachinePrecision]]]], 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}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1.95 \cdot 10^{-26} \lor \neg \left(x.re \leq 6.2 \cdot 10^{-49}\right) \land \left(x.re \leq 2.3 \cdot 10^{-18} \lor \neg \left(x.re \leq 1.36 \cdot 10^{+103}\right)\right):\\
\;\;\;\;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.re < -1.94999999999999993e-26 or 6.2e-49 < x.re < 2.3000000000000001e-18 or 1.36e103 < x.re Initial program 76.9%
*-commutative76.9%
distribute-lft-out76.9%
associate-*l*76.9%
*-commutative76.9%
distribute-rgt-out--88.4%
associate--l-88.4%
associate--l-88.4%
sub-neg88.4%
associate--l+88.4%
fma-udef92.9%
neg-mul-192.9%
count-292.9%
associate-*l*92.9%
distribute-rgt-out--92.9%
associate-*r*92.9%
metadata-eval92.9%
Simplified92.9%
Taylor expanded in x.re around inf 86.7%
unpow286.7%
Simplified86.7%
if -1.94999999999999993e-26 < x.re < 6.2e-49 or 2.3000000000000001e-18 < x.re < 1.36e103Initial program 92.0%
*-commutative92.0%
distribute-lft-out92.0%
associate-*l*91.9%
*-commutative91.9%
distribute-rgt-out--91.9%
associate--l-91.9%
associate--l-91.9%
sub-neg91.9%
associate--l+91.9%
fma-udef91.9%
neg-mul-191.9%
count-291.9%
associate-*l*91.9%
distribute-rgt-out--91.9%
associate-*r*91.9%
metadata-eval91.9%
Simplified91.9%
fma-udef91.9%
Applied egg-rr91.9%
Taylor expanded in x.re around 0 80.6%
unpow280.6%
Simplified80.6%
Final simplification83.3%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -6.6e+150) (not (<= x.im 7.6e+153))) (* x.im (* (* x.re x.im) -3.0)) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0))))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -6.6e+150) || !(x_46_im <= 7.6e+153)) {
tmp = x_46_im * ((x_46_re * x_46_im) * -3.0);
} else {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
}
return tmp;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if ((x_46im <= (-6.6d+150)) .or. (.not. (x_46im <= 7.6d+153))) then
tmp = x_46im * ((x_46re * x_46im) * (-3.0d0))
else
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -6.6e+150) || !(x_46_im <= 7.6e+153)) {
tmp = x_46_im * ((x_46_re * x_46_im) * -3.0);
} else {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -6.6e+150) or not (x_46_im <= 7.6e+153): tmp = x_46_im * ((x_46_re * x_46_im) * -3.0) else: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -6.6e+150) || !(x_46_im <= 7.6e+153)) tmp = Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * -3.0)); else tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * Float64(x_46_im * -3.0)))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_im <= -6.6e+150) || ~((x_46_im <= 7.6e+153))) tmp = x_46_im * ((x_46_re * x_46_im) * -3.0); else tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -6.6e+150], N[Not[LessEqual[x$46$im, 7.6e+153]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -6.6 \cdot 10^{+150} \lor \neg \left(x.im \leq 7.6 \cdot 10^{+153}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\
\end{array}
\end{array}
if x.im < -6.59999999999999962e150 or 7.59999999999999933e153 < x.im Initial program 56.1%
*-commutative56.1%
sub-neg56.1%
distribute-lft-in47.0%
associate--l+47.0%
cube-unmult47.0%
*-commutative47.0%
distribute-lft-out47.0%
associate-*l*47.0%
distribute-lft-out--46.9%
neg-mul-146.9%
count-246.9%
associate-*l*46.9%
distribute-rgt-out--46.9%
associate-*l*47.0%
metadata-eval47.0%
Simplified47.0%
add-sqr-sqrt31.5%
pow231.5%
*-commutative31.5%
sqrt-prod31.5%
sqrt-prod12.7%
add-sqr-sqrt39.9%
Applied egg-rr39.9%
*-commutative39.9%
unpow-prod-down31.5%
pow231.5%
add-sqr-sqrt47.0%
pow247.0%
associate-*r*67.1%
Applied egg-rr67.1%
Taylor expanded in x.re around 0 65.2%
*-commutative65.2%
unpow265.2%
associate-*r*85.3%
associate-*r*85.4%
*-commutative85.4%
associate-*l*85.3%
Simplified85.3%
if -6.59999999999999962e150 < x.im < 7.59999999999999933e153Initial program 93.3%
*-commutative93.3%
distribute-lft-out93.3%
associate-*l*93.3%
*-commutative93.3%
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%
Final simplification96.7%
(FPCore (x.re x.im)
:precision binary64
(if (<= x.im -6.6e+150)
(* x.im (* (* x.re x.im) -3.0))
(if (<= x.im 7.6e+153)
(* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0))))
(* x.im (* x.re (* x.im -3.0))))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= -6.6e+150) {
tmp = x_46_im * ((x_46_re * x_46_im) * -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_re * (x_46_im * -3.0));
}
return tmp;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if (x_46im <= (-6.6d+150)) then
tmp = x_46im * ((x_46re * x_46im) * (-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_46re * (x_46im * (-3.0d0)))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= -6.6e+150) {
tmp = x_46_im * ((x_46_re * x_46_im) * -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_re * (x_46_im * -3.0));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= -6.6e+150: tmp = x_46_im * ((x_46_re * x_46_im) * -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_re * (x_46_im * -3.0)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= -6.6e+150) tmp = Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * -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(x_46_re * Float64(x_46_im * -3.0))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= -6.6e+150) tmp = x_46_im * ((x_46_re * x_46_im) * -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_re * (x_46_im * -3.0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -6.6e+150], N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $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[(x$46$re * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -6.6 \cdot 10^{+150}:\\
\;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\
\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(x.re \cdot \left(x.im \cdot -3\right)\right)\\
\end{array}
\end{array}
if x.im < -6.59999999999999962e150Initial program 62.3%
*-commutative62.3%
sub-neg62.3%
distribute-lft-in55.9%
associate--l+55.9%
cube-unmult55.9%
*-commutative55.9%
distribute-lft-out55.9%
associate-*l*55.9%
distribute-lft-out--55.8%
neg-mul-155.8%
count-255.8%
associate-*l*55.8%
distribute-rgt-out--55.8%
associate-*l*55.9%
metadata-eval55.9%
Simplified55.9%
add-sqr-sqrt36.3%
pow236.3%
*-commutative36.3%
sqrt-prod36.3%
sqrt-prod0.0%
add-sqr-sqrt48.3%
Applied egg-rr48.3%
*-commutative48.3%
unpow-prod-down36.3%
pow236.3%
add-sqr-sqrt55.9%
pow255.9%
associate-*r*70.9%
Applied egg-rr70.9%
Taylor expanded in x.re around 0 75.2%
*-commutative75.2%
unpow275.2%
associate-*r*90.2%
associate-*r*90.2%
*-commutative90.2%
associate-*l*90.2%
Simplified90.2%
if -6.59999999999999962e150 < x.im < 7.59999999999999933e153Initial program 93.3%
*-commutative93.3%
distribute-lft-out93.3%
associate-*l*93.3%
*-commutative93.3%
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 48.0%
*-commutative48.0%
distribute-lft-out48.0%
associate-*l*48.0%
*-commutative48.0%
distribute-rgt-out--48.0%
associate--l-48.0%
associate--l-48.0%
sub-neg48.0%
associate--l+48.0%
fma-udef52.1%
neg-mul-152.1%
count-252.1%
associate-*l*52.1%
distribute-rgt-out--52.1%
associate-*r*52.1%
metadata-eval52.1%
Simplified52.1%
Taylor expanded in x.re around 0 52.1%
associate-*r*52.1%
unpow252.1%
Simplified52.1%
pow152.1%
*-commutative52.1%
associate-*l*79.2%
*-commutative79.2%
*-commutative79.2%
associate-*l*79.1%
*-commutative79.1%
Applied egg-rr79.1%
Final simplification96.7%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -4.8e+26) (not (<= x.im 0.052))) (* x.im (* (* x.re x.im) -3.0)) (* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -4.8e+26) || !(x_46_im <= 0.052)) {
tmp = x_46_im * ((x_46_re * x_46_im) * -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 <= (-4.8d+26)) .or. (.not. (x_46im <= 0.052d0))) then
tmp = x_46im * ((x_46re * x_46im) * (-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 <= -4.8e+26) || !(x_46_im <= 0.052)) {
tmp = x_46_im * ((x_46_re * x_46_im) * -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 <= -4.8e+26) or not (x_46_im <= 0.052): tmp = x_46_im * ((x_46_re * x_46_im) * -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 <= -4.8e+26) || !(x_46_im <= 0.052)) tmp = Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * -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 <= -4.8e+26) || ~((x_46_im <= 0.052))) tmp = x_46_im * ((x_46_re * x_46_im) * -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, -4.8e+26], N[Not[LessEqual[x$46$im, 0.052]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$re * x$46$im), $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.8 \cdot 10^{+26} \lor \neg \left(x.im \leq 0.052\right):\\
\;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\end{array}
\end{array}
if x.im < -4.80000000000000009e26 or 0.0519999999999999976 < x.im Initial program 67.5%
*-commutative67.5%
sub-neg67.5%
distribute-lft-in63.1%
associate--l+63.1%
cube-unmult63.1%
*-commutative63.1%
distribute-lft-out63.1%
associate-*l*63.0%
distribute-lft-out--63.0%
neg-mul-163.0%
count-263.0%
associate-*l*63.0%
distribute-rgt-out--63.0%
associate-*l*63.0%
metadata-eval63.0%
Simplified63.0%
add-sqr-sqrt33.2%
pow233.2%
*-commutative33.2%
sqrt-prod33.1%
sqrt-prod12.4%
add-sqr-sqrt37.3%
Applied egg-rr37.3%
*-commutative37.3%
unpow-prod-down33.1%
pow233.1%
add-sqr-sqrt63.0%
pow263.0%
associate-*r*72.9%
Applied egg-rr72.9%
Taylor expanded in x.re around 0 68.3%
*-commutative68.3%
unpow268.3%
associate-*r*78.3%
associate-*r*78.3%
*-commutative78.3%
associate-*l*78.3%
Simplified78.3%
if -4.80000000000000009e26 < x.im < 0.0519999999999999976Initial program 99.2%
*-commutative99.2%
distribute-lft-out99.2%
associate-*l*99.2%
*-commutative99.2%
distribute-rgt-out--99.9%
associate--l-99.9%
associate--l-99.9%
sub-neg99.9%
associate--l+99.9%
fma-udef99.9%
neg-mul-199.9%
count-299.9%
associate-*l*99.9%
distribute-rgt-out--99.9%
associate-*r*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x.re around inf 90.7%
unpow290.7%
Simplified90.7%
Final simplification85.3%
(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 85.3%
*-commutative85.3%
distribute-lft-out85.3%
associate-*l*85.3%
*-commutative85.3%
distribute-rgt-out--90.4%
associate--l-90.4%
associate--l-90.4%
sub-neg90.4%
associate--l+90.4%
fma-udef92.3%
neg-mul-192.3%
count-292.3%
associate-*l*92.3%
distribute-rgt-out--92.3%
associate-*r*92.3%
metadata-eval92.3%
Simplified92.3%
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 2023193
(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)))