
(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 8 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 (<= x.re -8e+153)
(* 3.0 (* x.re (* x.re x.im)))
(if (<= x.re 1.7e+151)
(* x.im (- (* (* x.re x.re) 3.0) (* x.im x.im)))
(* x.re (* (* x.re x.im) 3.0)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= -8e+153) {
tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
} else if (x_46_re <= 1.7e+151) {
tmp = x_46_im * (((x_46_re * x_46_re) * 3.0) - (x_46_im * x_46_im));
} else {
tmp = x_46_re * ((x_46_re * x_46_im) * 3.0);
}
return tmp;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if (x_46re <= (-8d+153)) then
tmp = 3.0d0 * (x_46re * (x_46re * x_46im))
else if (x_46re <= 1.7d+151) then
tmp = x_46im * (((x_46re * x_46re) * 3.0d0) - (x_46im * x_46im))
else
tmp = x_46re * ((x_46re * x_46im) * 3.0d0)
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= -8e+153) {
tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
} else if (x_46_re <= 1.7e+151) {
tmp = x_46_im * (((x_46_re * x_46_re) * 3.0) - (x_46_im * x_46_im));
} else {
tmp = x_46_re * ((x_46_re * x_46_im) * 3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_re <= -8e+153: tmp = 3.0 * (x_46_re * (x_46_re * x_46_im)) elif x_46_re <= 1.7e+151: tmp = x_46_im * (((x_46_re * x_46_re) * 3.0) - (x_46_im * x_46_im)) else: tmp = x_46_re * ((x_46_re * x_46_im) * 3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_re <= -8e+153) tmp = Float64(3.0 * Float64(x_46_re * Float64(x_46_re * x_46_im))); elseif (x_46_re <= 1.7e+151) tmp = Float64(x_46_im * Float64(Float64(Float64(x_46_re * x_46_re) * 3.0) - Float64(x_46_im * x_46_im))); else tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) * 3.0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_re <= -8e+153) tmp = 3.0 * (x_46_re * (x_46_re * x_46_im)); elseif (x_46_re <= 1.7e+151) tmp = x_46_im * (((x_46_re * x_46_re) * 3.0) - (x_46_im * x_46_im)); else tmp = x_46_re * ((x_46_re * x_46_im) * 3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, -8e+153], N[(3.0 * N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 1.7e+151], N[(x$46$im * N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] * 3.0), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -8 \cdot 10^{+153}:\\
\;\;\;\;3 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\
\mathbf{elif}\;x.re \leq 1.7 \cdot 10^{+151}:\\
\;\;\;\;x.im \cdot \left(\left(x.re \cdot x.re\right) \cdot 3 - x.im \cdot x.im\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 3\right)\\
\end{array}
\end{array}
if x.re < -8e153Initial program 57.0%
Taylor expanded in x.re around 0 57.0%
associate-*r*57.0%
*-commutative57.0%
unpow257.0%
associate-*r*57.0%
Simplified57.0%
expm1-log1p-u17.9%
expm1-udef17.9%
+-commutative17.9%
*-commutative17.9%
distribute-lft-out17.9%
*-commutative17.9%
*-commutative17.9%
Applied egg-rr17.9%
expm1-def17.9%
expm1-log1p57.0%
unpow257.0%
associate-+r-57.0%
associate-*r*57.0%
unpow257.0%
*-commutative57.0%
distribute-lft1-in57.0%
metadata-eval57.0%
unpow257.0%
Simplified57.0%
Taylor expanded in x.im around 0 63.9%
unpow263.9%
associate-*l*89.5%
Simplified89.5%
if -8e153 < x.re < 1.7e151Initial program 92.3%
Taylor expanded in x.re around 0 92.2%
associate-*r*92.2%
*-commutative92.2%
unpow292.2%
associate-*r*92.2%
Simplified92.2%
expm1-log1p-u67.9%
expm1-udef45.4%
+-commutative45.4%
*-commutative45.4%
distribute-lft-out50.2%
*-commutative50.2%
*-commutative50.2%
Applied egg-rr50.2%
expm1-def72.7%
expm1-log1p99.7%
unpow299.7%
associate-+r-99.7%
associate-*r*99.7%
unpow299.7%
*-commutative99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
unpow299.7%
Simplified99.7%
if 1.7e151 < x.re Initial program 49.4%
Taylor expanded in x.re around 0 49.4%
associate-*r*49.4%
*-commutative49.4%
unpow249.4%
associate-*r*49.4%
Simplified49.4%
expm1-log1p-u16.9%
expm1-udef16.9%
+-commutative16.9%
*-commutative16.9%
distribute-lft-out16.9%
*-commutative16.9%
*-commutative16.9%
Applied egg-rr16.9%
expm1-def16.9%
expm1-log1p49.4%
unpow249.4%
associate-+r-49.4%
associate-*r*49.4%
unpow249.4%
*-commutative49.4%
distribute-lft1-in49.4%
metadata-eval49.4%
unpow249.4%
Simplified49.4%
Taylor expanded in x.im around 0 65.1%
unpow265.1%
associate-*r*65.2%
associate-*r*65.1%
associate-*l*89.4%
*-commutative89.4%
associate-*r*89.2%
*-commutative89.2%
associate-*l*89.4%
Simplified89.4%
Final simplification97.0%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(+
(* x.im (- (* x.re x.re) (* x.im x.im)))
(* x.re (+ (* x.re x.im) (* x.re x.im))))
INFINITY)
(fma (* x.im (* x.re 2.0)) x.re (* (* x.im (+ x.re x.im)) (- x.re x.im)))
(* x.im (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (((x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= ((double) INFINITY)) {
tmp = fma((x_46_im * (x_46_re * 2.0)), x_46_re, ((x_46_im * (x_46_re + x_46_im)) * (x_46_re - x_46_im)));
} else {
tmp = x_46_im * (x_46_im * -x_46_im);
}
return tmp;
}
function code(x_46_re, x_46_im) tmp = 0.0 if (Float64(Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) + Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= Inf) tmp = fma(Float64(x_46_im * Float64(x_46_re * 2.0)), x_46_re, Float64(Float64(x_46_im * Float64(x_46_re + x_46_im)) * Float64(x_46_re - x_46_im))); else tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im))); end return tmp end
code[x$46$re_, x$46$im_] := If[LessEqual[N[(N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$im * N[(x$46$re * 2.0), $MachinePrecision]), $MachinePrecision] * x$46$re + N[(N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.im \cdot \left(x.re \cdot 2\right), x.re, \left(x.im \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) < +inf.0Initial program 92.4%
Taylor expanded in x.re around 0 92.3%
associate-*r*92.3%
*-commutative92.3%
unpow292.3%
associate-*r*92.3%
Simplified92.3%
+-commutative92.3%
associate-*r*92.4%
fma-def92.5%
*-commutative92.5%
*-commutative92.5%
difference-of-squares92.5%
associate-*r*99.8%
Applied egg-rr99.8%
if +inf.0 < (+.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.im) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.re)) Initial program 0.0%
Taylor expanded in x.re around 0 0.0%
associate-*r*0.0%
*-commutative0.0%
unpow20.0%
associate-*r*0.0%
Simplified0.0%
expm1-log1p-u0.0%
expm1-udef0.0%
+-commutative0.0%
*-commutative0.0%
distribute-lft-out31.0%
*-commutative31.0%
*-commutative31.0%
Applied egg-rr31.0%
expm1-def31.0%
expm1-log1p48.3%
unpow248.3%
associate-+r-48.3%
associate-*r*48.3%
unpow248.3%
*-commutative48.3%
distribute-lft1-in48.3%
metadata-eval48.3%
unpow248.3%
Simplified48.3%
Taylor expanded in x.re around 0 72.4%
unpow272.4%
mul-1-neg72.4%
distribute-rgt-neg-in72.4%
Simplified72.4%
Final simplification96.7%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.re -8.2e+18) (not (<= x.re 4.2e-26))) (* 3.0 (* (* x.re x.re) x.im)) (* x.im (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -8.2e+18) || !(x_46_re <= 4.2e-26)) {
tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
} else {
tmp = x_46_im * (x_46_im * -x_46_im);
}
return tmp;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if ((x_46re <= (-8.2d+18)) .or. (.not. (x_46re <= 4.2d-26))) then
tmp = 3.0d0 * ((x_46re * x_46re) * x_46im)
else
tmp = x_46im * (x_46im * -x_46im)
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -8.2e+18) || !(x_46_re <= 4.2e-26)) {
tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im);
} else {
tmp = x_46_im * (x_46_im * -x_46_im);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_re <= -8.2e+18) or not (x_46_re <= 4.2e-26): tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im) else: tmp = x_46_im * (x_46_im * -x_46_im) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_re <= -8.2e+18) || !(x_46_re <= 4.2e-26)) tmp = Float64(3.0 * Float64(Float64(x_46_re * x_46_re) * x_46_im)); else tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_re <= -8.2e+18) || ~((x_46_re <= 4.2e-26))) tmp = 3.0 * ((x_46_re * x_46_re) * x_46_im); else tmp = x_46_im * (x_46_im * -x_46_im); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -8.2e+18], N[Not[LessEqual[x$46$re, 4.2e-26]], $MachinePrecision]], N[(3.0 * N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -8.2 \cdot 10^{+18} \lor \neg \left(x.re \leq 4.2 \cdot 10^{-26}\right):\\
\;\;\;\;3 \cdot \left(\left(x.re \cdot x.re\right) \cdot x.im\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\
\end{array}
\end{array}
if x.re < -8.2e18 or 4.20000000000000016e-26 < x.re Initial program 64.6%
Taylor expanded in x.re around inf 66.3%
unpow266.3%
Simplified66.3%
*-commutative66.3%
*-commutative66.3%
count-266.3%
associate-*l*66.3%
*-commutative66.3%
associate-*l*66.3%
associate-*l*66.3%
distribute-lft-in66.2%
*-commutative66.2%
distribute-rgt1-in66.2%
metadata-eval66.2%
associate-*l*66.3%
Applied egg-rr66.3%
if -8.2e18 < x.re < 4.20000000000000016e-26Initial program 99.8%
Taylor expanded in x.re around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
unpow299.8%
associate-*r*99.8%
Simplified99.8%
expm1-log1p-u76.1%
expm1-udef56.3%
+-commutative56.3%
*-commutative56.3%
distribute-lft-out56.3%
*-commutative56.3%
*-commutative56.3%
Applied egg-rr56.3%
expm1-def76.2%
expm1-log1p99.8%
unpow299.8%
associate-+r-99.8%
associate-*r*99.8%
unpow299.8%
*-commutative99.8%
distribute-lft1-in99.8%
metadata-eval99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in x.re around 0 91.1%
unpow291.1%
mul-1-neg91.1%
distribute-rgt-neg-in91.1%
Simplified91.1%
Final simplification78.5%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.re -2e+30) (not (<= x.re 4.7e-26))) (* 3.0 (* x.re (* x.re x.im))) (* x.im (* x.im (- x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -2e+30) || !(x_46_re <= 4.7e-26)) {
tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
} else {
tmp = x_46_im * (x_46_im * -x_46_im);
}
return tmp;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if ((x_46re <= (-2d+30)) .or. (.not. (x_46re <= 4.7d-26))) then
tmp = 3.0d0 * (x_46re * (x_46re * x_46im))
else
tmp = x_46im * (x_46im * -x_46im)
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -2e+30) || !(x_46_re <= 4.7e-26)) {
tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
} else {
tmp = x_46_im * (x_46_im * -x_46_im);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_re <= -2e+30) or not (x_46_re <= 4.7e-26): tmp = 3.0 * (x_46_re * (x_46_re * x_46_im)) else: tmp = x_46_im * (x_46_im * -x_46_im) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_re <= -2e+30) || !(x_46_re <= 4.7e-26)) tmp = Float64(3.0 * Float64(x_46_re * Float64(x_46_re * x_46_im))); else tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_re <= -2e+30) || ~((x_46_re <= 4.7e-26))) tmp = 3.0 * (x_46_re * (x_46_re * x_46_im)); else tmp = x_46_im * (x_46_im * -x_46_im); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -2e+30], N[Not[LessEqual[x$46$re, 4.7e-26]], $MachinePrecision]], N[(3.0 * N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -2 \cdot 10^{+30} \lor \neg \left(x.re \leq 4.7 \cdot 10^{-26}\right):\\
\;\;\;\;3 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\
\end{array}
\end{array}
if x.re < -2e30 or 4.69999999999999989e-26 < x.re Initial program 64.6%
Taylor expanded in x.re around 0 64.6%
associate-*r*64.6%
*-commutative64.6%
unpow264.6%
associate-*r*64.6%
Simplified64.6%
expm1-log1p-u33.9%
expm1-udef20.4%
+-commutative20.4%
*-commutative20.4%
distribute-lft-out27.3%
*-commutative27.3%
*-commutative27.3%
Applied egg-rr27.3%
expm1-def40.9%
expm1-log1p75.4%
unpow275.4%
associate-+r-75.4%
associate-*r*75.4%
unpow275.4%
*-commutative75.4%
distribute-lft1-in75.4%
metadata-eval75.4%
unpow275.4%
Simplified75.4%
Taylor expanded in x.im around 0 66.3%
unpow266.3%
associate-*l*79.1%
Simplified79.1%
if -2e30 < x.re < 4.69999999999999989e-26Initial program 99.8%
Taylor expanded in x.re around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
unpow299.8%
associate-*r*99.8%
Simplified99.8%
expm1-log1p-u76.1%
expm1-udef56.3%
+-commutative56.3%
*-commutative56.3%
distribute-lft-out56.3%
*-commutative56.3%
*-commutative56.3%
Applied egg-rr56.3%
expm1-def76.2%
expm1-log1p99.8%
unpow299.8%
associate-+r-99.8%
associate-*r*99.8%
unpow299.8%
*-commutative99.8%
distribute-lft1-in99.8%
metadata-eval99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in x.re around 0 91.1%
unpow291.1%
mul-1-neg91.1%
distribute-rgt-neg-in91.1%
Simplified91.1%
Final simplification85.0%
(FPCore (x.re x.im)
:precision binary64
(if (<= x.re -2.85e+18)
(* 3.0 (* x.re (* x.re x.im)))
(if (<= x.re 1.9e-27)
(* x.im (* x.im (- x.im)))
(* x.re (* (* x.re x.im) 3.0)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= -2.85e+18) {
tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
} else if (x_46_re <= 1.9e-27) {
tmp = x_46_im * (x_46_im * -x_46_im);
} else {
tmp = x_46_re * ((x_46_re * x_46_im) * 3.0);
}
return tmp;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: tmp
if (x_46re <= (-2.85d+18)) then
tmp = 3.0d0 * (x_46re * (x_46re * x_46im))
else if (x_46re <= 1.9d-27) then
tmp = x_46im * (x_46im * -x_46im)
else
tmp = x_46re * ((x_46re * x_46im) * 3.0d0)
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= -2.85e+18) {
tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
} else if (x_46_re <= 1.9e-27) {
tmp = x_46_im * (x_46_im * -x_46_im);
} else {
tmp = x_46_re * ((x_46_re * x_46_im) * 3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_re <= -2.85e+18: tmp = 3.0 * (x_46_re * (x_46_re * x_46_im)) elif x_46_re <= 1.9e-27: tmp = x_46_im * (x_46_im * -x_46_im) else: tmp = x_46_re * ((x_46_re * x_46_im) * 3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_re <= -2.85e+18) tmp = Float64(3.0 * Float64(x_46_re * Float64(x_46_re * x_46_im))); elseif (x_46_re <= 1.9e-27) tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im))); else tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) * 3.0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_re <= -2.85e+18) tmp = 3.0 * (x_46_re * (x_46_re * x_46_im)); elseif (x_46_re <= 1.9e-27) tmp = x_46_im * (x_46_im * -x_46_im); else tmp = x_46_re * ((x_46_re * x_46_im) * 3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, -2.85e+18], N[(3.0 * N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 1.9e-27], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -2.85 \cdot 10^{+18}:\\
\;\;\;\;3 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\
\mathbf{elif}\;x.re \leq 1.9 \cdot 10^{-27}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 3\right)\\
\end{array}
\end{array}
if x.re < -2.85e18Initial program 65.5%
Taylor expanded in x.re around 0 65.4%
associate-*r*65.4%
*-commutative65.4%
unpow265.4%
associate-*r*65.4%
Simplified65.4%
expm1-log1p-u25.1%
expm1-udef18.6%
+-commutative18.6%
*-commutative18.6%
distribute-lft-out24.2%
*-commutative24.2%
*-commutative24.2%
Applied egg-rr24.2%
expm1-def30.7%
expm1-log1p76.6%
unpow276.6%
associate-+r-76.6%
associate-*r*76.6%
unpow276.6%
*-commutative76.6%
distribute-lft1-in76.6%
metadata-eval76.6%
unpow276.6%
Simplified76.6%
Taylor expanded in x.im around 0 65.5%
unpow265.5%
associate-*l*79.3%
Simplified79.3%
if -2.85e18 < x.re < 1.9e-27Initial program 99.8%
Taylor expanded in x.re around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
unpow299.8%
associate-*r*99.8%
Simplified99.8%
expm1-log1p-u76.1%
expm1-udef56.3%
+-commutative56.3%
*-commutative56.3%
distribute-lft-out56.3%
*-commutative56.3%
*-commutative56.3%
Applied egg-rr56.3%
expm1-def76.2%
expm1-log1p99.8%
unpow299.8%
associate-+r-99.8%
associate-*r*99.8%
unpow299.8%
*-commutative99.8%
distribute-lft1-in99.8%
metadata-eval99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in x.re around 0 91.1%
unpow291.1%
mul-1-neg91.1%
distribute-rgt-neg-in91.1%
Simplified91.1%
if 1.9e-27 < x.re Initial program 64.0%
Taylor expanded in x.re around 0 63.9%
associate-*r*63.9%
*-commutative63.9%
unpow263.9%
associate-*r*63.9%
Simplified63.9%
expm1-log1p-u40.2%
expm1-udef21.6%
+-commutative21.6%
*-commutative21.6%
distribute-lft-out29.5%
*-commutative29.5%
*-commutative29.5%
Applied egg-rr29.5%
expm1-def48.1%
expm1-log1p74.5%
unpow274.5%
associate-+r-74.5%
associate-*r*74.5%
unpow274.5%
*-commutative74.5%
distribute-lft1-in74.5%
metadata-eval74.5%
unpow274.5%
Simplified74.5%
Taylor expanded in x.im around 0 66.8%
unpow266.8%
associate-*r*66.8%
associate-*r*66.9%
associate-*l*79.0%
*-commutative79.0%
associate-*r*78.8%
*-commutative78.8%
associate-*l*78.9%
Simplified78.9%
Final simplification85.0%
(FPCore (x.re x.im)
:precision binary64
(if (<= x.re -2.2e+25)
(* 3.0 (* x.re (* x.re x.im)))
(if (<= x.re 3.5e-29)
(* x.im (* x.im (- x.im)))
(* (* x.re x.im) (* x.re 3.0)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= -2.2e+25) {
tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
} else if (x_46_re <= 3.5e-29) {
tmp = x_46_im * (x_46_im * -x_46_im);
} else {
tmp = (x_46_re * x_46_im) * (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_46re <= (-2.2d+25)) then
tmp = 3.0d0 * (x_46re * (x_46re * x_46im))
else if (x_46re <= 3.5d-29) then
tmp = x_46im * (x_46im * -x_46im)
else
tmp = (x_46re * x_46im) * (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_re <= -2.2e+25) {
tmp = 3.0 * (x_46_re * (x_46_re * x_46_im));
} else if (x_46_re <= 3.5e-29) {
tmp = x_46_im * (x_46_im * -x_46_im);
} else {
tmp = (x_46_re * x_46_im) * (x_46_re * 3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_re <= -2.2e+25: tmp = 3.0 * (x_46_re * (x_46_re * x_46_im)) elif x_46_re <= 3.5e-29: tmp = x_46_im * (x_46_im * -x_46_im) else: tmp = (x_46_re * x_46_im) * (x_46_re * 3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_re <= -2.2e+25) tmp = Float64(3.0 * Float64(x_46_re * Float64(x_46_re * x_46_im))); elseif (x_46_re <= 3.5e-29) tmp = Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im))); else tmp = Float64(Float64(x_46_re * x_46_im) * 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_re <= -2.2e+25) tmp = 3.0 * (x_46_re * (x_46_re * x_46_im)); elseif (x_46_re <= 3.5e-29) tmp = x_46_im * (x_46_im * -x_46_im); else tmp = (x_46_re * x_46_im) * (x_46_re * 3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, -2.2e+25], N[(3.0 * N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 3.5e-29], N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -2.2 \cdot 10^{+25}:\\
\;\;\;\;3 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)\\
\mathbf{elif}\;x.re \leq 3.5 \cdot 10^{-29}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.re \cdot 3\right)\\
\end{array}
\end{array}
if x.re < -2.2000000000000001e25Initial program 65.5%
Taylor expanded in x.re around 0 65.4%
associate-*r*65.4%
*-commutative65.4%
unpow265.4%
associate-*r*65.4%
Simplified65.4%
expm1-log1p-u25.1%
expm1-udef18.6%
+-commutative18.6%
*-commutative18.6%
distribute-lft-out24.2%
*-commutative24.2%
*-commutative24.2%
Applied egg-rr24.2%
expm1-def30.7%
expm1-log1p76.6%
unpow276.6%
associate-+r-76.6%
associate-*r*76.6%
unpow276.6%
*-commutative76.6%
distribute-lft1-in76.6%
metadata-eval76.6%
unpow276.6%
Simplified76.6%
Taylor expanded in x.im around 0 65.5%
unpow265.5%
associate-*l*79.3%
Simplified79.3%
if -2.2000000000000001e25 < x.re < 3.4999999999999997e-29Initial program 99.8%
Taylor expanded in x.re around 0 99.8%
associate-*r*99.8%
*-commutative99.8%
unpow299.8%
associate-*r*99.8%
Simplified99.8%
expm1-log1p-u76.1%
expm1-udef56.3%
+-commutative56.3%
*-commutative56.3%
distribute-lft-out56.3%
*-commutative56.3%
*-commutative56.3%
Applied egg-rr56.3%
expm1-def76.2%
expm1-log1p99.8%
unpow299.8%
associate-+r-99.8%
associate-*r*99.8%
unpow299.8%
*-commutative99.8%
distribute-lft1-in99.8%
metadata-eval99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in x.re around 0 91.1%
unpow291.1%
mul-1-neg91.1%
distribute-rgt-neg-in91.1%
Simplified91.1%
if 3.4999999999999997e-29 < x.re Initial program 64.0%
Taylor expanded in x.re around inf 66.9%
unpow266.9%
Simplified66.9%
*-commutative66.9%
*-commutative66.9%
count-266.9%
associate-*l*66.9%
*-commutative66.9%
associate-*l*66.9%
associate-*l*66.8%
distribute-lft-in66.7%
distribute-rgt1-in66.7%
metadata-eval66.7%
associate-*r*66.8%
associate-*r*66.9%
*-commutative66.9%
*-commutative66.9%
associate-*l*79.0%
*-commutative79.0%
*-commutative79.0%
Applied egg-rr79.0%
Final simplification85.0%
(FPCore (x.re x.im) :precision binary64 (* x.im (* x.im (- x.im))))
double code(double x_46_re, double x_46_im) {
return x_46_im * (x_46_im * -x_46_im);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = x_46im * (x_46im * -x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
return x_46_im * (x_46_im * -x_46_im);
}
def code(x_46_re, x_46_im): return x_46_im * (x_46_im * -x_46_im)
function code(x_46_re, x_46_im) return Float64(x_46_im * Float64(x_46_im * Float64(-x_46_im))) end
function tmp = code(x_46_re, x_46_im) tmp = x_46_im * (x_46_im * -x_46_im); end
code[x$46$re_, x$46$im_] := N[(x$46$im * N[(x$46$im * (-x$46$im)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.im \cdot \left(x.im \cdot \left(-x.im\right)\right)
\end{array}
Initial program 81.9%
Taylor expanded in x.re around 0 81.9%
associate-*r*81.9%
*-commutative81.9%
unpow281.9%
associate-*r*81.9%
Simplified81.9%
expm1-log1p-u54.7%
expm1-udef38.1%
+-commutative38.1%
*-commutative38.1%
distribute-lft-out41.6%
*-commutative41.6%
*-commutative41.6%
Applied egg-rr41.6%
expm1-def58.2%
expm1-log1p87.4%
unpow287.4%
associate-+r-87.4%
associate-*r*87.4%
unpow287.4%
*-commutative87.4%
distribute-lft1-in87.4%
metadata-eval87.4%
unpow287.4%
Simplified87.4%
Taylor expanded in x.re around 0 55.7%
unpow255.7%
mul-1-neg55.7%
distribute-rgt-neg-in55.7%
Simplified55.7%
Final simplification55.7%
(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 81.9%
Taylor expanded in x.re around 0 81.9%
associate-*r*81.9%
*-commutative81.9%
unpow281.9%
associate-*r*81.9%
Simplified81.9%
+-commutative81.9%
associate-*r*81.9%
fma-def83.9%
*-commutative83.9%
*-commutative83.9%
difference-of-squares87.1%
associate-*r*93.6%
Applied egg-rr93.6%
Taylor expanded in x.im around 0 51.9%
Simplified2.7%
Final simplification2.7%
(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 2023171
(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)))