
(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
(let* ((t_0 (* x.re (* x.re x.re))))
(if (<= x.re -1e+263)
t_0
(if (<= x.re -2.5e-25)
(* x.re (fma x.re x.re (* x.im (* x.im -3.0))))
(if (<= x.re 2.55e+219)
(fma
(* x.re (+ x.re x.im))
(- x.re x.im)
(* x.im (* x.re (- (- x.im) x.im))))
t_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 <= -1e+263) {
tmp = t_0;
} else if (x_46_re <= -2.5e-25) {
tmp = x_46_re * fma(x_46_re, x_46_re, (x_46_im * (x_46_im * -3.0)));
} else if (x_46_re <= 2.55e+219) {
tmp = fma((x_46_re * (x_46_re + x_46_im)), (x_46_re - x_46_im), (x_46_im * (x_46_re * (-x_46_im - x_46_im))));
} else {
tmp = t_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 <= -1e+263) tmp = t_0; elseif (x_46_re <= -2.5e-25) tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(x_46_im * Float64(x_46_im * -3.0)))); elseif (x_46_re <= 2.55e+219) tmp = fma(Float64(x_46_re * Float64(x_46_re + x_46_im)), Float64(x_46_re - x_46_im), Float64(x_46_im * Float64(x_46_re * Float64(Float64(-x_46_im) - x_46_im)))); else tmp = t_0; 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), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -1e+263], t$95$0, If[LessEqual[x$46$re, -2.5e-25], 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, 2.55e+219], N[(N[(x$46$re * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision] + N[(x$46$im * N[(x$46$re * N[((-x$46$im) - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{if}\;x.re \leq -1 \cdot 10^{+263}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.re \leq -2.5 \cdot 10^{-25}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{elif}\;x.re \leq 2.55 \cdot 10^{+219}:\\
\;\;\;\;\mathsf{fma}\left(x.re \cdot \left(x.re + x.im\right), x.re - x.im, x.im \cdot \left(x.re \cdot \left(\left(-x.im\right) - x.im\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x.re < -1.00000000000000002e263 or 2.54999999999999997e219 < x.re Initial program 56.7%
*-commutative56.7%
distribute-lft-out56.7%
associate-*l*56.7%
*-commutative56.7%
distribute-rgt-out--60.0%
associate--l-60.0%
associate--l-60.0%
sub-neg60.0%
associate--l+60.0%
fma-udef60.0%
neg-mul-160.0%
count-260.0%
associate-*l*60.0%
distribute-rgt-out--60.0%
associate-*r*60.0%
metadata-eval60.0%
Simplified60.0%
Taylor expanded in x.re around inf 100.0%
unpow2100.0%
Simplified100.0%
if -1.00000000000000002e263 < x.re < -2.49999999999999981e-25Initial program 73.7%
*-commutative73.7%
distribute-lft-out73.7%
associate-*l*73.7%
*-commutative73.7%
distribute-rgt-out--81.0%
associate--l-81.0%
associate--l-81.0%
sub-neg81.0%
associate--l+81.0%
fma-udef96.9%
neg-mul-196.9%
count-296.9%
associate-*l*96.9%
distribute-rgt-out--96.9%
associate-*r*96.9%
metadata-eval96.9%
Simplified96.9%
if -2.49999999999999981e-25 < x.re < 2.54999999999999997e219Initial program 91.3%
*-commutative91.3%
*-commutative91.3%
*-commutative91.3%
distribute-lft-out91.3%
Simplified91.3%
difference-of-squares93.2%
Applied egg-rr93.2%
associate-*r*99.1%
fma-neg99.1%
distribute-rgt-neg-in99.1%
distribute-rgt-neg-in99.1%
Applied egg-rr99.1%
Final simplification98.7%
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.re (* x.re x.re))))
(if (<= x.re -1e+262)
t_0
(if (<= x.re -5e-81)
(* x.re (fma x.re x.re (* x.im (* x.im -3.0))))
(if (<= x.re 1.3e+218)
(-
(* (* x.re (+ x.re x.im)) (- x.re x.im))
(* x.im (* x.re (+ x.im x.im))))
t_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 <= -1e+262) {
tmp = t_0;
} else if (x_46_re <= -5e-81) {
tmp = x_46_re * fma(x_46_re, x_46_re, (x_46_im * (x_46_im * -3.0)));
} else if (x_46_re <= 1.3e+218) {
tmp = ((x_46_re * (x_46_re + x_46_im)) * (x_46_re - x_46_im)) - (x_46_im * (x_46_re * (x_46_im + x_46_im)));
} else {
tmp = t_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 <= -1e+262) tmp = t_0; elseif (x_46_re <= -5e-81) tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(x_46_im * Float64(x_46_im * -3.0)))); elseif (x_46_re <= 1.3e+218) tmp = Float64(Float64(Float64(x_46_re * Float64(x_46_re + x_46_im)) * Float64(x_46_re - x_46_im)) - Float64(x_46_im * Float64(x_46_re * Float64(x_46_im + x_46_im)))); else tmp = t_0; 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), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -1e+262], t$95$0, If[LessEqual[x$46$re, -5e-81], 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, 1.3e+218], N[(N[(N[(x$46$re * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{if}\;x.re \leq -1 \cdot 10^{+262}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.re \leq -5 \cdot 10^{-81}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{elif}\;x.re \leq 1.3 \cdot 10^{+218}:\\
\;\;\;\;\left(x.re \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x.re < -1e262 or 1.30000000000000001e218 < x.re Initial program 56.7%
*-commutative56.7%
distribute-lft-out56.7%
associate-*l*56.7%
*-commutative56.7%
distribute-rgt-out--60.0%
associate--l-60.0%
associate--l-60.0%
sub-neg60.0%
associate--l+60.0%
fma-udef60.0%
neg-mul-160.0%
count-260.0%
associate-*l*60.0%
distribute-rgt-out--60.0%
associate-*r*60.0%
metadata-eval60.0%
Simplified60.0%
Taylor expanded in x.re around inf 100.0%
unpow2100.0%
Simplified100.0%
if -1e262 < x.re < -4.99999999999999981e-81Initial program 76.7%
*-commutative76.7%
distribute-lft-out76.7%
associate-*l*76.7%
*-commutative76.7%
distribute-rgt-out--83.1%
associate--l-83.1%
associate--l-83.1%
sub-neg83.1%
associate--l+83.1%
fma-udef97.2%
neg-mul-197.2%
count-297.2%
associate-*l*97.2%
distribute-rgt-out--97.2%
associate-*r*97.2%
metadata-eval97.2%
Simplified97.2%
if -4.99999999999999981e-81 < x.re < 1.30000000000000001e218Initial program 90.9%
*-commutative90.9%
*-commutative90.9%
*-commutative90.9%
distribute-lft-out90.9%
Simplified90.9%
difference-of-squares92.9%
Applied egg-rr92.9%
associate-*r*99.1%
fma-neg99.1%
distribute-rgt-neg-in99.1%
distribute-rgt-neg-in99.1%
Applied egg-rr99.1%
fma-udef99.1%
Applied egg-rr99.1%
Final simplification98.6%
(FPCore (x.re x.im)
:precision binary64
(if (or (<= x.re -5.8e+228) (not (<= x.re 9e+222)))
(* x.re (* x.re x.re))
(-
(* (* x.re (+ x.re x.im)) (- x.re x.im))
(* x.im (* x.re (+ x.im x.im))))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -5.8e+228) || !(x_46_re <= 9e+222)) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = ((x_46_re * (x_46_re + x_46_im)) * (x_46_re - x_46_im)) - (x_46_im * (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 <= (-5.8d+228)) .or. (.not. (x_46re <= 9d+222))) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = ((x_46re * (x_46re + x_46im)) * (x_46re - x_46im)) - (x_46im * (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 <= -5.8e+228) || !(x_46_re <= 9e+222)) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = ((x_46_re * (x_46_re + x_46_im)) * (x_46_re - x_46_im)) - (x_46_im * (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 <= -5.8e+228) or not (x_46_re <= 9e+222): tmp = x_46_re * (x_46_re * x_46_re) else: tmp = ((x_46_re * (x_46_re + x_46_im)) * (x_46_re - x_46_im)) - (x_46_im * (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 <= -5.8e+228) || !(x_46_re <= 9e+222)) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(Float64(Float64(x_46_re * Float64(x_46_re + x_46_im)) * Float64(x_46_re - x_46_im)) - Float64(x_46_im * 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 <= -5.8e+228) || ~((x_46_re <= 9e+222))) tmp = x_46_re * (x_46_re * x_46_re); else tmp = ((x_46_re * (x_46_re + x_46_im)) * (x_46_re - x_46_im)) - (x_46_im * (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, -5.8e+228], N[Not[LessEqual[x$46$re, 9e+222]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$re * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -5.8 \cdot 10^{+228} \lor \neg \left(x.re \leq 9 \cdot 10^{+222}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\\
\end{array}
\end{array}
if x.re < -5.80000000000000003e228 or 8.99999999999999978e222 < x.re Initial program 54.1%
*-commutative54.1%
distribute-lft-out54.1%
associate-*l*54.1%
*-commutative54.1%
distribute-rgt-out--59.5%
associate--l-59.5%
associate--l-59.5%
sub-neg59.5%
associate--l+59.5%
fma-udef64.9%
neg-mul-164.9%
count-264.9%
associate-*l*64.9%
distribute-rgt-out--64.9%
associate-*r*64.9%
metadata-eval64.9%
Simplified64.9%
Taylor expanded in x.re around inf 94.6%
unpow294.6%
Simplified94.6%
if -5.80000000000000003e228 < x.re < 8.99999999999999978e222Initial program 87.3%
*-commutative87.3%
*-commutative87.3%
*-commutative87.3%
distribute-lft-out87.3%
Simplified87.3%
difference-of-squares92.8%
Applied egg-rr92.8%
associate-*r*97.0%
fma-neg97.0%
distribute-rgt-neg-in97.0%
distribute-rgt-neg-in97.0%
Applied egg-rr97.0%
fma-udef97.0%
Applied egg-rr97.0%
Final simplification96.6%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 1.15e+139) (* 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 <= 1.15e+139) {
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 <= 1.15d+139) 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 <= 1.15e+139) {
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 <= 1.15e+139: 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 <= 1.15e+139) 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 <= 1.15e+139) 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, 1.15e+139], 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 1.15 \cdot 10^{+139}:\\
\;\;\;\;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 < 1.15e139Initial program 90.9%
*-commutative90.9%
distribute-lft-out90.9%
associate-*l*90.9%
*-commutative90.9%
distribute-rgt-out--93.7%
associate--l-93.7%
associate--l-93.7%
sub-neg93.7%
associate--l+93.7%
fma-udef96.5%
neg-mul-196.5%
count-296.5%
associate-*l*96.5%
distribute-rgt-out--96.5%
associate-*r*96.5%
metadata-eval96.5%
Simplified96.5%
fma-udef93.7%
Applied egg-rr93.7%
if 1.15e139 < x.im Initial program 41.0%
*-commutative41.0%
distribute-lft-out41.0%
associate-*l*41.0%
*-commutative41.0%
distribute-rgt-out--40.9%
associate--l-40.9%
associate--l-40.9%
sub-neg40.9%
associate--l+40.9%
fma-udef59.5%
neg-mul-159.5%
count-259.5%
associate-*l*59.5%
distribute-rgt-out--59.5%
associate-*r*59.5%
metadata-eval59.5%
Simplified59.5%
Taylor expanded in x.re around 0 59.6%
associate-*r*59.5%
*-commutative59.5%
*-commutative59.5%
metadata-eval59.5%
distribute-rgt-out59.5%
distribute-lft-in59.6%
mul-1-neg59.6%
distribute-rgt-neg-in59.6%
distribute-lft-neg-in59.6%
unpow259.6%
distribute-rgt-neg-out59.6%
*-commutative59.6%
metadata-eval59.6%
distribute-lft-neg-in59.6%
count-259.6%
distribute-rgt-neg-in59.6%
distribute-rgt-out59.6%
distribute-lft-out59.6%
distribute-rgt-neg-in59.6%
count-259.6%
distribute-lft-neg-in59.6%
metadata-eval59.6%
Simplified76.5%
Final simplification90.8%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 0.00044) (* x.re (* x.re x.re)) (* x.im (* -3.0 (* x.re x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 0.00044) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_im * (-3.0 * (x_46_re * 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_46im <= 0.00044d0) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = x_46im * ((-3.0d0) * (x_46re * 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_im <= 0.00044) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_im * (-3.0 * (x_46_re * x_46_im));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 0.00044: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = x_46_im * (-3.0 * (x_46_re * x_46_im)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 0.00044) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_re * x_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 0.00044) tmp = x_46_re * (x_46_re * x_46_re); else tmp = x_46_im * (-3.0 * (x_46_re * x_46_im)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 0.00044], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(-3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 0.00044:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(-3 \cdot \left(x.re \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.im < 4.40000000000000016e-4Initial program 91.2%
*-commutative91.2%
distribute-lft-out91.2%
associate-*l*91.2%
*-commutative91.2%
distribute-rgt-out--93.2%
associate--l-93.2%
associate--l-93.2%
sub-neg93.2%
associate--l+93.2%
fma-udef96.3%
neg-mul-196.3%
count-296.3%
associate-*l*96.3%
distribute-rgt-out--96.3%
associate-*r*96.3%
metadata-eval96.3%
Simplified96.3%
Taylor expanded in x.re around inf 74.3%
unpow274.3%
Simplified74.3%
if 4.40000000000000016e-4 < x.im Initial program 53.6%
*-commutative53.6%
distribute-lft-out53.6%
associate-*l*53.5%
*-commutative53.5%
distribute-rgt-out--56.8%
associate--l-56.8%
associate--l-56.8%
sub-neg56.8%
associate--l+56.8%
fma-udef70.4%
neg-mul-170.4%
count-270.4%
associate-*l*70.4%
distribute-rgt-out--70.4%
associate-*r*70.4%
metadata-eval70.4%
Simplified70.4%
Taylor expanded in x.re around 0 65.3%
associate-*r*65.3%
*-commutative65.3%
*-commutative65.3%
metadata-eval65.3%
distribute-rgt-out65.3%
distribute-lft-in65.3%
mul-1-neg65.3%
distribute-rgt-neg-in65.3%
distribute-lft-neg-in65.3%
unpow265.3%
distribute-rgt-neg-out65.3%
*-commutative65.3%
metadata-eval65.3%
distribute-lft-neg-in65.3%
count-265.3%
distribute-rgt-neg-in65.3%
distribute-rgt-out65.3%
distribute-lft-out65.3%
distribute-rgt-neg-in65.3%
count-265.3%
distribute-lft-neg-in65.3%
metadata-eval65.3%
Simplified77.7%
Taylor expanded in x.re around 0 77.7%
Final simplification75.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 82.5%
*-commutative82.5%
distribute-lft-out82.5%
associate-*l*82.5%
*-commutative82.5%
distribute-rgt-out--84.8%
associate--l-84.8%
associate--l-84.8%
sub-neg84.8%
associate--l+84.8%
fma-udef90.3%
neg-mul-190.3%
count-290.3%
associate-*l*90.3%
distribute-rgt-out--90.3%
associate-*r*90.3%
metadata-eval90.3%
Simplified90.3%
Taylor expanded in x.re around inf 62.5%
unpow262.5%
Simplified62.5%
Final simplification62.5%
(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 2023238
(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)))