
(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}
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (<= x.im 1.2e+144) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0)))) (* x.im (* -3.0 (* x.im x.re)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 1.2e+144) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
NOTE: x.im should be positive before calling this function
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.2d+144) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = x_46im * ((-3.0d0) * (x_46im * x_46re))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 1.2e+144) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= 1.2e+144: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) else: tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 1.2e+144) 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(-3.0 * Float64(x_46_im * x_46_re))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= 1.2e+144) tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); else tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 1.2e+144], 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[(-3.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1.2 \cdot 10^{+144}:\\
\;\;\;\;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(-3 \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 1.2e144Initial program 85.6%
*-commutative85.6%
distribute-lft-out85.6%
associate-*l*85.6%
*-commutative85.6%
distribute-rgt-out--92.9%
associate--l-92.9%
associate--l-92.9%
sub-neg92.9%
associate--l+92.9%
fma-udef93.8%
neg-mul-193.8%
count-293.8%
associate-*l*93.8%
distribute-rgt-out--93.8%
associate-*r*93.8%
metadata-eval93.8%
Simplified93.8%
fma-udef92.9%
Applied egg-rr92.9%
if 1.2e144 < x.im Initial program 55.8%
*-commutative55.8%
distribute-lft-out55.8%
associate-*l*55.8%
*-commutative55.8%
distribute-rgt-out--58.6%
associate--l-55.8%
associate--l-58.6%
sub-neg58.6%
associate--l+55.8%
fma-udef67.2%
neg-mul-167.2%
count-267.2%
associate-*l*67.2%
distribute-rgt-out--67.2%
associate-*r*67.2%
metadata-eval67.2%
Simplified67.2%
Taylor expanded in x.re around 0 67.2%
associate-*r*67.2%
unpow267.2%
Simplified67.2%
add-log-exp61.7%
exp-prod35.3%
exp-prod35.3%
Applied egg-rr35.3%
log-pow34.4%
associate-*l*35.3%
log-pow88.3%
Simplified88.3%
Taylor expanded in x.im around 0 88.3%
Final simplification92.3%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (or (<= x.im 1.35e-7) (and (not (<= x.im 8e+20)) (<= x.im 5e+66))) (* x.re (* x.re x.re)) (* -3.0 (* x.re (* x.im x.im)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= 1.35e-7) || (!(x_46_im <= 8e+20) && (x_46_im <= 5e+66))) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
}
return tmp;
}
NOTE: x.im should be positive before calling this function
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.35d-7) .or. (.not. (x_46im <= 8d+20)) .and. (x_46im <= 5d+66)) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= 1.35e-7) || (!(x_46_im <= 8e+20) && (x_46_im <= 5e+66))) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= 1.35e-7) or (not (x_46_im <= 8e+20) and (x_46_im <= 5e+66)): tmp = x_46_re * (x_46_re * x_46_re) else: tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= 1.35e-7) || (!(x_46_im <= 8e+20) && (x_46_im <= 5e+66))) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_im <= 1.35e-7) || (~((x_46_im <= 8e+20)) && (x_46_im <= 5e+66))) tmp = x_46_re * (x_46_re * x_46_re); else tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, 1.35e-7], And[N[Not[LessEqual[x$46$im, 8e+20]], $MachinePrecision], LessEqual[x$46$im, 5e+66]]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1.35 \cdot 10^{-7} \lor \neg \left(x.im \leq 8 \cdot 10^{+20}\right) \land x.im \leq 5 \cdot 10^{+66}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.im < 1.35000000000000004e-7 or 8e20 < x.im < 4.99999999999999991e66Initial program 84.9%
*-commutative84.9%
distribute-lft-out84.9%
associate-*l*84.9%
*-commutative84.9%
distribute-rgt-out--92.3%
associate--l-92.3%
associate--l-92.3%
sub-neg92.3%
associate--l+92.3%
fma-udef93.3%
neg-mul-193.3%
count-293.3%
associate-*l*93.3%
distribute-rgt-out--93.3%
associate-*r*93.3%
metadata-eval93.3%
Simplified93.3%
Taylor expanded in x.re around inf 71.1%
unpow271.1%
Simplified71.1%
if 1.35000000000000004e-7 < x.im < 8e20 or 4.99999999999999991e66 < x.im Initial program 68.7%
*-commutative68.7%
distribute-lft-out68.7%
associate-*l*68.7%
*-commutative68.7%
distribute-rgt-out--72.5%
associate--l-70.6%
associate--l-72.5%
sub-neg72.5%
associate--l+70.6%
fma-udef78.2%
neg-mul-178.2%
count-278.2%
associate-*l*78.2%
distribute-rgt-out--78.2%
associate-*r*78.1%
metadata-eval78.1%
Simplified78.1%
Taylor expanded in x.re around 0 70.5%
associate-*r*70.5%
unpow270.5%
Simplified70.5%
add-log-exp43.9%
exp-prod26.3%
exp-prod26.3%
Applied egg-rr26.3%
log-pow26.4%
associate-*l*27.0%
log-pow84.5%
Simplified84.5%
Taylor expanded in x.im around 0 70.5%
Simplified70.5%
Final simplification71.0%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (or (<= x.im 1.7e-7) (and (not (<= x.im 1.95e+21)) (<= x.im 3e+66))) (* x.re (* x.re x.re)) (* x.im (* -3.0 (* x.im x.re)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= 1.7e-7) || (!(x_46_im <= 1.95e+21) && (x_46_im <= 3e+66))) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
NOTE: x.im should be positive before calling this function
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.7d-7) .or. (.not. (x_46im <= 1.95d+21)) .and. (x_46im <= 3d+66)) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = x_46im * ((-3.0d0) * (x_46im * x_46re))
end if
code = tmp
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= 1.7e-7) || (!(x_46_im <= 1.95e+21) && (x_46_im <= 3e+66))) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= 1.7e-7) or (not (x_46_im <= 1.95e+21) and (x_46_im <= 3e+66)): tmp = x_46_re * (x_46_re * x_46_re) else: tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)) return tmp
x.im = abs(x.im) function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= 1.7e-7) || (!(x_46_im <= 1.95e+21) && (x_46_im <= 3e+66))) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_im * x_46_re))); end return tmp end
x.im = abs(x.im) function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_im <= 1.7e-7) || (~((x_46_im <= 1.95e+21)) && (x_46_im <= 3e+66))) tmp = x_46_re * (x_46_re * x_46_re); else tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, 1.7e-7], And[N[Not[LessEqual[x$46$im, 1.95e+21]], $MachinePrecision], LessEqual[x$46$im, 3e+66]]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(-3.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1.7 \cdot 10^{-7} \lor \neg \left(x.im \leq 1.95 \cdot 10^{+21}\right) \land x.im \leq 3 \cdot 10^{+66}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(-3 \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 1.69999999999999987e-7 or 1.95e21 < x.im < 3.00000000000000002e66Initial program 84.9%
*-commutative84.9%
distribute-lft-out84.9%
associate-*l*84.9%
*-commutative84.9%
distribute-rgt-out--92.3%
associate--l-92.3%
associate--l-92.3%
sub-neg92.3%
associate--l+92.3%
fma-udef93.3%
neg-mul-193.3%
count-293.3%
associate-*l*93.3%
distribute-rgt-out--93.3%
associate-*r*93.3%
metadata-eval93.3%
Simplified93.3%
Taylor expanded in x.re around inf 71.1%
unpow271.1%
Simplified71.1%
if 1.69999999999999987e-7 < x.im < 1.95e21 or 3.00000000000000002e66 < x.im Initial program 68.7%
*-commutative68.7%
distribute-lft-out68.7%
associate-*l*68.7%
*-commutative68.7%
distribute-rgt-out--72.5%
associate--l-70.6%
associate--l-72.5%
sub-neg72.5%
associate--l+70.6%
fma-udef78.2%
neg-mul-178.2%
count-278.2%
associate-*l*78.2%
distribute-rgt-out--78.2%
associate-*r*78.1%
metadata-eval78.1%
Simplified78.1%
Taylor expanded in x.re around 0 70.5%
associate-*r*70.5%
unpow270.5%
Simplified70.5%
add-log-exp43.9%
exp-prod26.3%
exp-prod26.3%
Applied egg-rr26.3%
log-pow26.4%
associate-*l*27.0%
log-pow84.5%
Simplified84.5%
Taylor expanded in x.im around 0 84.4%
Final simplification73.8%
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.re (* x.re x.re))))
(if (<= x.im 1.1e-7)
t_0
(if (<= x.im 2.1e+21)
(* x.re (* -3.0 (* x.im x.im)))
(if (<= x.im 1e+67) t_0 (* x.im (* -3.0 (* x.im x.re))))))))x.im = abs(x.im);
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_im <= 1.1e-7) {
tmp = t_0;
} else if (x_46_im <= 2.1e+21) {
tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
} else if (x_46_im <= 1e+67) {
tmp = t_0;
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
NOTE: x.im should be positive before calling this function
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_46im <= 1.1d-7) then
tmp = t_0
else if (x_46im <= 2.1d+21) then
tmp = x_46re * ((-3.0d0) * (x_46im * x_46im))
else if (x_46im <= 1d+67) then
tmp = t_0
else
tmp = x_46im * ((-3.0d0) * (x_46im * x_46re))
end if
code = tmp
end function
x.im = Math.abs(x.im);
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_im <= 1.1e-7) {
tmp = t_0;
} else if (x_46_im <= 2.1e+21) {
tmp = x_46_re * (-3.0 * (x_46_im * x_46_im));
} else if (x_46_im <= 1e+67) {
tmp = t_0;
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): t_0 = x_46_re * (x_46_re * x_46_re) tmp = 0 if x_46_im <= 1.1e-7: tmp = t_0 elif x_46_im <= 2.1e+21: tmp = x_46_re * (-3.0 * (x_46_im * x_46_im)) elif x_46_im <= 1e+67: tmp = t_0 else: tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)) return tmp
x.im = abs(x.im) 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_im <= 1.1e-7) tmp = t_0; elseif (x_46_im <= 2.1e+21) tmp = Float64(x_46_re * Float64(-3.0 * Float64(x_46_im * x_46_im))); elseif (x_46_im <= 1e+67) tmp = t_0; else tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_im * x_46_re))); end return tmp end
x.im = abs(x.im) 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_im <= 1.1e-7) tmp = t_0; elseif (x_46_im <= 2.1e+21) tmp = x_46_re * (-3.0 * (x_46_im * x_46_im)); elseif (x_46_im <= 1e+67) tmp = t_0; else tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function
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$im, 1.1e-7], t$95$0, If[LessEqual[x$46$im, 2.1e+21], N[(x$46$re * N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 1e+67], t$95$0, N[(x$46$im * N[(-3.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{if}\;x.im \leq 1.1 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.im \leq 2.1 \cdot 10^{+21}:\\
\;\;\;\;x.re \cdot \left(-3 \cdot \left(x.im \cdot x.im\right)\right)\\
\mathbf{elif}\;x.im \leq 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(-3 \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 1.1000000000000001e-7 or 2.1e21 < x.im < 9.99999999999999983e66Initial program 84.9%
*-commutative84.9%
distribute-lft-out84.9%
associate-*l*84.9%
*-commutative84.9%
distribute-rgt-out--92.3%
associate--l-92.3%
associate--l-92.3%
sub-neg92.3%
associate--l+92.3%
fma-udef93.3%
neg-mul-193.3%
count-293.3%
associate-*l*93.3%
distribute-rgt-out--93.3%
associate-*r*93.3%
metadata-eval93.3%
Simplified93.3%
Taylor expanded in x.re around inf 71.1%
unpow271.1%
Simplified71.1%
if 1.1000000000000001e-7 < x.im < 2.1e21Initial program 99.1%
*-commutative99.1%
distribute-lft-out99.1%
associate-*l*99.3%
*-commutative99.3%
distribute-rgt-out--99.3%
associate--l-99.3%
associate--l-99.3%
sub-neg99.3%
associate--l+99.3%
fma-udef99.3%
neg-mul-199.3%
count-299.3%
associate-*l*99.3%
distribute-rgt-out--99.3%
associate-*r*99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in x.re around 0 71.0%
associate-*r*70.8%
*-commutative70.8%
*-commutative70.8%
metadata-eval70.8%
distribute-rgt-out70.8%
+-commutative70.8%
distribute-rgt-in71.0%
*-commutative71.0%
metadata-eval71.0%
distribute-lft-neg-in71.0%
count-271.0%
distribute-rgt-neg-in71.0%
distribute-rgt-out71.0%
distribute-lft-out71.0%
distribute-rgt-neg-in71.0%
count-271.0%
distribute-lft-neg-in71.0%
metadata-eval71.0%
mul-1-neg71.0%
distribute-lft-neg-in71.0%
distribute-rgt-neg-in71.0%
unpow271.0%
distribute-rgt-neg-out71.0%
Simplified71.0%
if 9.99999999999999983e66 < x.im Initial program 64.1%
*-commutative64.1%
distribute-lft-out64.1%
associate-*l*64.1%
*-commutative64.1%
distribute-rgt-out--68.4%
associate--l-66.3%
associate--l-68.4%
sub-neg68.4%
associate--l+66.3%
fma-udef74.9%
neg-mul-174.9%
count-274.9%
associate-*l*74.9%
distribute-rgt-out--74.9%
associate-*r*74.9%
metadata-eval74.9%
Simplified74.9%
Taylor expanded in x.re around 0 70.4%
associate-*r*70.5%
unpow270.5%
Simplified70.5%
add-log-exp50.0%
exp-prod29.8%
exp-prod29.8%
Applied egg-rr29.8%
log-pow29.9%
associate-*l*30.6%
log-pow86.5%
Simplified86.5%
Taylor expanded in x.im around 0 86.5%
Final simplification73.9%
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.re (* x.re x.re))))
(if (<= x.im 8.6e-8)
t_0
(if (<= x.im 3e+20)
(* x.re (* x.im (* x.im -3.0)))
(if (<= x.im 3.7e+67) t_0 (* x.im (* -3.0 (* x.im x.re))))))))x.im = abs(x.im);
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_im <= 8.6e-8) {
tmp = t_0;
} else if (x_46_im <= 3e+20) {
tmp = x_46_re * (x_46_im * (x_46_im * -3.0));
} else if (x_46_im <= 3.7e+67) {
tmp = t_0;
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
NOTE: x.im should be positive before calling this function
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_46im <= 8.6d-8) then
tmp = t_0
else if (x_46im <= 3d+20) then
tmp = x_46re * (x_46im * (x_46im * (-3.0d0)))
else if (x_46im <= 3.7d+67) then
tmp = t_0
else
tmp = x_46im * ((-3.0d0) * (x_46im * x_46re))
end if
code = tmp
end function
x.im = Math.abs(x.im);
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_im <= 8.6e-8) {
tmp = t_0;
} else if (x_46_im <= 3e+20) {
tmp = x_46_re * (x_46_im * (x_46_im * -3.0));
} else if (x_46_im <= 3.7e+67) {
tmp = t_0;
} else {
tmp = x_46_im * (-3.0 * (x_46_im * x_46_re));
}
return tmp;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): t_0 = x_46_re * (x_46_re * x_46_re) tmp = 0 if x_46_im <= 8.6e-8: tmp = t_0 elif x_46_im <= 3e+20: tmp = x_46_re * (x_46_im * (x_46_im * -3.0)) elif x_46_im <= 3.7e+67: tmp = t_0 else: tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)) return tmp
x.im = abs(x.im) 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_im <= 8.6e-8) tmp = t_0; elseif (x_46_im <= 3e+20) tmp = Float64(x_46_re * Float64(x_46_im * Float64(x_46_im * -3.0))); elseif (x_46_im <= 3.7e+67) tmp = t_0; else tmp = Float64(x_46_im * Float64(-3.0 * Float64(x_46_im * x_46_re))); end return tmp end
x.im = abs(x.im) 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_im <= 8.6e-8) tmp = t_0; elseif (x_46_im <= 3e+20) tmp = x_46_re * (x_46_im * (x_46_im * -3.0)); elseif (x_46_im <= 3.7e+67) tmp = t_0; else tmp = x_46_im * (-3.0 * (x_46_im * x_46_re)); end tmp_2 = tmp; end
NOTE: x.im should be positive before calling this function
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$im, 8.6e-8], t$95$0, If[LessEqual[x$46$im, 3e+20], N[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 3.7e+67], t$95$0, N[(x$46$im * N[(-3.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{if}\;x.im \leq 8.6 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.im \leq 3 \cdot 10^{+20}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{elif}\;x.im \leq 3.7 \cdot 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(-3 \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 8.6000000000000002e-8 or 3e20 < x.im < 3.6999999999999997e67Initial program 84.9%
*-commutative84.9%
distribute-lft-out84.9%
associate-*l*84.9%
*-commutative84.9%
distribute-rgt-out--92.3%
associate--l-92.3%
associate--l-92.3%
sub-neg92.3%
associate--l+92.3%
fma-udef93.3%
neg-mul-193.3%
count-293.3%
associate-*l*93.3%
distribute-rgt-out--93.3%
associate-*r*93.3%
metadata-eval93.3%
Simplified93.3%
Taylor expanded in x.re around inf 71.1%
unpow271.1%
Simplified71.1%
if 8.6000000000000002e-8 < x.im < 3e20Initial program 99.1%
*-commutative99.1%
*-commutative99.1%
*-commutative99.1%
distribute-lft-out99.1%
Simplified99.1%
Taylor expanded in x.re around 0 70.8%
associate-*r*70.8%
mul-1-neg70.8%
unpow270.8%
Simplified70.8%
Taylor expanded in x.re around 0 71.0%
Simplified70.9%
if 3.6999999999999997e67 < x.im Initial program 64.1%
*-commutative64.1%
distribute-lft-out64.1%
associate-*l*64.1%
*-commutative64.1%
distribute-rgt-out--68.4%
associate--l-66.3%
associate--l-68.4%
sub-neg68.4%
associate--l+66.3%
fma-udef74.9%
neg-mul-174.9%
count-274.9%
associate-*l*74.9%
distribute-rgt-out--74.9%
associate-*r*74.9%
metadata-eval74.9%
Simplified74.9%
Taylor expanded in x.re around 0 70.4%
associate-*r*70.5%
unpow270.5%
Simplified70.5%
add-log-exp50.0%
exp-prod29.8%
exp-prod29.8%
Applied egg-rr29.8%
log-pow29.9%
associate-*l*30.6%
log-pow86.5%
Simplified86.5%
Taylor expanded in x.im around 0 86.5%
Final simplification73.8%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.re)))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
return x_46_re * (x_46_re * x_46_re);
}
NOTE: x.im should be positive before calling this function
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
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
return x_46_re * (x_46_re * x_46_re);
}
x.im = abs(x.im) def code(x_46_re, x_46_im): return x_46_re * (x_46_re * x_46_re)
x.im = abs(x.im) function code(x_46_re, x_46_im) return Float64(x_46_re * Float64(x_46_re * x_46_re)) end
x.im = abs(x.im) function tmp = code(x_46_re, x_46_im) tmp = x_46_re * (x_46_re * x_46_re); end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x.im = |x.im|\\
\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Initial program 81.5%
*-commutative81.5%
distribute-lft-out81.5%
associate-*l*81.5%
*-commutative81.5%
distribute-rgt-out--88.2%
associate--l-87.8%
associate--l-88.2%
sub-neg88.2%
associate--l+87.8%
fma-udef90.2%
neg-mul-190.2%
count-290.2%
associate-*l*90.2%
distribute-rgt-out--90.2%
associate-*r*90.2%
metadata-eval90.2%
Simplified90.2%
Taylor expanded in x.re around inf 59.6%
unpow259.6%
Simplified59.6%
Final simplification59.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 2023230
(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)))