
(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 9 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+147) (* x.re (fma -3.0 (* x.im x.im) (* x.re x.re))) (* -3.0 (* x.im (* 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+147) {
tmp = x_46_re * fma(-3.0, (x_46_im * x_46_im), (x_46_re * x_46_re));
} else {
tmp = -3.0 * (x_46_im * (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+147) tmp = Float64(x_46_re * fma(-3.0, Float64(x_46_im * x_46_im), Float64(x_46_re * x_46_re))); else tmp = Float64(-3.0 * Float64(x_46_im * Float64(x_46_im * x_46_re))); end return 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+147], N[(x$46$re * N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$im * 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^{+147}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(-3, x.im \cdot x.im, x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 1.20000000000000001e147Initial program 86.6%
Simplified85.8%
Taylor expanded in x.re around 0 85.8%
associate-*r*85.8%
*-commutative85.8%
metadata-eval85.8%
distribute-rgt-out--85.8%
*-commutative85.8%
fma-def90.9%
distribute-rgt-out--90.9%
metadata-eval90.9%
unpow290.9%
associate-*r*90.8%
fma-def85.8%
cube-mult85.7%
unpow285.7%
distribute-lft-out91.6%
associate-*r*91.6%
unpow291.6%
*-commutative91.6%
fma-def91.7%
unpow291.7%
unpow291.7%
Simplified91.7%
if 1.20000000000000001e147 < x.im Initial program 53.8%
Simplified51.2%
Taylor expanded in x.re around 0 51.2%
*-commutative51.2%
associate-*r*51.2%
*-commutative51.2%
metadata-eval51.2%
distribute-rgt-out--51.2%
unpow251.2%
associate-*r*81.8%
distribute-rgt-out--81.8%
metadata-eval81.8%
*-commutative81.8%
Simplified81.8%
Taylor expanded in x.re around 0 81.9%
Taylor expanded in x.re around 0 61.5%
*-commutative61.5%
unpow261.5%
associate-*r*92.1%
*-commutative92.1%
Simplified92.1%
Final simplification91.7%
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)))
(t_1 (- t_0 (* x.im (+ (* x.im x.re) (* x.im x.re))))))
(if (<= x.re -2.55e+120)
t_0
(if (<= x.re -1.45e-98)
t_1
(if (<= x.re 2.1e-75)
(* x.im (* x.im (* x.re -3.0)))
(if (<= x.re 2e+100) t_1 t_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 t_1 = t_0 - (x_46_im * ((x_46_im * x_46_re) + (x_46_im * x_46_re)));
double tmp;
if (x_46_re <= -2.55e+120) {
tmp = t_0;
} else if (x_46_re <= -1.45e-98) {
tmp = t_1;
} else if (x_46_re <= 2.1e-75) {
tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
} else if (x_46_re <= 2e+100) {
tmp = t_1;
} else {
tmp = t_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) :: t_1
real(8) :: tmp
t_0 = x_46re * (x_46re * x_46re)
t_1 = t_0 - (x_46im * ((x_46im * x_46re) + (x_46im * x_46re)))
if (x_46re <= (-2.55d+120)) then
tmp = t_0
else if (x_46re <= (-1.45d-98)) then
tmp = t_1
else if (x_46re <= 2.1d-75) then
tmp = x_46im * (x_46im * (x_46re * (-3.0d0)))
else if (x_46re <= 2d+100) then
tmp = t_1
else
tmp = t_0
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 t_1 = t_0 - (x_46_im * ((x_46_im * x_46_re) + (x_46_im * x_46_re)));
double tmp;
if (x_46_re <= -2.55e+120) {
tmp = t_0;
} else if (x_46_re <= -1.45e-98) {
tmp = t_1;
} else if (x_46_re <= 2.1e-75) {
tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
} else if (x_46_re <= 2e+100) {
tmp = t_1;
} else {
tmp = t_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) t_1 = t_0 - (x_46_im * ((x_46_im * x_46_re) + (x_46_im * x_46_re))) tmp = 0 if x_46_re <= -2.55e+120: tmp = t_0 elif x_46_re <= -1.45e-98: tmp = t_1 elif x_46_re <= 2.1e-75: tmp = x_46_im * (x_46_im * (x_46_re * -3.0)) elif x_46_re <= 2e+100: tmp = t_1 else: tmp = t_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)) t_1 = Float64(t_0 - Float64(x_46_im * Float64(Float64(x_46_im * x_46_re) + Float64(x_46_im * x_46_re)))) tmp = 0.0 if (x_46_re <= -2.55e+120) tmp = t_0; elseif (x_46_re <= -1.45e-98) tmp = t_1; elseif (x_46_re <= 2.1e-75) tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0))); elseif (x_46_re <= 2e+100) tmp = t_1; else tmp = t_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); t_1 = t_0 - (x_46_im * ((x_46_im * x_46_re) + (x_46_im * x_46_re))); tmp = 0.0; if (x_46_re <= -2.55e+120) tmp = t_0; elseif (x_46_re <= -1.45e-98) tmp = t_1; elseif (x_46_re <= 2.1e-75) tmp = x_46_im * (x_46_im * (x_46_re * -3.0)); elseif (x_46_re <= 2e+100) tmp = t_1; else tmp = t_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]}, Block[{t$95$1 = N[(t$95$0 - N[(x$46$im * N[(N[(x$46$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$re, -2.55e+120], t$95$0, If[LessEqual[x$46$re, -1.45e-98], t$95$1, If[LessEqual[x$46$re, 2.1e-75], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 2e+100], t$95$1, t$95$0]]]]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
t_1 := t_0 - x.im \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\
\mathbf{if}\;x.re \leq -2.55 \cdot 10^{+120}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.re \leq -1.45 \cdot 10^{-98}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x.re \leq 2.1 \cdot 10^{-75}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\
\mathbf{elif}\;x.re \leq 2 \cdot 10^{+100}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x.re < -2.55000000000000014e120 or 2.00000000000000003e100 < x.re Initial program 60.8%
Simplified56.8%
Taylor expanded in x.re around 0 56.8%
associate-*r*56.8%
*-commutative56.8%
metadata-eval56.8%
distribute-rgt-out--56.8%
*-commutative56.8%
fma-def71.6%
distribute-rgt-out--71.6%
metadata-eval71.6%
unpow271.6%
associate-*r*71.6%
fma-def56.8%
cube-mult56.8%
unpow256.8%
distribute-lft-out75.7%
associate-*r*75.7%
unpow275.7%
*-commutative75.7%
fma-def75.7%
unpow275.7%
unpow275.7%
Simplified75.7%
Taylor expanded in x.im around 0 85.1%
unpow285.1%
Simplified85.1%
if -2.55000000000000014e120 < x.re < -1.45e-98 or 2.1000000000000001e-75 < x.re < 2.00000000000000003e100Initial program 95.6%
Taylor expanded in x.re around inf 87.0%
unpow287.0%
Simplified87.0%
if -1.45e-98 < x.re < 2.1000000000000001e-75Initial program 84.9%
Simplified84.8%
Taylor expanded in x.re around 0 84.8%
*-commutative84.8%
associate-*r*84.8%
*-commutative84.8%
metadata-eval84.8%
distribute-rgt-out--84.8%
unpow284.8%
associate-*r*99.7%
distribute-rgt-out--99.7%
metadata-eval99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in x.re around 0 83.8%
*-commutative83.8%
associate-*r*83.9%
*-commutative83.9%
unpow283.9%
associate-*r*98.7%
Simplified98.7%
Final simplification90.7%
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)))
(t_1 (* x.im (+ (* x.im x.re) (* x.im x.re))))
(t_2 (- t_0 t_1)))
(if (<= x.re -2.55e+120)
t_0
(if (<= x.re -2.6e-101)
t_2
(if (<= x.re 6.2e-74)
(- (* x.im (* x.im (- x.re))) t_1)
(if (<= x.re 2e+100) t_2 t_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 t_1 = x_46_im * ((x_46_im * x_46_re) + (x_46_im * x_46_re));
double t_2 = t_0 - t_1;
double tmp;
if (x_46_re <= -2.55e+120) {
tmp = t_0;
} else if (x_46_re <= -2.6e-101) {
tmp = t_2;
} else if (x_46_re <= 6.2e-74) {
tmp = (x_46_im * (x_46_im * -x_46_re)) - t_1;
} else if (x_46_re <= 2e+100) {
tmp = t_2;
} else {
tmp = t_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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = x_46re * (x_46re * x_46re)
t_1 = x_46im * ((x_46im * x_46re) + (x_46im * x_46re))
t_2 = t_0 - t_1
if (x_46re <= (-2.55d+120)) then
tmp = t_0
else if (x_46re <= (-2.6d-101)) then
tmp = t_2
else if (x_46re <= 6.2d-74) then
tmp = (x_46im * (x_46im * -x_46re)) - t_1
else if (x_46re <= 2d+100) then
tmp = t_2
else
tmp = t_0
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 t_1 = x_46_im * ((x_46_im * x_46_re) + (x_46_im * x_46_re));
double t_2 = t_0 - t_1;
double tmp;
if (x_46_re <= -2.55e+120) {
tmp = t_0;
} else if (x_46_re <= -2.6e-101) {
tmp = t_2;
} else if (x_46_re <= 6.2e-74) {
tmp = (x_46_im * (x_46_im * -x_46_re)) - t_1;
} else if (x_46_re <= 2e+100) {
tmp = t_2;
} else {
tmp = t_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) t_1 = x_46_im * ((x_46_im * x_46_re) + (x_46_im * x_46_re)) t_2 = t_0 - t_1 tmp = 0 if x_46_re <= -2.55e+120: tmp = t_0 elif x_46_re <= -2.6e-101: tmp = t_2 elif x_46_re <= 6.2e-74: tmp = (x_46_im * (x_46_im * -x_46_re)) - t_1 elif x_46_re <= 2e+100: tmp = t_2 else: tmp = t_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)) t_1 = Float64(x_46_im * Float64(Float64(x_46_im * x_46_re) + Float64(x_46_im * x_46_re))) t_2 = Float64(t_0 - t_1) tmp = 0.0 if (x_46_re <= -2.55e+120) tmp = t_0; elseif (x_46_re <= -2.6e-101) tmp = t_2; elseif (x_46_re <= 6.2e-74) tmp = Float64(Float64(x_46_im * Float64(x_46_im * Float64(-x_46_re))) - t_1); elseif (x_46_re <= 2e+100) tmp = t_2; else tmp = t_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); t_1 = x_46_im * ((x_46_im * x_46_re) + (x_46_im * x_46_re)); t_2 = t_0 - t_1; tmp = 0.0; if (x_46_re <= -2.55e+120) tmp = t_0; elseif (x_46_re <= -2.6e-101) tmp = t_2; elseif (x_46_re <= 6.2e-74) tmp = (x_46_im * (x_46_im * -x_46_re)) - t_1; elseif (x_46_re <= 2e+100) tmp = t_2; else tmp = t_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]}, Block[{t$95$1 = N[(x$46$im * N[(N[(x$46$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - t$95$1), $MachinePrecision]}, If[LessEqual[x$46$re, -2.55e+120], t$95$0, If[LessEqual[x$46$re, -2.6e-101], t$95$2, If[LessEqual[x$46$re, 6.2e-74], N[(N[(x$46$im * N[(x$46$im * (-x$46$re)), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[x$46$re, 2e+100], t$95$2, t$95$0]]]]]]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
t_0 := x.re \cdot \left(x.re \cdot x.re\right)\\
t_1 := x.im \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\
t_2 := t_0 - t_1\\
\mathbf{if}\;x.re \leq -2.55 \cdot 10^{+120}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x.re \leq -2.6 \cdot 10^{-101}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x.re \leq 6.2 \cdot 10^{-74}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.re\right)\right) - t_1\\
\mathbf{elif}\;x.re \leq 2 \cdot 10^{+100}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x.re < -2.55000000000000014e120 or 2.00000000000000003e100 < x.re Initial program 60.8%
Simplified56.8%
Taylor expanded in x.re around 0 56.8%
associate-*r*56.8%
*-commutative56.8%
metadata-eval56.8%
distribute-rgt-out--56.8%
*-commutative56.8%
fma-def71.6%
distribute-rgt-out--71.6%
metadata-eval71.6%
unpow271.6%
associate-*r*71.6%
fma-def56.8%
cube-mult56.8%
unpow256.8%
distribute-lft-out75.7%
associate-*r*75.7%
unpow275.7%
*-commutative75.7%
fma-def75.7%
unpow275.7%
unpow275.7%
Simplified75.7%
Taylor expanded in x.im around 0 85.1%
unpow285.1%
Simplified85.1%
if -2.55000000000000014e120 < x.re < -2.6000000000000001e-101 or 6.2000000000000003e-74 < x.re < 2.00000000000000003e100Initial program 95.6%
Taylor expanded in x.re around inf 87.0%
unpow287.0%
Simplified87.0%
if -2.6000000000000001e-101 < x.re < 6.2000000000000003e-74Initial program 84.9%
Taylor expanded in x.re around 0 83.9%
mul-1-neg83.9%
unpow283.9%
distribute-rgt-neg-in83.9%
Simplified83.9%
Taylor expanded in x.im around 0 83.9%
associate-*r*83.9%
mul-1-neg83.9%
unpow283.9%
distribute-rgt-neg-out83.9%
associate-*l*98.7%
Simplified98.7%
Final simplification90.8%
NOTE: x.im should be positive before calling this function
(FPCore (x.re x.im)
:precision binary64
(if (<= x.im 2.35e+126)
(-
(* x.re (- (* x.re x.re) (* x.im x.im)))
(* x.im (+ (* x.im x.re) (* x.im x.re))))
(if (<= x.im 4.7e+142)
(* x.re (* x.re x.re))
(* -3.0 (* x.im (* 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 <= 2.35e+126) {
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) + (x_46_im * x_46_re)));
} else if (x_46_im <= 4.7e+142) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_im * (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 <= 2.35d+126) then
tmp = (x_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * ((x_46im * x_46re) + (x_46im * x_46re)))
else if (x_46im <= 4.7d+142) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (-3.0d0) * (x_46im * (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 <= 2.35e+126) {
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) + (x_46_im * x_46_re)));
} else if (x_46_im <= 4.7e+142) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_im * (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 <= 2.35e+126: 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) + (x_46_im * x_46_re))) elif x_46_im <= 4.7e+142: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = -3.0 * (x_46_im * (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 <= 2.35e+126) tmp = 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_im * x_46_re) + Float64(x_46_im * x_46_re)))); elseif (x_46_im <= 4.7e+142) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(-3.0 * Float64(x_46_im * 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 <= 2.35e+126) 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) + (x_46_im * x_46_re))); elseif (x_46_im <= 4.7e+142) tmp = x_46_re * (x_46_re * x_46_re); else tmp = -3.0 * (x_46_im * (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, 2.35e+126], 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$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 4.7e+142], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$im * 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 2.35 \cdot 10^{+126}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\
\mathbf{elif}\;x.im \leq 4.7 \cdot 10^{+142}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.im < 2.3499999999999999e126Initial program 87.4%
if 2.3499999999999999e126 < x.im < 4.7e142Initial program 0.0%
Simplified0.0%
Taylor expanded in x.re around 0 0.0%
associate-*r*0.0%
*-commutative0.0%
metadata-eval0.0%
distribute-rgt-out--0.0%
*-commutative0.0%
fma-def100.0%
distribute-rgt-out--100.0%
metadata-eval100.0%
unpow2100.0%
associate-*r*100.0%
fma-def0.0%
cube-mult0.0%
unpow20.0%
distribute-lft-out100.0%
associate-*r*100.0%
unpow2100.0%
*-commutative100.0%
fma-def100.0%
unpow2100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x.im around 0 100.0%
unpow2100.0%
Simplified100.0%
if 4.7e142 < x.im Initial program 53.8%
Simplified51.2%
Taylor expanded in x.re around 0 51.2%
*-commutative51.2%
associate-*r*51.2%
*-commutative51.2%
metadata-eval51.2%
distribute-rgt-out--51.2%
unpow251.2%
associate-*r*81.8%
distribute-rgt-out--81.8%
metadata-eval81.8%
*-commutative81.8%
Simplified81.8%
Taylor expanded in x.re around 0 81.9%
Taylor expanded in x.re around 0 61.5%
*-commutative61.5%
unpow261.5%
associate-*r*92.1%
*-commutative92.1%
Simplified92.1%
Final simplification88.2%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (or (<= x.re -2.6e+18) (not (<= x.re 6.8e-69))) (* 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_re <= -2.6e+18) || !(x_46_re <= 6.8e-69)) {
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_46re <= (-2.6d+18)) .or. (.not. (x_46re <= 6.8d-69))) 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_re <= -2.6e+18) || !(x_46_re <= 6.8e-69)) {
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_re <= -2.6e+18) or not (x_46_re <= 6.8e-69): 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_re <= -2.6e+18) || !(x_46_re <= 6.8e-69)) 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_re <= -2.6e+18) || ~((x_46_re <= 6.8e-69))) 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$re, -2.6e+18], N[Not[LessEqual[x$46$re, 6.8e-69]], $MachinePrecision]], 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.re \leq -2.6 \cdot 10^{+18} \lor \neg \left(x.re \leq 6.8 \cdot 10^{-69}\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.re < -2.6e18 or 6.80000000000000016e-69 < x.re Initial program 77.0%
Simplified74.9%
Taylor expanded in x.re around 0 74.9%
associate-*r*74.9%
*-commutative74.9%
metadata-eval74.9%
distribute-rgt-out--74.9%
*-commutative74.9%
fma-def83.1%
distribute-rgt-out--83.1%
metadata-eval83.1%
unpow283.1%
associate-*r*83.1%
fma-def74.9%
cube-mult74.7%
unpow274.7%
distribute-lft-out85.1%
associate-*r*85.1%
unpow285.1%
*-commutative85.1%
fma-def85.1%
unpow285.1%
unpow285.1%
Simplified85.1%
Taylor expanded in x.im around 0 79.9%
unpow279.9%
Simplified79.9%
if -2.6e18 < x.re < 6.80000000000000016e-69Initial program 86.8%
Simplified86.7%
Taylor expanded in x.re around 0 86.8%
*-commutative86.8%
associate-*r*86.8%
*-commutative86.8%
metadata-eval86.8%
distribute-rgt-out--86.8%
unpow286.8%
associate-*r*99.7%
distribute-rgt-out--99.7%
metadata-eval99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in x.re around 0 79.7%
unpow279.7%
Simplified79.7%
Final simplification79.8%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 (if (or (<= x.re -7e+14) (not (<= x.re 5.1e-49))) (* x.re (* x.re x.re)) (* -3.0 (* x.im (* x.im x.re)))))
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -7e+14) || !(x_46_re <= 5.1e-49)) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_im * (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_46re <= (-7d+14)) .or. (.not. (x_46re <= 5.1d-49))) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (-3.0d0) * (x_46im * (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_re <= -7e+14) || !(x_46_re <= 5.1e-49)) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (x_46_im * (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_re <= -7e+14) or not (x_46_re <= 5.1e-49): tmp = x_46_re * (x_46_re * x_46_re) else: tmp = -3.0 * (x_46_im * (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_re <= -7e+14) || !(x_46_re <= 5.1e-49)) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(-3.0 * Float64(x_46_im * 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_re <= -7e+14) || ~((x_46_re <= 5.1e-49))) tmp = x_46_re * (x_46_re * x_46_re); else tmp = -3.0 * (x_46_im * (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$re, -7e+14], N[Not[LessEqual[x$46$re, 5.1e-49]], $MachinePrecision]], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$im * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x.im = |x.im|\\
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -7 \cdot 10^{+14} \lor \neg \left(x.re \leq 5.1 \cdot 10^{-49}\right):\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.im \cdot x.re\right)\right)\\
\end{array}
\end{array}
if x.re < -7e14 or 5.10000000000000026e-49 < x.re Initial program 77.3%
Simplified75.2%
Taylor expanded in x.re around 0 75.2%
associate-*r*75.2%
*-commutative75.2%
metadata-eval75.2%
distribute-rgt-out--75.2%
*-commutative75.2%
fma-def83.7%
distribute-rgt-out--83.7%
metadata-eval83.7%
unpow283.7%
associate-*r*83.7%
fma-def75.2%
cube-mult75.0%
unpow275.0%
distribute-lft-out85.9%
associate-*r*85.8%
unpow285.8%
*-commutative85.8%
fma-def85.9%
unpow285.9%
unpow285.9%
Simplified85.9%
Taylor expanded in x.im around 0 81.3%
unpow281.3%
Simplified81.3%
if -7e14 < x.re < 5.10000000000000026e-49Initial program 86.0%
Simplified85.9%
Taylor expanded in x.re around 0 85.9%
*-commutative85.9%
associate-*r*86.0%
*-commutative86.0%
metadata-eval86.0%
distribute-rgt-out--86.0%
unpow286.0%
associate-*r*99.7%
distribute-rgt-out--99.7%
metadata-eval99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in x.re around 0 99.7%
Taylor expanded in x.re around 0 77.0%
*-commutative77.0%
unpow277.0%
associate-*r*90.8%
*-commutative90.8%
Simplified90.8%
Final simplification86.0%
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.6%
Simplified80.5%
Taylor expanded in x.re around 0 80.5%
associate-*r*80.5%
*-commutative80.5%
metadata-eval80.5%
distribute-rgt-out--80.5%
*-commutative80.5%
fma-def84.8%
distribute-rgt-out--84.8%
metadata-eval84.8%
unpow284.8%
associate-*r*84.8%
fma-def80.5%
cube-mult80.4%
unpow280.4%
distribute-lft-out85.9%
associate-*r*85.9%
unpow285.9%
*-commutative85.9%
fma-def85.9%
unpow285.9%
unpow285.9%
Simplified85.9%
Taylor expanded in x.im around 0 57.8%
unpow257.8%
Simplified57.8%
Final simplification57.8%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 -38.0)
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
return -38.0;
}
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 = -38.0d0
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
return -38.0;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): return -38.0
x.im = abs(x.im) function code(x_46_re, x_46_im) return -38.0 end
x.im = abs(x.im) function tmp = code(x_46_re, x_46_im) tmp = -38.0; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := -38.0
\begin{array}{l}
x.im = |x.im|\\
\\
-38
\end{array}
Initial program 81.6%
Simplified80.5%
Taylor expanded in x.re around 0 80.5%
*-commutative80.5%
associate-*r*80.5%
*-commutative80.5%
metadata-eval80.5%
distribute-rgt-out--80.5%
unpow280.5%
associate-*r*87.4%
distribute-rgt-out--87.4%
metadata-eval87.4%
*-commutative87.4%
Simplified87.4%
Applied egg-rr2.6%
Final simplification2.6%
NOTE: x.im should be positive before calling this function (FPCore (x.re x.im) :precision binary64 0.0)
x.im = abs(x.im);
double code(double x_46_re, double x_46_im) {
return 0.0;
}
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 = 0.0d0
end function
x.im = Math.abs(x.im);
public static double code(double x_46_re, double x_46_im) {
return 0.0;
}
x.im = abs(x.im) def code(x_46_re, x_46_im): return 0.0
x.im = abs(x.im) function code(x_46_re, x_46_im) return 0.0 end
x.im = abs(x.im) function tmp = code(x_46_re, x_46_im) tmp = 0.0; end
NOTE: x.im should be positive before calling this function code[x$46$re_, x$46$im_] := 0.0
\begin{array}{l}
x.im = |x.im|\\
\\
0
\end{array}
Initial program 81.6%
Simplified80.5%
Taylor expanded in x.re around 0 80.5%
*-commutative80.5%
associate-*r*80.5%
*-commutative80.5%
metadata-eval80.5%
distribute-rgt-out--80.5%
unpow280.5%
associate-*r*87.4%
distribute-rgt-out--87.4%
metadata-eval87.4%
*-commutative87.4%
Simplified87.4%
Applied egg-rr13.5%
Final simplification13.5%
(FPCore (x.re x.im) :precision binary64 (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im)))))
double code(double x_46_re, double x_46_im) {
return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)));
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = ((x_46re * x_46re) * (x_46re - x_46im)) + ((x_46re * x_46im) * (x_46re - (3.0d0 * x_46im)))
end function
public static double code(double x_46_re, double x_46_im) {
return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)));
}
def code(x_46_re, x_46_im): return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)))
function code(x_46_re, x_46_im) return Float64(Float64(Float64(x_46_re * x_46_re) * Float64(x_46_re - x_46_im)) + Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re - Float64(3.0 * x_46_im)))) end
function tmp = code(x_46_re, x_46_im) tmp = ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im))); end
code[x$46$re_, x$46$im_] := N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re - N[(3.0 * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right)
\end{array}
herbie shell --seed 2023297
(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)))