
(FPCore (x.re x.im) :precision binary64 (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im): return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
function code(x_46_re, x_46_im) return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im)) end
function tmp = code(x_46_re, x_46_im) tmp = (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im); end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im) :precision binary64 (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im): return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
function code(x_46_re, x_46_im) return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im)) end
function tmp = code(x_46_re, x_46_im) tmp = (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im); end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\end{array}
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -6.8e+141) (not (<= x.im 2.7e+135))) (* (* x.re x.im) (* 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.8e+141) || !(x_46_im <= 2.7e+135)) {
tmp = (x_46_re * x_46_im) * (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.8d+141)) .or. (.not. (x_46im <= 2.7d+135))) then
tmp = (x_46re * x_46im) * (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.8e+141) || !(x_46_im <= 2.7e+135)) {
tmp = (x_46_re * x_46_im) * (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.8e+141) or not (x_46_im <= 2.7e+135): tmp = (x_46_re * x_46_im) * (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.8e+141) || !(x_46_im <= 2.7e+135)) tmp = Float64(Float64(x_46_re * x_46_im) * Float64(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.8e+141) || ~((x_46_im <= 2.7e+135))) tmp = (x_46_re * x_46_im) * (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.8e+141], N[Not[LessEqual[x$46$im, 2.7e+135]], $MachinePrecision]], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -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.8 \cdot 10^{+141} \lor \neg \left(x.im \leq 2.7 \cdot 10^{+135}\right):\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \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.7999999999999996e141 or 2.69999999999999985e135 < x.im Initial program 50.1%
*-commutative50.1%
distribute-lft-out50.1%
associate-*l*50.1%
*-commutative50.1%
distribute-rgt-out--50.1%
associate--l-50.1%
associate--l-50.1%
sub-neg50.1%
associate--l+50.1%
fma-udef62.0%
neg-mul-162.0%
count-262.0%
associate-*l*62.0%
distribute-rgt-out--62.0%
associate-*r*62.0%
metadata-eval62.0%
Simplified62.0%
fma-udef50.0%
Applied egg-rr50.0%
Taylor expanded in x.re around 0 62.0%
*-commutative62.0%
unpow262.0%
associate-*r*90.9%
associate-*r*90.9%
*-commutative90.9%
*-commutative90.9%
Simplified90.9%
if -6.7999999999999996e141 < x.im < 2.69999999999999985e135Initial program 90.8%
*-commutative90.8%
distribute-lft-out90.8%
associate-*l*90.7%
*-commutative90.7%
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.7%
metadata-eval99.7%
Simplified99.7%
fma-udef99.7%
Applied egg-rr99.7%
Final simplification97.4%
(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)
(- (* (+ x.re x.im) (* x.re (- x.re x.im))) (* x.im (* x.re (+ x.im x.im))))
(* x.re (fma 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_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 = ((x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))) - (x_46_im * (x_46_re * (x_46_im + x_46_im)));
} else {
tmp = x_46_re * fma(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 (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(Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re * Float64(x_46_re - x_46_im))) - Float64(x_46_im * Float64(x_46_re * Float64(x_46_im + x_46_im)))); else tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(x_46_im * Float64(x_46_im * -3.0)))); 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[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]
\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:\\
\;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\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 91.1%
*-commutative91.1%
*-commutative91.1%
*-commutative91.1%
distribute-lft-out91.1%
Simplified91.1%
add-log-exp51.0%
exp-prod52.0%
Applied egg-rr52.0%
log-pow47.1%
difference-of-squares47.1%
add-log-exp91.1%
associate-*l*99.7%
Applied egg-rr99.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--54.8%
associate--l-54.8%
associate--l-54.8%
sub-neg54.8%
associate--l+54.8%
fma-udef80.6%
neg-mul-180.6%
count-280.6%
associate-*l*80.6%
distribute-rgt-out--80.6%
associate-*r*80.6%
metadata-eval80.6%
Simplified80.6%
Final simplification97.4%
(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)
(- (* (+ x.re x.im) (* x.re (- x.re x.im))) (* x.im (* 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_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 = ((x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))) - (x_46_im * (x_46_re * (x_46_im + 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 = ((x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))) - (x_46_im * (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_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 = ((x_46_re + x_46_im) * (x_46_re * (x_46_re - x_46_im))) - (x_46_im * (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 (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(Float64(Float64(x_46_re + x_46_im) * Float64(x_46_re * Float64(x_46_re - x_46_im))) - Float64(x_46_im * 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_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 + x_46_im) * (x_46_re * (x_46_re - x_46_im))) - (x_46_im * (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[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[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$re * N[(x$46$im + 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:\\
\;\;\;\;\left(x.re + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - x.im \cdot \left(x.re \cdot \left(x.im + 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 91.1%
*-commutative91.1%
*-commutative91.1%
*-commutative91.1%
distribute-lft-out91.1%
Simplified91.1%
add-log-exp51.0%
exp-prod52.0%
Applied egg-rr52.0%
log-pow47.1%
difference-of-squares47.1%
add-log-exp91.1%
associate-*l*99.7%
Applied egg-rr99.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--54.8%
associate--l-54.8%
associate--l-54.8%
sub-neg54.8%
associate--l+54.8%
fma-udef80.6%
neg-mul-180.6%
count-280.6%
associate-*l*80.6%
distribute-rgt-out--80.6%
associate-*r*80.6%
metadata-eval80.6%
Simplified80.6%
Taylor expanded in x.re around inf 74.2%
unpow274.2%
Simplified74.2%
Final simplification96.6%
(FPCore (x.re x.im)
:precision binary64
(if (or (<= x.re -6.6)
(and (not (<= x.re 1.02e+26))
(or (<= x.re 2.2e+78) (not (<= x.re 4.9e+113)))))
(* x.re (* 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_re <= -6.6) || (!(x_46_re <= 1.02e+26) && ((x_46_re <= 2.2e+78) || !(x_46_re <= 4.9e+113)))) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = 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_46re <= (-6.6d0)) .or. (.not. (x_46re <= 1.02d+26)) .and. (x_46re <= 2.2d+78) .or. (.not. (x_46re <= 4.9d+113))) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = 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_re <= -6.6) || (!(x_46_re <= 1.02e+26) && ((x_46_re <= 2.2e+78) || !(x_46_re <= 4.9e+113)))) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = 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_re <= -6.6) or (not (x_46_re <= 1.02e+26) and ((x_46_re <= 2.2e+78) or not (x_46_re <= 4.9e+113))): tmp = x_46_re * (x_46_re * x_46_re) else: tmp = 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_re <= -6.6) || (!(x_46_re <= 1.02e+26) && ((x_46_re <= 2.2e+78) || !(x_46_re <= 4.9e+113)))) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(x_46_re * Float64(Float64(x_46_im * 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_re <= -6.6) || (~((x_46_re <= 1.02e+26)) && ((x_46_re <= 2.2e+78) || ~((x_46_re <= 4.9e+113))))) tmp = x_46_re * (x_46_re * x_46_re); else tmp = 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$re, -6.6], And[N[Not[LessEqual[x$46$re, 1.02e+26]], $MachinePrecision], Or[LessEqual[x$46$re, 2.2e+78], N[Not[LessEqual[x$46$re, 4.9e+113]], $MachinePrecision]]]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(N[(x$46$im * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -6.6 \lor \neg \left(x.re \leq 1.02 \cdot 10^{+26}\right) \land \left(x.re \leq 2.2 \cdot 10^{+78} \lor \neg \left(x.re \leq 4.9 \cdot 10^{+113}\right)\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)\\
\end{array}
\end{array}
if x.re < -6.5999999999999996 or 1.0200000000000001e26 < x.re < 2.20000000000000014e78 or 4.90000000000000021e113 < x.re Initial program 73.6%
*-commutative73.6%
distribute-lft-out73.6%
associate-*l*73.6%
*-commutative73.6%
distribute-rgt-out--88.0%
associate--l-88.0%
associate--l-88.0%
sub-neg88.0%
associate--l+88.0%
fma-udef94.8%
neg-mul-194.8%
count-294.8%
associate-*l*94.8%
distribute-rgt-out--94.8%
associate-*r*94.8%
metadata-eval94.8%
Simplified94.8%
Taylor expanded in x.re around inf 83.0%
unpow283.0%
Simplified83.0%
if -6.5999999999999996 < x.re < 1.0200000000000001e26 or 2.20000000000000014e78 < x.re < 4.90000000000000021e113Initial program 85.6%
*-commutative85.6%
distribute-lft-out85.6%
associate-*l*85.6%
*-commutative85.6%
distribute-rgt-out--85.6%
associate--l-85.6%
associate--l-85.6%
sub-neg85.6%
associate--l+85.6%
fma-udef85.6%
neg-mul-185.6%
count-285.6%
associate-*l*85.6%
distribute-rgt-out--85.6%
associate-*r*85.6%
metadata-eval85.6%
Simplified85.6%
Taylor expanded in x.re around 0 72.9%
associate-*r*73.0%
*-commutative73.0%
metadata-eval73.0%
distribute-rgt-out--73.0%
*-commutative73.0%
cancel-sign-sub-inv73.0%
metadata-eval73.0%
+-commutative73.0%
distribute-rgt-in72.9%
*-commutative72.9%
metadata-eval72.9%
distribute-lft-neg-in72.9%
count-272.9%
distribute-rgt-neg-in72.9%
distribute-rgt-out72.9%
distribute-lft-out72.9%
distribute-rgt-neg-in72.9%
count-272.9%
distribute-lft-neg-in72.9%
metadata-eval72.9%
mul-1-neg72.9%
distribute-lft-neg-in72.9%
Simplified73.0%
Final simplification77.6%
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.re (* x.re x.re))))
(if (<= x.re -15.2)
t_0
(if (<= x.re 8e+24)
(* (* x.re x.im) (* x.im -3.0))
(if (or (<= x.re 2.2e+78) (not (<= x.re 1.95e+108)))
t_0
(* x.re (* (* x.im x.im) -3.0)))))))
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_re <= -15.2) {
tmp = t_0;
} else if (x_46_re <= 8e+24) {
tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
} else if ((x_46_re <= 2.2e+78) || !(x_46_re <= 1.95e+108)) {
tmp = t_0;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = x_46re * (x_46re * x_46re)
if (x_46re <= (-15.2d0)) then
tmp = t_0
else if (x_46re <= 8d+24) then
tmp = (x_46re * x_46im) * (x_46im * (-3.0d0))
else if ((x_46re <= 2.2d+78) .or. (.not. (x_46re <= 1.95d+108))) then
tmp = t_0
else
tmp = 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 t_0 = x_46_re * (x_46_re * x_46_re);
double tmp;
if (x_46_re <= -15.2) {
tmp = t_0;
} else if (x_46_re <= 8e+24) {
tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
} else if ((x_46_re <= 2.2e+78) || !(x_46_re <= 1.95e+108)) {
tmp = t_0;
} else {
tmp = x_46_re * ((x_46_im * x_46_im) * -3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): t_0 = x_46_re * (x_46_re * x_46_re) tmp = 0 if x_46_re <= -15.2: tmp = t_0 elif x_46_re <= 8e+24: tmp = (x_46_re * x_46_im) * (x_46_im * -3.0) elif (x_46_re <= 2.2e+78) or not (x_46_re <= 1.95e+108): tmp = t_0 else: tmp = x_46_re * ((x_46_im * x_46_im) * -3.0) return tmp
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_re <= -15.2) tmp = t_0; elseif (x_46_re <= 8e+24) tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0)); elseif ((x_46_re <= 2.2e+78) || !(x_46_re <= 1.95e+108)) tmp = t_0; else tmp = Float64(x_46_re * Float64(Float64(x_46_im * x_46_im) * -3.0)); end return tmp end
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_re <= -15.2) tmp = t_0; elseif (x_46_re <= 8e+24) tmp = (x_46_re * x_46_im) * (x_46_im * -3.0); elseif ((x_46_re <= 2.2e+78) || ~((x_46_re <= 1.95e+108))) tmp = t_0; else tmp = x_46_re * ((x_46_im * x_46_im) * -3.0); end tmp_2 = tmp; end
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$re, -15.2], t$95$0, If[LessEqual[x$46$re, 8e+24], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x$46$re, 2.2e+78], N[Not[LessEqual[x$46$re, 1.95e+108]], $MachinePrecision]], t$95$0, N[(x$46$re * N[(N[(x$46$im * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{if}\;x.re \leq -15.2:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.re \leq 8 \cdot 10^{+24}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\
\mathbf{elif}\;x.re \leq 2.2 \cdot 10^{+78} \lor \neg \left(x.re \leq 1.95 \cdot 10^{+108}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(\left(x.im \cdot x.im\right) \cdot -3\right)\\
\end{array}
\end{array}
if x.re < -15.199999999999999 or 7.9999999999999999e24 < x.re < 2.20000000000000014e78 or 1.94999999999999992e108 < x.re Initial program 73.6%
*-commutative73.6%
distribute-lft-out73.6%
associate-*l*73.6%
*-commutative73.6%
distribute-rgt-out--88.0%
associate--l-88.0%
associate--l-88.0%
sub-neg88.0%
associate--l+88.0%
fma-udef94.8%
neg-mul-194.8%
count-294.8%
associate-*l*94.8%
distribute-rgt-out--94.8%
associate-*r*94.8%
metadata-eval94.8%
Simplified94.8%
Taylor expanded in x.re around inf 83.0%
unpow283.0%
Simplified83.0%
if -15.199999999999999 < x.re < 7.9999999999999999e24Initial program 84.6%
*-commutative84.6%
distribute-lft-out84.6%
associate-*l*84.6%
*-commutative84.6%
distribute-rgt-out--84.6%
associate--l-84.6%
associate--l-84.6%
sub-neg84.6%
associate--l+84.6%
fma-udef84.6%
neg-mul-184.6%
count-284.6%
associate-*l*84.6%
distribute-rgt-out--84.6%
associate-*r*84.6%
metadata-eval84.6%
Simplified84.6%
fma-udef84.6%
Applied egg-rr84.6%
Taylor expanded in x.re around 0 72.6%
*-commutative72.6%
unpow272.6%
associate-*r*87.6%
associate-*r*87.6%
*-commutative87.6%
*-commutative87.6%
Simplified87.6%
if 2.20000000000000014e78 < x.re < 1.94999999999999992e108Initial program 100.0%
*-commutative100.0%
distribute-lft-out100.0%
associate-*l*100.0%
*-commutative100.0%
distribute-rgt-out--100.0%
associate--l-100.0%
associate--l-100.0%
sub-neg100.0%
associate--l+100.0%
fma-udef100.0%
neg-mul-1100.0%
count-2100.0%
associate-*l*100.0%
distribute-rgt-out--100.0%
associate-*r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x.re around 0 77.9%
associate-*r*77.9%
*-commutative77.9%
metadata-eval77.9%
distribute-rgt-out--77.9%
*-commutative77.9%
cancel-sign-sub-inv77.9%
metadata-eval77.9%
+-commutative77.9%
distribute-rgt-in77.9%
*-commutative77.9%
metadata-eval77.9%
distribute-lft-neg-in77.9%
count-277.9%
distribute-rgt-neg-in77.9%
distribute-rgt-out77.9%
distribute-lft-out77.9%
distribute-rgt-neg-in77.9%
count-277.9%
distribute-lft-neg-in77.9%
metadata-eval77.9%
mul-1-neg77.9%
distribute-lft-neg-in77.9%
Simplified77.9%
Final simplification85.1%
(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 80.1%
*-commutative80.1%
distribute-lft-out80.1%
associate-*l*80.1%
*-commutative80.1%
distribute-rgt-out--86.7%
associate--l-86.7%
associate--l-86.7%
sub-neg86.7%
associate--l+86.7%
fma-udef89.9%
neg-mul-189.9%
count-289.9%
associate-*l*89.9%
distribute-rgt-out--89.9%
associate-*r*89.9%
metadata-eval89.9%
Simplified89.9%
Taylor expanded in x.re around inf 55.3%
unpow255.3%
Simplified55.3%
Final simplification55.3%
(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 2023195
(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)))