
(FPCore (x.re x.im) :precision binary64 (+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re)))
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_im) + (((x_46_re * x_46_im) + (x_46_im * 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_46im * x_46im)) * x_46im) + (((x_46re * x_46im) + (x_46im * 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_im * x_46_im)) * x_46_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re);
}
def code(x_46_re, x_46_im): return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re)
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_im) + Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * 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_im * x_46_im)) * x_46_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re); 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$im), $MachinePrecision] + N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
\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.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re)))
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_im) + (((x_46_re * x_46_im) + (x_46_im * 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_46im * x_46im)) * x_46im) + (((x_46re * x_46im) + (x_46im * 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_im * x_46_im)) * x_46_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re);
}
def code(x_46_re, x_46_im): return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re)
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_im) + Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * 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_im * x_46_im)) * x_46_im) + (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_re); 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$im), $MachinePrecision] + N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.im + \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.re
\end{array}
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -5e+102) (not (<= x.im 1.55e+67))) (* x.im (* (- x.re x.im) (+ x.im x.re))) (- (* (* x.im x.re) (* x.re 3.0)) (pow x.im 3.0))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -5e+102) || !(x_46_im <= 1.55e+67)) {
tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
} else {
tmp = ((x_46_im * x_46_re) * (x_46_re * 3.0)) - pow(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 <= (-5d+102)) .or. (.not. (x_46im <= 1.55d+67))) then
tmp = x_46im * ((x_46re - x_46im) * (x_46im + x_46re))
else
tmp = ((x_46im * x_46re) * (x_46re * 3.0d0)) - (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 <= -5e+102) || !(x_46_im <= 1.55e+67)) {
tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
} else {
tmp = ((x_46_im * x_46_re) * (x_46_re * 3.0)) - Math.pow(x_46_im, 3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -5e+102) or not (x_46_im <= 1.55e+67): tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)) else: tmp = ((x_46_im * x_46_re) * (x_46_re * 3.0)) - math.pow(x_46_im, 3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -5e+102) || !(x_46_im <= 1.55e+67)) tmp = Float64(x_46_im * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im + x_46_re))); else tmp = Float64(Float64(Float64(x_46_im * x_46_re) * Float64(x_46_re * 3.0)) - (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 <= -5e+102) || ~((x_46_im <= 1.55e+67))) tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)); else tmp = ((x_46_im * x_46_re) * (x_46_re * 3.0)) - (x_46_im ^ 3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -5e+102], N[Not[LessEqual[x$46$im, 1.55e+67]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$im * x$46$re), $MachinePrecision] * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -5 \cdot 10^{+102} \lor \neg \left(x.im \leq 1.55 \cdot 10^{+67}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.im \cdot x.re\right) \cdot \left(x.re \cdot 3\right) - {x.im}^{3}\\
\end{array}
\end{array}
if x.im < -5e102 or 1.54999999999999998e67 < x.im Initial program 67.4%
difference-of-squares81.4%
*-commutative81.4%
Applied egg-rr81.4%
expm1-log1p-u61.6%
expm1-udef61.6%
*-commutative61.6%
*-commutative61.6%
count-261.6%
*-commutative61.6%
associate-*r*61.6%
associate-*r*61.6%
*-commutative61.6%
count-261.6%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified100.0%
if -5e102 < x.im < 1.54999999999999998e67Initial program 89.9%
Simplified99.8%
associate-*r*99.8%
associate-*l*99.8%
add-sqr-sqrt63.3%
pow263.3%
associate-*r*58.5%
associate-*r*58.5%
sqrt-prod43.2%
sqrt-prod25.1%
add-sqr-sqrt48.6%
Applied egg-rr48.6%
unpow248.6%
*-commutative48.6%
*-commutative48.6%
swap-sqr43.2%
add-sqr-sqrt89.9%
associate-*r*99.8%
associate-*r*99.8%
*-commutative99.8%
*-commutative99.8%
associate-*r*99.8%
Applied egg-rr99.8%
Final simplification99.9%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -5e+102) (not (<= x.im 2e+65))) (* x.im (* (- x.re x.im) (+ x.im x.re))) (- (* x.re (* (* x.im x.re) 3.0)) (pow x.im 3.0))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -5e+102) || !(x_46_im <= 2e+65)) {
tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
} else {
tmp = (x_46_re * ((x_46_im * x_46_re) * 3.0)) - pow(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 <= (-5d+102)) .or. (.not. (x_46im <= 2d+65))) then
tmp = x_46im * ((x_46re - x_46im) * (x_46im + x_46re))
else
tmp = (x_46re * ((x_46im * x_46re) * 3.0d0)) - (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 <= -5e+102) || !(x_46_im <= 2e+65)) {
tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
} else {
tmp = (x_46_re * ((x_46_im * x_46_re) * 3.0)) - Math.pow(x_46_im, 3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -5e+102) or not (x_46_im <= 2e+65): tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)) else: tmp = (x_46_re * ((x_46_im * x_46_re) * 3.0)) - math.pow(x_46_im, 3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -5e+102) || !(x_46_im <= 2e+65)) tmp = Float64(x_46_im * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im + x_46_re))); else tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_im * x_46_re) * 3.0)) - (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 <= -5e+102) || ~((x_46_im <= 2e+65))) tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)); else tmp = (x_46_re * ((x_46_im * x_46_re) * 3.0)) - (x_46_im ^ 3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -5e+102], N[Not[LessEqual[x$46$im, 2e+65]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * N[(N[(x$46$im * x$46$re), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -5 \cdot 10^{+102} \lor \neg \left(x.im \leq 2 \cdot 10^{+65}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(\left(x.im \cdot x.re\right) \cdot 3\right) - {x.im}^{3}\\
\end{array}
\end{array}
if x.im < -5e102 or 2e65 < x.im Initial program 67.4%
difference-of-squares81.4%
*-commutative81.4%
Applied egg-rr81.4%
expm1-log1p-u61.6%
expm1-udef61.6%
*-commutative61.6%
*-commutative61.6%
count-261.6%
*-commutative61.6%
associate-*r*61.6%
associate-*r*61.6%
*-commutative61.6%
count-261.6%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified100.0%
if -5e102 < x.im < 2e65Initial program 89.9%
Simplified99.8%
Taylor expanded in x.re around 0 99.8%
Final simplification99.8%
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.im (* (- x.re x.im) (+ x.im x.re))))
(t_1 (+ t_0 (* x.re (* (* x.im x.re) 2.0)))))
(if (<= x.im -5e+142)
t_0
(if (<= x.im -1.05e-66)
t_1
(if (<= x.im 1e-125)
(* (* x.im x.re) (* x.re 3.0))
(if (<= x.im 0.00275) t_1 t_0))))))
double code(double x_46_re, double x_46_im) {
double t_0 = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
double t_1 = t_0 + (x_46_re * ((x_46_im * x_46_re) * 2.0));
double tmp;
if (x_46_im <= -5e+142) {
tmp = t_0;
} else if (x_46_im <= -1.05e-66) {
tmp = t_1;
} else if (x_46_im <= 1e-125) {
tmp = (x_46_im * x_46_re) * (x_46_re * 3.0);
} else if (x_46_im <= 0.00275) {
tmp = t_1;
} else {
tmp = t_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) :: t_1
real(8) :: tmp
t_0 = x_46im * ((x_46re - x_46im) * (x_46im + x_46re))
t_1 = t_0 + (x_46re * ((x_46im * x_46re) * 2.0d0))
if (x_46im <= (-5d+142)) then
tmp = t_0
else if (x_46im <= (-1.05d-66)) then
tmp = t_1
else if (x_46im <= 1d-125) then
tmp = (x_46im * x_46re) * (x_46re * 3.0d0)
else if (x_46im <= 0.00275d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double t_0 = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
double t_1 = t_0 + (x_46_re * ((x_46_im * x_46_re) * 2.0));
double tmp;
if (x_46_im <= -5e+142) {
tmp = t_0;
} else if (x_46_im <= -1.05e-66) {
tmp = t_1;
} else if (x_46_im <= 1e-125) {
tmp = (x_46_im * x_46_re) * (x_46_re * 3.0);
} else if (x_46_im <= 0.00275) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im): t_0 = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)) t_1 = t_0 + (x_46_re * ((x_46_im * x_46_re) * 2.0)) tmp = 0 if x_46_im <= -5e+142: tmp = t_0 elif x_46_im <= -1.05e-66: tmp = t_1 elif x_46_im <= 1e-125: tmp = (x_46_im * x_46_re) * (x_46_re * 3.0) elif x_46_im <= 0.00275: tmp = t_1 else: tmp = t_0 return tmp
function code(x_46_re, x_46_im) t_0 = Float64(x_46_im * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im + x_46_re))) t_1 = Float64(t_0 + Float64(x_46_re * Float64(Float64(x_46_im * x_46_re) * 2.0))) tmp = 0.0 if (x_46_im <= -5e+142) tmp = t_0; elseif (x_46_im <= -1.05e-66) tmp = t_1; elseif (x_46_im <= 1e-125) tmp = Float64(Float64(x_46_im * x_46_re) * Float64(x_46_re * 3.0)); elseif (x_46_im <= 0.00275) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im) t_0 = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)); t_1 = t_0 + (x_46_re * ((x_46_im * x_46_re) * 2.0)); tmp = 0.0; if (x_46_im <= -5e+142) tmp = t_0; elseif (x_46_im <= -1.05e-66) tmp = t_1; elseif (x_46_im <= 1e-125) tmp = (x_46_im * x_46_re) * (x_46_re * 3.0); elseif (x_46_im <= 0.00275) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$im * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 + N[(x$46$re * N[(N[(x$46$im * x$46$re), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -5e+142], t$95$0, If[LessEqual[x$46$im, -1.05e-66], t$95$1, If[LessEqual[x$46$im, 1e-125], N[(N[(x$46$im * x$46$re), $MachinePrecision] * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 0.00275], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\
t_1 := t_0 + x.re \cdot \left(\left(x.im \cdot x.re\right) \cdot 2\right)\\
\mathbf{if}\;x.im \leq -5 \cdot 10^{+142}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.im \leq -1.05 \cdot 10^{-66}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x.im \leq 10^{-125}:\\
\;\;\;\;\left(x.im \cdot x.re\right) \cdot \left(x.re \cdot 3\right)\\
\mathbf{elif}\;x.im \leq 0.00275:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x.im < -5.0000000000000001e142 or 0.0027499999999999998 < x.im Initial program 68.9%
difference-of-squares82.2%
*-commutative82.2%
Applied egg-rr82.2%
expm1-log1p-u71.1%
expm1-udef71.1%
*-commutative71.1%
*-commutative71.1%
count-271.1%
*-commutative71.1%
associate-*r*71.1%
associate-*r*71.1%
*-commutative71.1%
count-271.1%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified100.0%
if -5.0000000000000001e142 < x.im < -1.05e-66 or 1.00000000000000001e-125 < x.im < 0.0027499999999999998Initial program 99.8%
difference-of-squares99.8%
*-commutative99.8%
Applied egg-rr99.8%
*-commutative99.8%
*-un-lft-identity99.8%
*-un-lft-identity99.8%
distribute-rgt-out99.8%
metadata-eval99.8%
Applied egg-rr99.8%
if -1.05e-66 < x.im < 1.00000000000000001e-125Initial program 83.2%
Taylor expanded in x.re around inf 83.2%
distribute-rgt1-in83.2%
metadata-eval83.2%
*-commutative83.2%
add-sqr-sqrt37.1%
unpow237.1%
swap-sqr46.3%
unpow246.3%
Applied egg-rr46.3%
unpow246.3%
*-commutative46.3%
*-commutative46.3%
swap-sqr37.1%
add-sqr-sqrt83.2%
associate-*r*99.7%
associate-*r*99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r*99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -0.106) (not (<= x.im 2.7e-48))) (* x.im (* (- x.re x.im) (+ x.im x.re))) (* (* x.im x.re) (* x.re 3.0))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -0.106) || !(x_46_im <= 2.7e-48)) {
tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
} else {
tmp = (x_46_im * x_46_re) * (x_46_re * 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 <= (-0.106d0)) .or. (.not. (x_46im <= 2.7d-48))) then
tmp = x_46im * ((x_46re - x_46im) * (x_46im + x_46re))
else
tmp = (x_46im * x_46re) * (x_46re * 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 <= -0.106) || !(x_46_im <= 2.7e-48)) {
tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re));
} else {
tmp = (x_46_im * x_46_re) * (x_46_re * 3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -0.106) or not (x_46_im <= 2.7e-48): tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)) else: tmp = (x_46_im * x_46_re) * (x_46_re * 3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -0.106) || !(x_46_im <= 2.7e-48)) tmp = Float64(x_46_im * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im + x_46_re))); else tmp = Float64(Float64(x_46_im * x_46_re) * Float64(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_im <= -0.106) || ~((x_46_im <= 2.7e-48))) tmp = x_46_im * ((x_46_re - x_46_im) * (x_46_im + x_46_re)); else tmp = (x_46_im * x_46_re) * (x_46_re * 3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -0.106], N[Not[LessEqual[x$46$im, 2.7e-48]], $MachinePrecision]], N[(x$46$im * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * x$46$re), $MachinePrecision] * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -0.106 \lor \neg \left(x.im \leq 2.7 \cdot 10^{-48}\right):\\
\;\;\;\;x.im \cdot \left(\left(x.re - x.im\right) \cdot \left(x.im + x.re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.im \cdot x.re\right) \cdot \left(x.re \cdot 3\right)\\
\end{array}
\end{array}
if x.im < -0.105999999999999997 or 2.70000000000000011e-48 < x.im Initial program 78.2%
difference-of-squares87.5%
*-commutative87.5%
Applied egg-rr87.5%
expm1-log1p-u64.2%
expm1-udef63.6%
*-commutative63.6%
*-commutative63.6%
count-263.6%
*-commutative63.6%
associate-*r*63.6%
associate-*r*63.6%
*-commutative63.6%
count-263.6%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified96.9%
if -0.105999999999999997 < x.im < 2.70000000000000011e-48Initial program 86.6%
Taylor expanded in x.re around inf 81.9%
distribute-rgt1-in81.9%
metadata-eval81.9%
*-commutative81.9%
add-sqr-sqrt37.6%
unpow237.6%
swap-sqr44.9%
unpow244.9%
Applied egg-rr44.9%
unpow247.0%
*-commutative47.0%
*-commutative47.0%
swap-sqr39.7%
add-sqr-sqrt86.5%
associate-*r*99.7%
associate-*r*99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r*99.7%
Applied egg-rr95.1%
Final simplification96.0%
(FPCore (x.re x.im) :precision binary64 (* (* x.im x.re) (* x.re 3.0)))
double code(double x_46_re, double x_46_im) {
return (x_46_im * x_46_re) * (x_46_re * 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_46re * 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_re * 3.0);
}
def code(x_46_re, x_46_im): return (x_46_im * x_46_re) * (x_46_re * 3.0)
function code(x_46_re, x_46_im) return Float64(Float64(x_46_im * x_46_re) * Float64(x_46_re * 3.0)) end
function tmp = code(x_46_re, x_46_im) tmp = (x_46_im * x_46_re) * (x_46_re * 3.0); end
code[x$46$re_, x$46$im_] := N[(N[(x$46$im * x$46$re), $MachinePrecision] * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.im \cdot x.re\right) \cdot \left(x.re \cdot 3\right)
\end{array}
Initial program 82.4%
Taylor expanded in x.re around inf 58.9%
distribute-rgt1-in58.9%
metadata-eval58.9%
*-commutative58.9%
add-sqr-sqrt30.6%
unpow230.6%
swap-sqr34.2%
unpow234.2%
Applied egg-rr34.2%
unpow242.4%
*-commutative42.4%
*-commutative42.4%
swap-sqr38.8%
add-sqr-sqrt80.4%
associate-*r*87.0%
associate-*r*86.9%
*-commutative86.9%
*-commutative86.9%
associate-*r*87.0%
Applied egg-rr65.4%
Final simplification65.4%
(FPCore (x.re x.im) :precision binary64 -3.0)
double code(double x_46_re, double x_46_im) {
return -3.0;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = -3.0d0
end function
public static double code(double x_46_re, double x_46_im) {
return -3.0;
}
def code(x_46_re, x_46_im): return -3.0
function code(x_46_re, x_46_im) return -3.0 end
function tmp = code(x_46_re, x_46_im) tmp = -3.0; end
code[x$46$re_, x$46$im_] := -3.0
\begin{array}{l}
\\
-3
\end{array}
Initial program 82.4%
difference-of-squares87.1%
*-commutative87.1%
Applied egg-rr87.1%
Taylor expanded in x.re around 0 65.9%
Simplified27.4%
expm1-log1p-u66.4%
expm1-udef56.6%
*-commutative56.6%
*-commutative56.6%
count-256.6%
*-commutative56.6%
associate-*r*56.6%
associate-*r*56.6%
*-commutative56.6%
count-256.6%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified2.6%
Final simplification2.6%
(FPCore (x.re x.im) :precision binary64 (+ (* (* x.re x.im) (* 2.0 x.re)) (* (* x.im (- x.re x.im)) (+ x.re x.im))))
double code(double x_46_re, double x_46_im) {
return ((x_46_re * x_46_im) * (2.0 * x_46_re)) + ((x_46_im * (x_46_re - 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_46im) * (2.0d0 * x_46re)) + ((x_46im * (x_46re - 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_im) * (2.0 * x_46_re)) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im));
}
def code(x_46_re, x_46_im): return ((x_46_re * x_46_im) * (2.0 * x_46_re)) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im))
function code(x_46_re, x_46_im) return Float64(Float64(Float64(x_46_re * x_46_im) * Float64(2.0 * x_46_re)) + Float64(Float64(x_46_im * Float64(x_46_re - x_46_im)) * Float64(x_46_re + x_46_im))) end
function tmp = code(x_46_re, x_46_im) tmp = ((x_46_re * x_46_im) * (2.0 * x_46_re)) + ((x_46_im * (x_46_re - x_46_im)) * (x_46_re + x_46_im)); end
code[x$46$re_, x$46$im_] := N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(2.0 * x$46$re), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$im * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.im\right) \cdot \left(2 \cdot x.re\right) + \left(x.im \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right)
\end{array}
herbie shell --seed 2023318
(FPCore (x.re x.im)
:name "math.cube on complex, imaginary part"
:precision binary64
:herbie-target
(+ (* (* x.re x.im) (* 2.0 x.re)) (* (* x.im (- x.re x.im)) (+ x.re x.im)))
(+ (* (- (* x.re x.re) (* x.im x.im)) x.im) (* (+ (* x.re x.im) (* x.im x.re)) x.re)))