
(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 12 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
(let* ((t_0 (* (- x.re x.im) (* x.im (+ x.re x.im)))))
(if (<=
(+
(* x.im (- (* x.re x.re) (* x.im x.im)))
(* x.re (+ (* x.re x.im) (* x.re x.im))))
INFINITY)
(+ t_0 (* x.re (* x.re (+ x.im x.im))))
(+ t_0 (* x.re 0.0)))))
double code(double x_46_re, double x_46_im) {
double t_0 = (x_46_re - x_46_im) * (x_46_im * (x_46_re + 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 = t_0 + (x_46_re * (x_46_re * (x_46_im + x_46_im)));
} else {
tmp = t_0 + (x_46_re * 0.0);
}
return tmp;
}
public static double code(double x_46_re, double x_46_im) {
double t_0 = (x_46_re - x_46_im) * (x_46_im * (x_46_re + 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.POSITIVE_INFINITY) {
tmp = t_0 + (x_46_re * (x_46_re * (x_46_im + x_46_im)));
} else {
tmp = t_0 + (x_46_re * 0.0);
}
return tmp;
}
def code(x_46_re, x_46_im): t_0 = (x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im)) tmp = 0 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)))) <= math.inf: tmp = t_0 + (x_46_re * (x_46_re * (x_46_im + x_46_im))) else: tmp = t_0 + (x_46_re * 0.0) return tmp
function code(x_46_re, x_46_im) t_0 = Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(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 = Float64(t_0 + Float64(x_46_re * Float64(x_46_re * Float64(x_46_im + x_46_im)))); else tmp = Float64(t_0 + Float64(x_46_re * 0.0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) t_0 = (x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im)); tmp = 0.0; 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)))) <= Inf) tmp = t_0 + (x_46_re * (x_46_re * (x_46_im + x_46_im))); else tmp = t_0 + (x_46_re * 0.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, 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[(t$95$0 + N[(x$46$re * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(x$46$re * 0.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.re + x.im\right)\right)\\
\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:\\
\;\;\;\;t_0 + x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + x.re \cdot 0\\
\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 95.8%
add-cube-cbrt95.3%
pow395.3%
*-commutative95.3%
difference-of-squares95.3%
associate-*r*99.3%
Applied egg-rr99.3%
unpow399.2%
add-cube-cbrt99.8%
*-commutative99.8%
+-commutative99.8%
Applied egg-rr99.8%
*-commutative99.8%
distribute-lft-out99.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%
add-cube-cbrt0.0%
pow30.0%
*-commutative0.0%
difference-of-squares12.0%
associate-*r*12.0%
Applied egg-rr12.0%
unpow312.0%
add-cube-cbrt12.0%
*-commutative12.0%
+-commutative12.0%
Applied egg-rr12.0%
*-commutative12.0%
flip-+0.0%
div-sub0.0%
pow20.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
pow20.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
Applied egg-rr0.0%
+-inverses100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -2.5e-104) (not (<= x.im 6.2e-104))) (+ (* (- x.re x.im) (* x.im (+ x.re x.im))) (* x.re 0.0)) (+ (* x.re (* x.re (+ x.im x.im))) (* (* x.re x.im) (- x.re x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -2.5e-104) || !(x_46_im <= 6.2e-104)) {
tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + (x_46_re * 0.0);
} else {
tmp = (x_46_re * (x_46_re * (x_46_im + x_46_im))) + ((x_46_re * x_46_im) * (x_46_re - 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_46im <= (-2.5d-104)) .or. (.not. (x_46im <= 6.2d-104))) then
tmp = ((x_46re - x_46im) * (x_46im * (x_46re + x_46im))) + (x_46re * 0.0d0)
else
tmp = (x_46re * (x_46re * (x_46im + x_46im))) + ((x_46re * x_46im) * (x_46re - 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_im <= -2.5e-104) || !(x_46_im <= 6.2e-104)) {
tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + (x_46_re * 0.0);
} else {
tmp = (x_46_re * (x_46_re * (x_46_im + x_46_im))) + ((x_46_re * x_46_im) * (x_46_re - x_46_im));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -2.5e-104) or not (x_46_im <= 6.2e-104): tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + (x_46_re * 0.0) else: tmp = (x_46_re * (x_46_re * (x_46_im + x_46_im))) + ((x_46_re * x_46_im) * (x_46_re - x_46_im)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -2.5e-104) || !(x_46_im <= 6.2e-104)) tmp = Float64(Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(x_46_re + x_46_im))) + Float64(x_46_re * 0.0)); else tmp = Float64(Float64(x_46_re * Float64(x_46_re * Float64(x_46_im + x_46_im))) + Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re - x_46_im))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_im <= -2.5e-104) || ~((x_46_im <= 6.2e-104))) tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + (x_46_re * 0.0); else tmp = (x_46_re * (x_46_re * (x_46_im + x_46_im))) + ((x_46_re * x_46_im) * (x_46_re - x_46_im)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -2.5e-104], N[Not[LessEqual[x$46$im, 6.2e-104]], $MachinePrecision]], N[(N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * 0.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -2.5 \cdot 10^{-104} \lor \neg \left(x.im \leq 6.2 \cdot 10^{-104}\right):\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.re + x.im\right)\right) + x.re \cdot 0\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot \left(x.im + x.im\right)\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - x.im\right)\\
\end{array}
\end{array}
if x.im < -2.49999999999999989e-104 or 6.19999999999999951e-104 < x.im Initial program 83.5%
add-cube-cbrt82.8%
pow382.9%
*-commutative82.9%
difference-of-squares84.8%
associate-*r*85.4%
Applied egg-rr85.4%
unpow385.3%
add-cube-cbrt86.0%
*-commutative86.0%
+-commutative86.0%
Applied egg-rr86.0%
*-commutative86.0%
flip-+0.0%
div-sub0.0%
pow20.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
pow20.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
Applied egg-rr0.0%
+-inverses91.1%
Simplified91.1%
if -2.49999999999999989e-104 < x.im < 6.19999999999999951e-104Initial program 91.3%
add-cube-cbrt91.0%
pow391.0%
*-commutative91.0%
difference-of-squares91.0%
associate-*r*99.4%
Applied egg-rr99.4%
unpow399.4%
add-cube-cbrt99.8%
*-commutative99.8%
+-commutative99.8%
Applied egg-rr99.8%
*-commutative99.8%
distribute-lft-out99.8%
Applied egg-rr99.8%
Taylor expanded in x.im around 0 99.8%
Final simplification94.4%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -7.4e-103) (not (<= x.im 2.3e-103))) (+ (* (- x.re x.im) (* x.im (+ x.re x.im))) (* x.re 0.0)) (* x.re (* (* x.re x.im) 3.0))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -7.4e-103) || !(x_46_im <= 2.3e-103)) {
tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + (x_46_re * 0.0);
} 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_46im <= (-7.4d-103)) .or. (.not. (x_46im <= 2.3d-103))) then
tmp = ((x_46re - x_46im) * (x_46im * (x_46re + x_46im))) + (x_46re * 0.0d0)
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_im <= -7.4e-103) || !(x_46_im <= 2.3e-103)) {
tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + (x_46_re * 0.0);
} 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_im <= -7.4e-103) or not (x_46_im <= 2.3e-103): tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + (x_46_re * 0.0) 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_im <= -7.4e-103) || !(x_46_im <= 2.3e-103)) tmp = Float64(Float64(Float64(x_46_re - x_46_im) * Float64(x_46_im * Float64(x_46_re + x_46_im))) + Float64(x_46_re * 0.0)); 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_im <= -7.4e-103) || ~((x_46_im <= 2.3e-103))) tmp = ((x_46_re - x_46_im) * (x_46_im * (x_46_re + x_46_im))) + (x_46_re * 0.0); 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[Or[LessEqual[x$46$im, -7.4e-103], N[Not[LessEqual[x$46$im, 2.3e-103]], $MachinePrecision]], N[(N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x$46$re * 0.0), $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.im \leq -7.4 \cdot 10^{-103} \lor \neg \left(x.im \leq 2.3 \cdot 10^{-103}\right):\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(x.im \cdot \left(x.re + x.im\right)\right) + x.re \cdot 0\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 3\right)\\
\end{array}
\end{array}
if x.im < -7.3999999999999999e-103 or 2.3000000000000001e-103 < x.im Initial program 83.5%
add-cube-cbrt82.8%
pow382.9%
*-commutative82.9%
difference-of-squares84.8%
associate-*r*85.4%
Applied egg-rr85.4%
unpow385.3%
add-cube-cbrt86.0%
*-commutative86.0%
+-commutative86.0%
Applied egg-rr86.0%
*-commutative86.0%
flip-+0.0%
div-sub0.0%
pow20.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
pow20.0%
*-commutative0.0%
*-commutative0.0%
*-commutative0.0%
Applied egg-rr0.0%
+-inverses91.1%
Simplified91.1%
if -7.3999999999999999e-103 < x.im < 2.3000000000000001e-103Initial program 91.3%
add-cube-cbrt91.0%
pow391.0%
*-commutative91.0%
difference-of-squares91.0%
associate-*r*99.4%
Applied egg-rr99.4%
unpow399.4%
add-cube-cbrt99.8%
*-commutative99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x.re around inf 91.2%
distribute-rgt1-in91.2%
metadata-eval91.2%
*-commutative91.2%
associate-*r*91.2%
unpow291.2%
associate-*r*99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification94.4%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -15000000000.0) (not (<= x.im 4.5e+22))) (+ (+ x.im x.im) (* (* x.im x.im) (- x.re 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_im <= -15000000000.0) || !(x_46_im <= 4.5e+22)) {
tmp = (x_46_im + x_46_im) + ((x_46_im * x_46_im) * (x_46_re - 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_46im <= (-15000000000.0d0)) .or. (.not. (x_46im <= 4.5d+22))) then
tmp = (x_46im + x_46im) + ((x_46im * x_46im) * (x_46re - 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_im <= -15000000000.0) || !(x_46_im <= 4.5e+22)) {
tmp = (x_46_im + x_46_im) + ((x_46_im * x_46_im) * (x_46_re - 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_im <= -15000000000.0) or not (x_46_im <= 4.5e+22): tmp = (x_46_im + x_46_im) + ((x_46_im * x_46_im) * (x_46_re - 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_im <= -15000000000.0) || !(x_46_im <= 4.5e+22)) tmp = Float64(Float64(x_46_im + x_46_im) + Float64(Float64(x_46_im * x_46_im) * Float64(x_46_re - 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_im <= -15000000000.0) || ~((x_46_im <= 4.5e+22))) tmp = (x_46_im + x_46_im) + ((x_46_im * x_46_im) * (x_46_re - 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[Or[LessEqual[x$46$im, -15000000000.0], N[Not[LessEqual[x$46$im, 4.5e+22]], $MachinePrecision]], N[(N[(x$46$im + x$46$im), $MachinePrecision] + N[(N[(x$46$im * x$46$im), $MachinePrecision] * N[(x$46$re - 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.im \leq -15000000000 \lor \neg \left(x.im \leq 4.5 \cdot 10^{+22}\right):\\
\;\;\;\;\left(x.im + x.im\right) + \left(x.im \cdot x.im\right) \cdot \left(x.re - 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.im < -1.5e10 or 4.4999999999999998e22 < x.im Initial program 76.2%
+-commutative76.2%
*-commutative76.2%
fma-def80.9%
*-commutative80.9%
distribute-rgt-out80.9%
*-commutative80.9%
Simplified80.9%
fma-udef76.2%
distribute-lft-in76.2%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+84.3%
distribute-lft-in84.3%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+88.1%
difference-of-squares97.6%
associate-*r*97.6%
Applied egg-rr97.6%
Taylor expanded in x.im around inf 84.6%
unpow284.6%
Simplified84.6%
if -1.5e10 < x.im < 4.4999999999999998e22Initial program 93.7%
add-cube-cbrt93.0%
pow393.1%
*-commutative93.1%
difference-of-squares93.1%
associate-*r*99.1%
Applied egg-rr99.1%
unpow399.1%
add-cube-cbrt99.7%
*-commutative99.7%
+-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in x.re around inf 76.6%
distribute-rgt1-in76.6%
metadata-eval76.6%
*-commutative76.6%
associate-*r*76.6%
unpow276.6%
associate-*r*82.7%
associate-*l*82.8%
*-commutative82.8%
Simplified82.8%
Final simplification83.5%
(FPCore (x.re x.im) :precision binary64 (* 2.0 (* x.re (* x.re x.im))))
double code(double x_46_re, double x_46_im) {
return 2.0 * (x_46_re * (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 = 2.0d0 * (x_46re * (x_46re * x_46im))
end function
public static double code(double x_46_re, double x_46_im) {
return 2.0 * (x_46_re * (x_46_re * x_46_im));
}
def code(x_46_re, x_46_im): return 2.0 * (x_46_re * (x_46_re * x_46_im))
function code(x_46_re, x_46_im) return Float64(2.0 * Float64(x_46_re * Float64(x_46_re * x_46_im))) end
function tmp = code(x_46_re, x_46_im) tmp = 2.0 * (x_46_re * (x_46_re * x_46_im)); end
code[x$46$re_, x$46$im_] := N[(2.0 * N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \left(x.re \cdot \left(x.re \cdot x.im\right)\right)
\end{array}
Initial program 86.5%
add-cube-cbrt86.0%
pow386.0%
*-commutative86.0%
difference-of-squares87.2%
associate-*r*90.7%
Applied egg-rr90.7%
Taylor expanded in x.im around 0 36.4%
*-commutative36.4%
unpow236.4%
associate-*r*36.9%
Simplified36.9%
Final simplification36.9%
(FPCore (x.re x.im) :precision binary64 (* x.im (* (* x.re x.re) 3.0)))
double code(double x_46_re, double x_46_im) {
return x_46_im * ((x_46_re * x_46_re) * 3.0);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = x_46im * ((x_46re * x_46re) * 3.0d0)
end function
public static double code(double x_46_re, double x_46_im) {
return x_46_im * ((x_46_re * x_46_re) * 3.0);
}
def code(x_46_re, x_46_im): return x_46_im * ((x_46_re * x_46_re) * 3.0)
function code(x_46_re, x_46_im) return Float64(x_46_im * Float64(Float64(x_46_re * x_46_re) * 3.0)) end
function tmp = code(x_46_re, x_46_im) tmp = x_46_im * ((x_46_re * x_46_re) * 3.0); end
code[x$46$re_, x$46$im_] := N[(x$46$im * N[(N[(x$46$re * x$46$re), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.im \cdot \left(\left(x.re \cdot x.re\right) \cdot 3\right)
\end{array}
Initial program 86.5%
Taylor expanded in x.re around inf 53.0%
Simplified53.0%
Taylor expanded in x.im around 0 52.9%
*-commutative52.9%
distribute-lft1-in52.9%
metadata-eval52.9%
unpow252.9%
Simplified52.9%
Final simplification52.9%
(FPCore (x.re x.im) :precision binary64 (* x.re (* (* x.re x.im) 3.0)))
double code(double x_46_re, double x_46_im) {
return x_46_re * ((x_46_re * x_46_im) * 3.0);
}
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) * 3.0d0)
end function
public static double code(double x_46_re, double x_46_im) {
return x_46_re * ((x_46_re * x_46_im) * 3.0);
}
def code(x_46_re, x_46_im): return x_46_re * ((x_46_re * x_46_im) * 3.0)
function code(x_46_re, x_46_im) return Float64(x_46_re * Float64(Float64(x_46_re * x_46_im) * 3.0)) end
function tmp = code(x_46_re, x_46_im) tmp = x_46_re * ((x_46_re * x_46_im) * 3.0); end
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot \left(\left(x.re \cdot x.im\right) \cdot 3\right)
\end{array}
Initial program 86.5%
add-cube-cbrt86.0%
pow386.0%
*-commutative86.0%
difference-of-squares87.2%
associate-*r*90.7%
Applied egg-rr90.7%
unpow390.7%
add-cube-cbrt91.2%
*-commutative91.2%
+-commutative91.2%
Applied egg-rr91.2%
Taylor expanded in x.re around inf 52.9%
distribute-rgt1-in52.9%
metadata-eval52.9%
*-commutative52.9%
associate-*r*52.9%
unpow252.9%
associate-*r*56.5%
associate-*l*56.5%
*-commutative56.5%
Simplified56.5%
Final simplification56.5%
(FPCore (x.re x.im) :precision binary64 (* (* x.re x.re) x.im))
double code(double x_46_re, double x_46_im) {
return (x_46_re * 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
end function
public static double code(double x_46_re, double x_46_im) {
return (x_46_re * x_46_re) * x_46_im;
}
def code(x_46_re, x_46_im): return (x_46_re * x_46_re) * x_46_im
function code(x_46_re, x_46_im) return Float64(Float64(x_46_re * 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; end
code[x$46$re_, x$46$im_] := N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re\right) \cdot x.im
\end{array}
Initial program 86.5%
*-commutative86.5%
*-commutative86.5%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+66.7%
distribute-lft-in66.7%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+50.0%
Applied egg-rr50.0%
Taylor expanded in x.re around inf 35.9%
*-commutative35.9%
unpow235.9%
Simplified35.9%
Final simplification35.9%
(FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.im)))
double code(double x_46_re, double x_46_im) {
return x_46_re * (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)
end function
public static double code(double x_46_re, double x_46_im) {
return x_46_re * (x_46_re * x_46_im);
}
def code(x_46_re, x_46_im): return x_46_re * (x_46_re * x_46_im)
function code(x_46_re, x_46_im) return Float64(x_46_re * Float64(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); end
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot \left(x.re \cdot x.im\right)
\end{array}
Initial program 86.5%
*-commutative86.5%
*-commutative86.5%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+66.7%
distribute-lft-in66.7%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+50.0%
Applied egg-rr50.0%
Taylor expanded in x.re around inf 35.9%
*-commutative35.9%
unpow235.9%
associate-*r*36.3%
Simplified36.3%
Final simplification36.3%
(FPCore (x.re x.im) :precision binary64 -10.0)
double code(double x_46_re, double x_46_im) {
return -10.0;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = -10.0d0
end function
public static double code(double x_46_re, double x_46_im) {
return -10.0;
}
def code(x_46_re, x_46_im): return -10.0
function code(x_46_re, x_46_im) return -10.0 end
function tmp = code(x_46_re, x_46_im) tmp = -10.0; end
code[x$46$re_, x$46$im_] := -10.0
\begin{array}{l}
\\
-10
\end{array}
Initial program 86.5%
+-commutative86.5%
*-commutative86.5%
sub-neg86.5%
distribute-lft-in84.5%
associate-+r+84.5%
distribute-rgt-neg-out84.5%
unsub-neg84.5%
associate-*r*88.1%
distribute-rgt-out88.1%
*-commutative88.1%
count-288.1%
distribute-lft1-in88.1%
metadata-eval88.1%
*-commutative88.1%
*-commutative88.1%
associate-*r*88.1%
cube-unmult88.1%
Simplified88.1%
associate-*r*88.2%
associate-*l*88.2%
flip--23.7%
div-inv23.4%
swap-sqr23.3%
pow223.3%
metadata-eval23.3%
pow-prod-up23.3%
metadata-eval23.3%
associate-*l*23.2%
associate-*r*23.2%
fma-def23.2%
Applied egg-rr23.2%
Simplified2.8%
Final simplification2.8%
(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 86.5%
Taylor expanded in x.re around 0 61.5%
Simplified2.8%
Final simplification2.8%
(FPCore (x.re x.im) :precision binary64 0.1)
double code(double x_46_re, double x_46_im) {
return 0.1;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = 0.1d0
end function
public static double code(double x_46_re, double x_46_im) {
return 0.1;
}
def code(x_46_re, x_46_im): return 0.1
function code(x_46_re, x_46_im) return 0.1 end
function tmp = code(x_46_re, x_46_im) tmp = 0.1; end
code[x$46$re_, x$46$im_] := 0.1
\begin{array}{l}
\\
0.1
\end{array}
Initial program 86.5%
+-commutative86.5%
*-commutative86.5%
sub-neg86.5%
distribute-lft-in84.5%
associate-+r+84.5%
distribute-rgt-neg-out84.5%
unsub-neg84.5%
associate-*r*88.1%
distribute-rgt-out88.1%
*-commutative88.1%
count-288.1%
distribute-lft1-in88.1%
metadata-eval88.1%
*-commutative88.1%
*-commutative88.1%
associate-*r*88.1%
cube-unmult88.1%
Simplified88.1%
sub-neg88.1%
associate-*r*88.2%
associate-*l*88.2%
flip3-+16.5%
associate-*r*16.1%
associate-*r*16.1%
unpow-prod-down10.7%
pow210.7%
pow-pow10.7%
metadata-eval10.7%
Applied egg-rr10.7%
Simplified2.9%
Final simplification2.9%
(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 2023199
(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)))