
(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 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im) :precision binary64 (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im): return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
function code(x_46_re, x_46_im) return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im)) end
function tmp = code(x_46_re, x_46_im) tmp = (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im); end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\end{array}
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* x.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)))
(pow x.re 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 = fma((x_46_re * x_46_re), x_46_re, ((x_46_re * x_46_im) * (x_46_im * -3.0)));
} else {
tmp = pow(x_46_re, 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 = 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 = x_46_re ^ 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[(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[Power[x$46$re, 3.0], $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}^{3}\\
\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 92.8%
Simplified91.1%
unpow391.0%
fma-def92.8%
associate-*r*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%
Simplified0.0%
Taylor expanded in x.re around inf 72.4%
Final simplification96.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)
(- (* (+ x.re x.im) (* x.re (- x.re x.im))) (* x.im (* x.re (+ x.im x.im))))
(pow x.re 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 = pow(x_46_re, 3.0);
}
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 = Math.pow(x_46_re, 3.0);
}
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 = math.pow(x_46_re, 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 = x_46_re ^ 3.0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (((x_46_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 ^ 3.0; 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[Power[x$46$re, 3.0], $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}^{3}\\
\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 92.8%
sqr-neg92.8%
difference-of-squares92.8%
sub-neg92.8%
associate-*l*99.7%
sub-neg99.7%
remove-double-neg99.7%
+-commutative99.7%
*-commutative99.7%
*-commutative99.7%
distribute-rgt-out99.7%
Simplified99.7%
cancel-sign-sub-inv99.7%
fma-def99.8%
*-commutative99.8%
Applied egg-rr99.8%
*-commutative99.8%
add-cube-cbrt99.2%
pow399.2%
*-commutative99.2%
Applied egg-rr99.2%
fma-udef99.2%
unpow399.2%
add-cube-cbrt99.7%
Applied egg-rr99.7%
distribute-lft-neg-out99.7%
unsub-neg99.7%
associate-*r*99.7%
*-commutative99.7%
*-commutative99.7%
Simplified99.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%
Simplified0.0%
Taylor expanded in x.re around inf 72.4%
Final simplification96.6%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.re -1.9e-94) (not (<= x.re 2.45e-67))) (- (* (- x.re x.im) (* x.re (+ x.re x.im))) (* x.re (* x.im x.im))) (* x.im (* (* x.re x.im) -3.0))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -1.9e-94) || !(x_46_re <= 2.45e-67)) {
tmp = ((x_46_re - x_46_im) * (x_46_re * (x_46_re + x_46_im))) - (x_46_re * (x_46_im * x_46_im));
} 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_46re <= (-1.9d-94)) .or. (.not. (x_46re <= 2.45d-67))) then
tmp = ((x_46re - x_46im) * (x_46re * (x_46re + x_46im))) - (x_46re * (x_46im * x_46im))
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_re <= -1.9e-94) || !(x_46_re <= 2.45e-67)) {
tmp = ((x_46_re - x_46_im) * (x_46_re * (x_46_re + x_46_im))) - (x_46_re * (x_46_im * x_46_im));
} 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_re <= -1.9e-94) or not (x_46_re <= 2.45e-67): tmp = ((x_46_re - x_46_im) * (x_46_re * (x_46_re + x_46_im))) - (x_46_re * (x_46_im * x_46_im)) 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_re <= -1.9e-94) || !(x_46_re <= 2.45e-67)) tmp = Float64(Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re * Float64(x_46_re + x_46_im))) - Float64(x_46_re * Float64(x_46_im * x_46_im))); else tmp = Float64(x_46_im * Float64(Float64(x_46_re * 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 <= -1.9e-94) || ~((x_46_re <= 2.45e-67))) tmp = ((x_46_re - x_46_im) * (x_46_re * (x_46_re + x_46_im))) - (x_46_re * (x_46_im * x_46_im)); 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[Or[LessEqual[x$46$re, -1.9e-94], N[Not[LessEqual[x$46$re, 2.45e-67]], $MachinePrecision]], 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$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1.9 \cdot 10^{-94} \lor \neg \left(x.re \leq 2.45 \cdot 10^{-67}\right):\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(x.re \cdot \left(x.re + x.im\right)\right) - x.re \cdot \left(x.im \cdot x.im\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)\\
\end{array}
\end{array}
if x.re < -1.9e-94 or 2.44999999999999997e-67 < x.re Initial program 81.5%
sqr-neg81.5%
difference-of-squares86.4%
sub-neg86.4%
associate-*l*86.9%
sub-neg86.9%
remove-double-neg86.9%
+-commutative86.9%
*-commutative86.9%
*-commutative86.9%
distribute-rgt-out86.9%
Simplified86.9%
distribute-lft-in86.9%
add-cube-cbrt86.9%
fma-def86.9%
pow286.9%
Applied egg-rr86.8%
Taylor expanded in x.im around 0 77.2%
*-commutative77.2%
unpow277.2%
Simplified77.2%
if -1.9e-94 < x.re < 2.44999999999999997e-67Initial program 83.6%
sqr-neg83.6%
difference-of-squares83.6%
sub-neg83.6%
associate-*l*99.7%
sub-neg99.7%
remove-double-neg99.7%
+-commutative99.7%
*-commutative99.7%
*-commutative99.7%
distribute-rgt-out99.7%
Simplified99.7%
cancel-sign-sub-inv99.7%
fma-def99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in x.re around 0 81.9%
distribute-rgt-out81.9%
unpow281.9%
metadata-eval81.9%
Simplified81.9%
Taylor expanded in x.re around 0 81.8%
*-commutative81.8%
associate-*r*81.9%
unpow281.9%
associate-*l*97.9%
*-commutative97.9%
associate-*r*97.9%
Simplified97.9%
Taylor expanded in x.im around 0 98.0%
Final simplification84.8%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 8e+87) (+ (* x.re (- (* x.re x.re) (* x.im x.im))) (* (* x.im x.im) (* x.re -2.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 <= 8e+87) {
tmp = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + ((x_46_im * x_46_im) * (x_46_re * -2.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 <= 8d+87) then
tmp = (x_46re * ((x_46re * x_46re) - (x_46im * x_46im))) + ((x_46im * x_46im) * (x_46re * (-2.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 <= 8e+87) {
tmp = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + ((x_46_im * x_46_im) * (x_46_re * -2.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 <= 8e+87: tmp = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + ((x_46_im * x_46_im) * (x_46_re * -2.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 <= 8e+87) tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(Float64(x_46_im * x_46_im) * Float64(x_46_re * -2.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 <= 8e+87) tmp = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + ((x_46_im * x_46_im) * (x_46_re * -2.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, 8e+87], 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[(N[(x$46$im * x$46$im), $MachinePrecision] * N[(x$46$re * -2.0), $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 8 \cdot 10^{+87}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + \left(x.im \cdot x.im\right) \cdot \left(x.re \cdot -2\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.re \cdot \left(x.im \cdot -3\right)\right)\\
\end{array}
\end{array}
if x.im < 7.9999999999999997e87Initial program 87.8%
sqr-neg87.8%
*-commutative87.8%
fma-neg87.8%
sqr-neg87.8%
+-commutative87.8%
*-commutative87.8%
*-commutative87.8%
distribute-lft-out87.8%
associate-*r*87.8%
distribute-rgt-neg-in87.8%
distribute-neg-out87.8%
neg-mul-187.8%
neg-mul-187.8%
distribute-rgt-out87.8%
metadata-eval87.8%
Simplified87.8%
fma-udef87.8%
Applied egg-rr87.8%
if 7.9999999999999997e87 < x.im Initial program 55.4%
sqr-neg55.4%
difference-of-squares64.5%
sub-neg64.5%
associate-*l*81.4%
sub-neg81.4%
remove-double-neg81.4%
+-commutative81.4%
*-commutative81.4%
*-commutative81.4%
distribute-rgt-out81.4%
Simplified81.4%
cancel-sign-sub-inv81.4%
fma-def81.6%
*-commutative81.6%
Applied egg-rr81.6%
Taylor expanded in x.re around 0 64.5%
distribute-rgt-out64.5%
unpow264.5%
metadata-eval64.5%
Simplified64.5%
Taylor expanded in x.re around 0 64.5%
*-commutative64.5%
associate-*r*64.5%
unpow264.5%
associate-*l*81.6%
*-commutative81.6%
associate-*r*81.6%
Simplified81.6%
Final simplification86.7%
(FPCore (x.re x.im) :precision binary64 (- (* (+ x.re x.im) (* x.re (- x.re x.im))) (* x.im (* x.re (+ x.im x.im)))))
double code(double x_46_re, double x_46_im) {
return ((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)));
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = ((x_46re + x_46im) * (x_46re * (x_46re - x_46im))) - (x_46im * (x_46re * (x_46im + x_46im)))
end function
public static double code(double x_46_re, double x_46_im) {
return ((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)));
}
def code(x_46_re, x_46_im): return ((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)))
function code(x_46_re, x_46_im) return 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)))) end
function tmp = code(x_46_re, x_46_im) 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))); end
code[x$46$re_, x$46$im_] := 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]
\begin{array}{l}
\\
\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)
\end{array}
Initial program 82.2%
sqr-neg82.2%
difference-of-squares85.4%
sub-neg85.4%
associate-*l*91.5%
sub-neg91.5%
remove-double-neg91.5%
+-commutative91.5%
*-commutative91.5%
*-commutative91.5%
distribute-rgt-out91.5%
Simplified91.5%
cancel-sign-sub-inv91.5%
fma-def91.6%
*-commutative91.6%
Applied egg-rr91.6%
*-commutative91.6%
add-cube-cbrt91.1%
pow391.1%
*-commutative91.1%
Applied egg-rr91.1%
fma-udef91.1%
unpow391.1%
add-cube-cbrt91.5%
Applied egg-rr91.5%
distribute-lft-neg-out91.5%
unsub-neg91.5%
associate-*r*91.5%
*-commutative91.5%
*-commutative91.5%
Simplified91.5%
Final simplification91.5%
(FPCore (x.re x.im) :precision binary64 (* -2.0 (* x.im (* x.re x.im))))
double code(double x_46_re, double x_46_im) {
return -2.0 * (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 = (-2.0d0) * (x_46im * (x_46re * x_46im))
end function
public static double code(double x_46_re, double x_46_im) {
return -2.0 * (x_46_im * (x_46_re * x_46_im));
}
def code(x_46_re, x_46_im): return -2.0 * (x_46_im * (x_46_re * x_46_im))
function code(x_46_re, x_46_im) return Float64(-2.0 * Float64(x_46_im * Float64(x_46_re * x_46_im))) end
function tmp = code(x_46_re, x_46_im) tmp = -2.0 * (x_46_im * (x_46_re * x_46_im)); end
code[x$46$re_, x$46$im_] := N[(-2.0 * N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)
\end{array}
Initial program 82.2%
sqr-neg82.2%
difference-of-squares85.4%
sub-neg85.4%
associate-*l*91.5%
sub-neg91.5%
remove-double-neg91.5%
+-commutative91.5%
*-commutative91.5%
*-commutative91.5%
distribute-rgt-out91.5%
Simplified91.5%
cancel-sign-sub-inv91.5%
fma-def91.6%
*-commutative91.6%
Applied egg-rr91.6%
distribute-lft-in91.6%
add-cube-cbrt91.4%
fma-def91.4%
pow291.4%
Applied egg-rr91.4%
Taylor expanded in x.re around 0 31.6%
unpow231.6%
associate-*l*32.5%
Simplified32.5%
Final simplification32.5%
(FPCore (x.re x.im) :precision binary64 (* x.im (* (* x.re x.im) -3.0)))
double code(double x_46_re, double x_46_im) {
return x_46_im * ((x_46_re * x_46_im) * -3.0);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = x_46im * ((x_46re * x_46im) * (-3.0d0))
end function
public static double code(double x_46_re, double x_46_im) {
return x_46_im * ((x_46_re * x_46_im) * -3.0);
}
def code(x_46_re, x_46_im): return x_46_im * ((x_46_re * x_46_im) * -3.0)
function code(x_46_re, x_46_im) return Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * -3.0)) end
function tmp = code(x_46_re, x_46_im) tmp = x_46_im * ((x_46_re * x_46_im) * -3.0); end
code[x$46$re_, x$46$im_] := N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot -3\right)
\end{array}
Initial program 82.2%
sqr-neg82.2%
difference-of-squares85.4%
sub-neg85.4%
associate-*l*91.5%
sub-neg91.5%
remove-double-neg91.5%
+-commutative91.5%
*-commutative91.5%
*-commutative91.5%
distribute-rgt-out91.5%
Simplified91.5%
cancel-sign-sub-inv91.5%
fma-def91.6%
*-commutative91.6%
Applied egg-rr91.6%
Taylor expanded in x.re around 0 47.4%
distribute-rgt-out47.4%
unpow247.4%
metadata-eval47.4%
Simplified47.4%
Taylor expanded in x.re around 0 47.3%
*-commutative47.3%
associate-*r*47.4%
unpow247.4%
associate-*l*53.5%
*-commutative53.5%
associate-*r*53.6%
Simplified53.6%
Taylor expanded in x.im around 0 53.6%
Final simplification53.6%
(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 2023271
(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)))