
(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 4 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 1e+152) (* 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 <= 1e+152) {
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 <= 1d+152) 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 <= 1e+152) {
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 <= 1e+152: 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 <= 1e+152) 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 <= 1e+152) 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, 1e+152], 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 10^{+152}:\\
\;\;\;\;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 < 1e152Initial program 87.7%
*-commutative87.7%
distribute-lft-out87.7%
associate-*l*87.7%
*-commutative87.7%
distribute-rgt-out--93.0%
associate--l-93.0%
associate--l-93.0%
sub-neg93.0%
associate--l+93.0%
fma-udef96.1%
neg-mul-196.1%
count-296.1%
associate-*l*96.1%
distribute-rgt-out--96.1%
associate-*r*96.1%
metadata-eval96.1%
Simplified96.1%
fma-udef93.0%
Applied egg-rr93.0%
if 1e152 < x.im Initial program 45.6%
*-commutative45.6%
*-commutative45.6%
*-commutative45.6%
distribute-lft-out45.6%
Simplified45.6%
sub-neg45.6%
*-commutative45.6%
difference-of-squares62.3%
associate-*l*89.9%
*-commutative89.9%
distribute-rgt-neg-in89.9%
distribute-rgt-in89.9%
distribute-lft-out89.9%
Applied egg-rr89.9%
Taylor expanded in x.re around 0 62.3%
distribute-rgt-out62.3%
unpow262.3%
metadata-eval62.3%
associate-*r*62.3%
*-commutative62.3%
associate-*r*89.9%
associate-*r*89.9%
*-commutative89.9%
associate-*l*89.9%
*-commutative89.9%
Simplified89.9%
Final simplification92.6%
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
:precision binary64
(if (or (<= x.im 3.6e-34)
(and (not (<= x.im 5.7e-27))
(or (<= x.im 5.1e+16)
(and (not (<= x.im 6.2e+95)) (<= x.im 1.2e+104)))))
(* 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 <= 3.6e-34) || (!(x_46_im <= 5.7e-27) && ((x_46_im <= 5.1e+16) || (!(x_46_im <= 6.2e+95) && (x_46_im <= 1.2e+104))))) {
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 <= 3.6d-34) .or. (.not. (x_46im <= 5.7d-27)) .and. (x_46im <= 5.1d+16) .or. (.not. (x_46im <= 6.2d+95)) .and. (x_46im <= 1.2d+104)) 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 <= 3.6e-34) || (!(x_46_im <= 5.7e-27) && ((x_46_im <= 5.1e+16) || (!(x_46_im <= 6.2e+95) && (x_46_im <= 1.2e+104))))) {
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 <= 3.6e-34) or (not (x_46_im <= 5.7e-27) and ((x_46_im <= 5.1e+16) or (not (x_46_im <= 6.2e+95) and (x_46_im <= 1.2e+104)))): 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 <= 3.6e-34) || (!(x_46_im <= 5.7e-27) && ((x_46_im <= 5.1e+16) || (!(x_46_im <= 6.2e+95) && (x_46_im <= 1.2e+104))))) 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 <= 3.6e-34) || (~((x_46_im <= 5.7e-27)) && ((x_46_im <= 5.1e+16) || (~((x_46_im <= 6.2e+95)) && (x_46_im <= 1.2e+104))))) 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, 3.6e-34], And[N[Not[LessEqual[x$46$im, 5.7e-27]], $MachinePrecision], Or[LessEqual[x$46$im, 5.1e+16], And[N[Not[LessEqual[x$46$im, 6.2e+95]], $MachinePrecision], LessEqual[x$46$im, 1.2e+104]]]]], 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 3.6 \cdot 10^{-34} \lor \neg \left(x.im \leq 5.7 \cdot 10^{-27}\right) \land \left(x.im \leq 5.1 \cdot 10^{+16} \lor \neg \left(x.im \leq 6.2 \cdot 10^{+95}\right) \land x.im \leq 1.2 \cdot 10^{+104}\right):\\
\;\;\;\;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 < 3.60000000000000008e-34 or 5.6999999999999996e-27 < x.im < 5.1e16 or 6.2000000000000006e95 < x.im < 1.2e104Initial program 88.0%
*-commutative88.0%
distribute-lft-out88.0%
associate-*l*88.0%
*-commutative88.0%
distribute-rgt-out--92.0%
associate--l-92.0%
associate--l-92.0%
sub-neg92.0%
associate--l+92.0%
fma-udef95.5%
neg-mul-195.5%
count-295.5%
associate-*l*95.5%
distribute-rgt-out--95.5%
associate-*r*95.6%
metadata-eval95.6%
Simplified95.6%
fma-udef92.0%
Applied egg-rr92.0%
Taylor expanded in x.re around inf 68.2%
unpow268.2%
Simplified68.2%
if 3.60000000000000008e-34 < x.im < 5.6999999999999996e-27 or 5.1e16 < x.im < 6.2000000000000006e95 or 1.2e104 < x.im Initial program 65.4%
*-commutative65.4%
distribute-lft-out65.4%
associate-*l*65.3%
*-commutative65.3%
distribute-rgt-out--72.2%
associate--l-72.2%
associate--l-72.2%
sub-neg72.2%
associate--l+72.2%
fma-udef80.7%
neg-mul-180.7%
count-280.7%
associate-*l*80.7%
distribute-rgt-out--80.7%
associate-*r*80.7%
metadata-eval80.7%
Simplified80.7%
Taylor expanded in x.re around 0 68.7%
Simplified68.7%
Final simplification68.3%
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 2e-36)
t_0
(if (<= x.im 1.95e-26)
(* -3.0 (* x.re (* x.im x.im)))
(if (or (<= x.im 2.35e+15)
(and (not (<= x.im 8e+95)) (<= x.im 1.2e+104)))
t_0
(* x.im (* x.re (* x.im -3.0))))))))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 <= 2e-36) {
tmp = t_0;
} else if (x_46_im <= 1.95e-26) {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
} else if ((x_46_im <= 2.35e+15) || (!(x_46_im <= 8e+95) && (x_46_im <= 1.2e+104))) {
tmp = t_0;
} else {
tmp = x_46_im * (x_46_re * (x_46_im * -3.0));
}
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 <= 2d-36) then
tmp = t_0
else if (x_46im <= 1.95d-26) then
tmp = (-3.0d0) * (x_46re * (x_46im * x_46im))
else if ((x_46im <= 2.35d+15) .or. (.not. (x_46im <= 8d+95)) .and. (x_46im <= 1.2d+104)) then
tmp = t_0
else
tmp = x_46im * (x_46re * (x_46im * (-3.0d0)))
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 <= 2e-36) {
tmp = t_0;
} else if (x_46_im <= 1.95e-26) {
tmp = -3.0 * (x_46_re * (x_46_im * x_46_im));
} else if ((x_46_im <= 2.35e+15) || (!(x_46_im <= 8e+95) && (x_46_im <= 1.2e+104))) {
tmp = t_0;
} else {
tmp = x_46_im * (x_46_re * (x_46_im * -3.0));
}
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 <= 2e-36: tmp = t_0 elif x_46_im <= 1.95e-26: tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)) elif (x_46_im <= 2.35e+15) or (not (x_46_im <= 8e+95) and (x_46_im <= 1.2e+104)): tmp = t_0 else: tmp = x_46_im * (x_46_re * (x_46_im * -3.0)) 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 <= 2e-36) tmp = t_0; elseif (x_46_im <= 1.95e-26) tmp = Float64(-3.0 * Float64(x_46_re * Float64(x_46_im * x_46_im))); elseif ((x_46_im <= 2.35e+15) || (!(x_46_im <= 8e+95) && (x_46_im <= 1.2e+104))) tmp = t_0; else tmp = Float64(x_46_im * Float64(x_46_re * Float64(x_46_im * -3.0))); 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 <= 2e-36) tmp = t_0; elseif (x_46_im <= 1.95e-26) tmp = -3.0 * (x_46_re * (x_46_im * x_46_im)); elseif ((x_46_im <= 2.35e+15) || (~((x_46_im <= 8e+95)) && (x_46_im <= 1.2e+104))) tmp = t_0; else tmp = x_46_im * (x_46_re * (x_46_im * -3.0)); 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, 2e-36], t$95$0, If[LessEqual[x$46$im, 1.95e-26], N[(-3.0 * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x$46$im, 2.35e+15], And[N[Not[LessEqual[x$46$im, 8e+95]], $MachinePrecision], LessEqual[x$46$im, 1.2e+104]]], t$95$0, N[(x$46$im * N[(x$46$re * N[(x$46$im * -3.0), $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 2 \cdot 10^{-36}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.im \leq 1.95 \cdot 10^{-26}:\\
\;\;\;\;-3 \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\
\mathbf{elif}\;x.im \leq 2.35 \cdot 10^{+15} \lor \neg \left(x.im \leq 8 \cdot 10^{+95}\right) \land x.im \leq 1.2 \cdot 10^{+104}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.re \cdot \left(x.im \cdot -3\right)\right)\\
\end{array}
\end{array}
if x.im < 1.9999999999999999e-36 or 1.94999999999999993e-26 < x.im < 2.35e15 or 8.00000000000000016e95 < x.im < 1.2e104Initial program 88.0%
*-commutative88.0%
distribute-lft-out88.0%
associate-*l*88.0%
*-commutative88.0%
distribute-rgt-out--92.0%
associate--l-92.0%
associate--l-92.0%
sub-neg92.0%
associate--l+92.0%
fma-udef95.5%
neg-mul-195.5%
count-295.5%
associate-*l*95.5%
distribute-rgt-out--95.5%
associate-*r*95.6%
metadata-eval95.6%
Simplified95.6%
fma-udef92.0%
Applied egg-rr92.0%
Taylor expanded in x.re around inf 68.2%
unpow268.2%
Simplified68.2%
if 1.9999999999999999e-36 < x.im < 1.94999999999999993e-26Initial program 99.2%
*-commutative99.2%
distribute-lft-out99.2%
associate-*l*99.6%
*-commutative99.6%
distribute-rgt-out--99.6%
associate--l-99.6%
associate--l-99.6%
sub-neg99.6%
associate--l+99.6%
fma-udef99.6%
neg-mul-199.6%
count-299.6%
associate-*l*99.6%
distribute-rgt-out--99.6%
associate-*r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x.re around 0 99.6%
Simplified99.6%
if 2.35e15 < x.im < 8.00000000000000016e95 or 1.2e104 < x.im Initial program 62.9%
*-commutative62.9%
distribute-lft-out62.9%
associate-*l*62.8%
*-commutative62.8%
distribute-rgt-out--70.3%
associate--l-70.3%
associate--l-70.3%
sub-neg70.3%
associate--l+70.3%
fma-udef79.3%
neg-mul-179.3%
count-279.3%
associate-*l*79.3%
distribute-rgt-out--79.3%
associate-*r*79.3%
metadata-eval79.3%
Simplified79.3%
fma-udef70.2%
Applied egg-rr70.2%
Taylor expanded in x.re around 0 66.5%
*-commutative66.5%
unpow266.5%
associate-*r*81.5%
*-commutative81.5%
associate-*l*81.7%
associate-*r*81.7%
*-commutative81.7%
Simplified81.7%
Final simplification71.6%
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 82.8%
*-commutative82.8%
distribute-lft-out82.8%
associate-*l*82.7%
*-commutative82.7%
distribute-rgt-out--87.4%
associate--l-87.4%
associate--l-87.4%
sub-neg87.4%
associate--l+87.4%
fma-udef92.1%
neg-mul-192.1%
count-292.1%
associate-*l*92.1%
distribute-rgt-out--92.1%
associate-*r*92.1%
metadata-eval92.1%
Simplified92.1%
fma-udef87.5%
Applied egg-rr87.5%
Taylor expanded in x.re around inf 56.8%
unpow256.8%
Simplified56.8%
Final simplification56.8%
(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 2023224
(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)))