
(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 10 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 (or (<= x.im -3.4e+119) (not (<= x.im 4e+93))) (+ -3.0 (* x.im (* (+ x.im x.re) (- x.re x.im)))) (- (* x.re (* 3.0 (* x.im x.re))) (pow x.im 3.0))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -3.4e+119) || !(x_46_im <= 4e+93)) {
tmp = -3.0 + (x_46_im * ((x_46_im + x_46_re) * (x_46_re - x_46_im)));
} else {
tmp = (x_46_re * (3.0 * (x_46_im * x_46_re))) - pow(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 <= (-3.4d+119)) .or. (.not. (x_46im <= 4d+93))) then
tmp = (-3.0d0) + (x_46im * ((x_46im + x_46re) * (x_46re - x_46im)))
else
tmp = (x_46re * (3.0d0 * (x_46im * 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 <= -3.4e+119) || !(x_46_im <= 4e+93)) {
tmp = -3.0 + (x_46_im * ((x_46_im + x_46_re) * (x_46_re - x_46_im)));
} else {
tmp = (x_46_re * (3.0 * (x_46_im * x_46_re))) - Math.pow(x_46_im, 3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -3.4e+119) or not (x_46_im <= 4e+93): tmp = -3.0 + (x_46_im * ((x_46_im + x_46_re) * (x_46_re - x_46_im))) else: tmp = (x_46_re * (3.0 * (x_46_im * x_46_re))) - math.pow(x_46_im, 3.0) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -3.4e+119) || !(x_46_im <= 4e+93)) tmp = Float64(-3.0 + Float64(x_46_im * Float64(Float64(x_46_im + x_46_re) * Float64(x_46_re - x_46_im)))); else tmp = Float64(Float64(x_46_re * Float64(3.0 * Float64(x_46_im * 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 <= -3.4e+119) || ~((x_46_im <= 4e+93))) tmp = -3.0 + (x_46_im * ((x_46_im + x_46_re) * (x_46_re - x_46_im))); else tmp = (x_46_re * (3.0 * (x_46_im * 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, -3.4e+119], N[Not[LessEqual[x$46$im, 4e+93]], $MachinePrecision]], N[(-3.0 + N[(x$46$im * N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * N[(3.0 * N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x$46$im, 3.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -3.4 \cdot 10^{+119} \lor \neg \left(x.im \leq 4 \cdot 10^{+93}\right):\\
\;\;\;\;-3 + x.im \cdot \left(\left(x.im + x.re\right) \cdot \left(x.re - x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(3 \cdot \left(x.im \cdot x.re\right)\right) - {x.im}^{3}\\
\end{array}
\end{array}
if x.im < -3.40000000000000013e119 or 4.00000000000000017e93 < x.im Initial program 68.2%
*-commutative68.2%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+75.3%
*-commutative75.3%
distribute-lft-in75.3%
Applied egg-rr75.3%
+-commutative75.3%
add-cube-cbrt75.3%
fma-def75.3%
Applied egg-rr0.0%
Simplified100.0%
if -3.40000000000000013e119 < x.im < 4.00000000000000017e93Initial program 92.6%
+-commutative92.6%
*-commutative92.6%
sub-neg92.6%
distribute-lft-in92.6%
associate-+r+92.6%
distribute-rgt-neg-out92.6%
unsub-neg92.6%
associate-*r*99.7%
distribute-rgt-out99.7%
*-commutative99.7%
count-299.7%
distribute-lft1-in99.7%
metadata-eval99.7%
*-commutative99.7%
*-commutative99.7%
associate-*r*99.7%
cube-unmult99.8%
Simplified99.8%
Taylor expanded in x.re around 0 99.8%
Final simplification99.9%
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0
(+
(* x.im (- (* x.re x.re) (* x.im x.im)))
(* x.re (+ (* x.im x.re) (* x.im x.re))))))
(if (<= t_0 4e+304)
t_0
(* x.im (+ (* (+ x.im x.re) (- x.re x.im)) (+ x.re x.re))))))
double code(double x_46_re, double x_46_im) {
double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_im * x_46_re) + (x_46_im * x_46_re)));
double tmp;
if (t_0 <= 4e+304) {
tmp = t_0;
} else {
tmp = x_46_im * (((x_46_im + x_46_re) * (x_46_re - x_46_im)) + (x_46_re + x_46_re));
}
return tmp;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: t_0
real(8) :: tmp
t_0 = (x_46im * ((x_46re * x_46re) - (x_46im * x_46im))) + (x_46re * ((x_46im * x_46re) + (x_46im * x_46re)))
if (t_0 <= 4d+304) then
tmp = t_0
else
tmp = x_46im * (((x_46im + x_46re) * (x_46re - x_46im)) + (x_46re + x_46re))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_im * x_46_re) + (x_46_im * x_46_re)));
double tmp;
if (t_0 <= 4e+304) {
tmp = t_0;
} else {
tmp = x_46_im * (((x_46_im + x_46_re) * (x_46_re - x_46_im)) + (x_46_re + x_46_re));
}
return tmp;
}
def code(x_46_re, x_46_im): t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_im * x_46_re) + (x_46_im * x_46_re))) tmp = 0 if t_0 <= 4e+304: tmp = t_0 else: tmp = x_46_im * (((x_46_im + x_46_re) * (x_46_re - x_46_im)) + (x_46_re + x_46_re)) return tmp
function code(x_46_re, x_46_im) t_0 = 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_im * x_46_re) + Float64(x_46_im * x_46_re)))) tmp = 0.0 if (t_0 <= 4e+304) tmp = t_0; else tmp = Float64(x_46_im * Float64(Float64(Float64(x_46_im + x_46_re) * Float64(x_46_re - x_46_im)) + Float64(x_46_re + x_46_re))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) t_0 = (x_46_im * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) + (x_46_re * ((x_46_im * x_46_re) + (x_46_im * x_46_re))); tmp = 0.0; if (t_0 <= 4e+304) tmp = t_0; else tmp = x_46_im * (((x_46_im + x_46_re) * (x_46_re - x_46_im)) + (x_46_re + x_46_re)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = 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$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e+304], t$95$0, N[(x$46$im * N[(N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) + x.re \cdot \left(x.im \cdot x.re + x.im \cdot x.re\right)\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{+304}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(\left(x.im + x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re + x.re\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)) < 3.9999999999999998e304Initial program 96.7%
if 3.9999999999999998e304 < (+.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 55.7%
*-commutative55.7%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+62.3%
*-commutative62.3%
distribute-lft-in62.3%
Applied egg-rr62.3%
+-commutative62.3%
distribute-rgt-out62.3%
*-commutative62.3%
distribute-lft-out71.5%
difference-of-squares91.2%
Applied egg-rr91.2%
Final simplification95.0%
(FPCore (x.re x.im)
:precision binary64
(if (<= x.im -32000000000000.0)
(* x.im (+ (+ x.re x.re) (- (* x.re (+ x.im x.re)) (* x.im (+ x.im x.re)))))
(if (<= x.im 7.8e-97)
(* (* x.im x.re) (+ x.re (+ x.re x.re)))
(* x.im (+ (* (+ x.im x.re) (- x.re x.im)) (+ x.re x.re))))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= -32000000000000.0) {
tmp = x_46_im * ((x_46_re + x_46_re) + ((x_46_re * (x_46_im + x_46_re)) - (x_46_im * (x_46_im + x_46_re))));
} else if (x_46_im <= 7.8e-97) {
tmp = (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re));
} else {
tmp = x_46_im * (((x_46_im + x_46_re) * (x_46_re - x_46_im)) + (x_46_re + x_46_re));
}
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 <= (-32000000000000.0d0)) then
tmp = x_46im * ((x_46re + x_46re) + ((x_46re * (x_46im + x_46re)) - (x_46im * (x_46im + x_46re))))
else if (x_46im <= 7.8d-97) then
tmp = (x_46im * x_46re) * (x_46re + (x_46re + x_46re))
else
tmp = x_46im * (((x_46im + x_46re) * (x_46re - x_46im)) + (x_46re + x_46re))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= -32000000000000.0) {
tmp = x_46_im * ((x_46_re + x_46_re) + ((x_46_re * (x_46_im + x_46_re)) - (x_46_im * (x_46_im + x_46_re))));
} else if (x_46_im <= 7.8e-97) {
tmp = (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re));
} else {
tmp = x_46_im * (((x_46_im + x_46_re) * (x_46_re - x_46_im)) + (x_46_re + x_46_re));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_im <= -32000000000000.0: tmp = x_46_im * ((x_46_re + x_46_re) + ((x_46_re * (x_46_im + x_46_re)) - (x_46_im * (x_46_im + x_46_re)))) elif x_46_im <= 7.8e-97: tmp = (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re)) else: tmp = x_46_im * (((x_46_im + x_46_re) * (x_46_re - x_46_im)) + (x_46_re + x_46_re)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= -32000000000000.0) tmp = Float64(x_46_im * Float64(Float64(x_46_re + x_46_re) + Float64(Float64(x_46_re * Float64(x_46_im + x_46_re)) - Float64(x_46_im * Float64(x_46_im + x_46_re))))); elseif (x_46_im <= 7.8e-97) tmp = Float64(Float64(x_46_im * x_46_re) * Float64(x_46_re + Float64(x_46_re + x_46_re))); else tmp = Float64(x_46_im * Float64(Float64(Float64(x_46_im + x_46_re) * Float64(x_46_re - x_46_im)) + Float64(x_46_re + x_46_re))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_im <= -32000000000000.0) tmp = x_46_im * ((x_46_re + x_46_re) + ((x_46_re * (x_46_im + x_46_re)) - (x_46_im * (x_46_im + x_46_re)))); elseif (x_46_im <= 7.8e-97) tmp = (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re)); else tmp = x_46_im * (((x_46_im + x_46_re) * (x_46_re - x_46_im)) + (x_46_re + x_46_re)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, -32000000000000.0], N[(x$46$im * N[(N[(x$46$re + x$46$re), $MachinePrecision] + N[(N[(x$46$re * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$im + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 7.8e-97], N[(N[(x$46$im * x$46$re), $MachinePrecision] * N[(x$46$re + N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] + N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -32000000000000:\\
\;\;\;\;x.im \cdot \left(\left(x.re + x.re\right) + \left(x.re \cdot \left(x.im + x.re\right) - x.im \cdot \left(x.im + x.re\right)\right)\right)\\
\mathbf{elif}\;x.im \leq 7.8 \cdot 10^{-97}:\\
\;\;\;\;\left(x.im \cdot x.re\right) \cdot \left(x.re + \left(x.re + x.re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(\left(x.im + x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re + x.re\right)\right)\\
\end{array}
\end{array}
if x.im < -3.2e13Initial program 86.2%
*-commutative86.2%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+82.6%
*-commutative82.6%
distribute-lft-in82.6%
Applied egg-rr82.6%
+-commutative82.6%
distribute-rgt-out82.6%
*-commutative82.6%
distribute-lft-out90.2%
difference-of-squares93.2%
Applied egg-rr93.2%
sub-neg93.2%
distribute-lft-in87.2%
+-commutative87.2%
+-commutative87.2%
Applied egg-rr87.2%
if -3.2e13 < x.im < 7.7999999999999997e-97Initial program 88.2%
Taylor expanded in x.re around inf 80.0%
Simplified80.0%
*-commutative80.0%
distribute-lft-in80.0%
*-commutative80.0%
Applied egg-rr80.0%
+-commutative80.0%
associate-*l*80.0%
*-commutative80.0%
associate-*l*91.5%
distribute-rgt-out91.6%
*-commutative91.6%
Applied egg-rr91.6%
if 7.7999999999999997e-97 < x.im Initial program 78.4%
*-commutative78.4%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+71.1%
*-commutative71.1%
distribute-lft-in71.1%
Applied egg-rr71.1%
+-commutative71.1%
distribute-rgt-out71.1%
*-commutative71.1%
distribute-lft-out75.9%
difference-of-squares91.3%
Applied egg-rr91.3%
Final simplification90.4%
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* (+ x.im x.re) (- x.re x.im))))
(if (<= x.im -31000000000000.0)
(+ -3.0 (* x.im t_0))
(if (<= x.im 7.8e-97)
(* (* x.im x.re) (+ x.re (+ x.re x.re)))
(* x.im (+ t_0 (+ x.re x.re)))))))
double code(double x_46_re, double x_46_im) {
double t_0 = (x_46_im + x_46_re) * (x_46_re - x_46_im);
double tmp;
if (x_46_im <= -31000000000000.0) {
tmp = -3.0 + (x_46_im * t_0);
} else if (x_46_im <= 7.8e-97) {
tmp = (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re));
} else {
tmp = x_46_im * (t_0 + (x_46_re + x_46_re));
}
return tmp;
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
real(8) :: t_0
real(8) :: tmp
t_0 = (x_46im + x_46re) * (x_46re - x_46im)
if (x_46im <= (-31000000000000.0d0)) then
tmp = (-3.0d0) + (x_46im * t_0)
else if (x_46im <= 7.8d-97) then
tmp = (x_46im * x_46re) * (x_46re + (x_46re + x_46re))
else
tmp = x_46im * (t_0 + (x_46re + x_46re))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double t_0 = (x_46_im + x_46_re) * (x_46_re - x_46_im);
double tmp;
if (x_46_im <= -31000000000000.0) {
tmp = -3.0 + (x_46_im * t_0);
} else if (x_46_im <= 7.8e-97) {
tmp = (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re));
} else {
tmp = x_46_im * (t_0 + (x_46_re + x_46_re));
}
return tmp;
}
def code(x_46_re, x_46_im): t_0 = (x_46_im + x_46_re) * (x_46_re - x_46_im) tmp = 0 if x_46_im <= -31000000000000.0: tmp = -3.0 + (x_46_im * t_0) elif x_46_im <= 7.8e-97: tmp = (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re)) else: tmp = x_46_im * (t_0 + (x_46_re + x_46_re)) return tmp
function code(x_46_re, x_46_im) t_0 = Float64(Float64(x_46_im + x_46_re) * Float64(x_46_re - x_46_im)) tmp = 0.0 if (x_46_im <= -31000000000000.0) tmp = Float64(-3.0 + Float64(x_46_im * t_0)); elseif (x_46_im <= 7.8e-97) tmp = Float64(Float64(x_46_im * x_46_re) * Float64(x_46_re + Float64(x_46_re + x_46_re))); else tmp = Float64(x_46_im * Float64(t_0 + Float64(x_46_re + x_46_re))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) t_0 = (x_46_im + x_46_re) * (x_46_re - x_46_im); tmp = 0.0; if (x_46_im <= -31000000000000.0) tmp = -3.0 + (x_46_im * t_0); elseif (x_46_im <= 7.8e-97) tmp = (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re)); else tmp = x_46_im * (t_0 + (x_46_re + x_46_re)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, -31000000000000.0], N[(-3.0 + N[(x$46$im * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$im, 7.8e-97], N[(N[(x$46$im * x$46$re), $MachinePrecision] * N[(x$46$re + N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(t$95$0 + N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x.im + x.re\right) \cdot \left(x.re - x.im\right)\\
\mathbf{if}\;x.im \leq -31000000000000:\\
\;\;\;\;-3 + x.im \cdot t_0\\
\mathbf{elif}\;x.im \leq 7.8 \cdot 10^{-97}:\\
\;\;\;\;\left(x.im \cdot x.re\right) \cdot \left(x.re + \left(x.re + x.re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(t_0 + \left(x.re + x.re\right)\right)\\
\end{array}
\end{array}
if x.im < -3.1e13Initial program 86.2%
*-commutative86.2%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+82.6%
*-commutative82.6%
distribute-lft-in82.6%
Applied egg-rr82.6%
+-commutative82.6%
add-cube-cbrt82.6%
fma-def82.6%
Applied egg-rr0.0%
Simplified93.2%
if -3.1e13 < x.im < 7.7999999999999997e-97Initial program 88.2%
Taylor expanded in x.re around inf 80.0%
Simplified80.0%
*-commutative80.0%
distribute-lft-in80.0%
*-commutative80.0%
Applied egg-rr80.0%
+-commutative80.0%
associate-*l*80.0%
*-commutative80.0%
associate-*l*91.5%
distribute-rgt-out91.6%
*-commutative91.6%
Applied egg-rr91.6%
if 7.7999999999999997e-97 < x.im Initial program 78.4%
*-commutative78.4%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+71.1%
*-commutative71.1%
distribute-lft-in71.1%
Applied egg-rr71.1%
+-commutative71.1%
distribute-rgt-out71.1%
*-commutative71.1%
distribute-lft-out75.9%
difference-of-squares91.3%
Applied egg-rr91.3%
Final simplification91.9%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.im -31000000000000.0) (not (<= x.im 37000000.0))) (+ -3.0 (* x.im (* (+ x.im x.re) (- x.re x.im)))) (* x.re (+ (* x.im x.re) (* (* x.im x.re) 2.0)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_im <= -31000000000000.0) || !(x_46_im <= 37000000.0)) {
tmp = -3.0 + (x_46_im * ((x_46_im + x_46_re) * (x_46_re - x_46_im)));
} else {
tmp = x_46_re * ((x_46_im * x_46_re) + ((x_46_im * x_46_re) * 2.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 <= (-31000000000000.0d0)) .or. (.not. (x_46im <= 37000000.0d0))) then
tmp = (-3.0d0) + (x_46im * ((x_46im + x_46re) * (x_46re - x_46im)))
else
tmp = x_46re * ((x_46im * x_46re) + ((x_46im * x_46re) * 2.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 <= -31000000000000.0) || !(x_46_im <= 37000000.0)) {
tmp = -3.0 + (x_46_im * ((x_46_im + x_46_re) * (x_46_re - x_46_im)));
} else {
tmp = x_46_re * ((x_46_im * x_46_re) + ((x_46_im * x_46_re) * 2.0));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_im <= -31000000000000.0) or not (x_46_im <= 37000000.0): tmp = -3.0 + (x_46_im * ((x_46_im + x_46_re) * (x_46_re - x_46_im))) else: tmp = x_46_re * ((x_46_im * x_46_re) + ((x_46_im * x_46_re) * 2.0)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_im <= -31000000000000.0) || !(x_46_im <= 37000000.0)) tmp = Float64(-3.0 + Float64(x_46_im * Float64(Float64(x_46_im + x_46_re) * Float64(x_46_re - x_46_im)))); else tmp = Float64(x_46_re * Float64(Float64(x_46_im * x_46_re) + Float64(Float64(x_46_im * x_46_re) * 2.0))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_im <= -31000000000000.0) || ~((x_46_im <= 37000000.0))) tmp = -3.0 + (x_46_im * ((x_46_im + x_46_re) * (x_46_re - x_46_im))); else tmp = x_46_re * ((x_46_im * x_46_re) + ((x_46_im * x_46_re) * 2.0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$im, -31000000000000.0], N[Not[LessEqual[x$46$im, 37000000.0]], $MachinePrecision]], N[(-3.0 + N[(x$46$im * N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(N[(x$46$im * x$46$re), $MachinePrecision] + N[(N[(x$46$im * x$46$re), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -31000000000000 \lor \neg \left(x.im \leq 37000000\right):\\
\;\;\;\;-3 + x.im \cdot \left(\left(x.im + x.re\right) \cdot \left(x.re - x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.im \cdot x.re + \left(x.im \cdot x.re\right) \cdot 2\right)\\
\end{array}
\end{array}
if x.im < -3.1e13 or 3.7e7 < x.im Initial program 79.4%
*-commutative79.4%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
+-inverses0.0%
flip-+77.1%
*-commutative77.1%
distribute-lft-in77.1%
Applied egg-rr77.1%
+-commutative77.1%
add-cube-cbrt77.1%
fma-def77.1%
Applied egg-rr0.0%
Simplified95.3%
if -3.1e13 < x.im < 3.7e7Initial program 89.9%
Taylor expanded in x.re around inf 75.1%
Simplified75.1%
*-commutative75.1%
distribute-lft-in75.1%
*-commutative75.1%
Applied egg-rr75.1%
associate-*l*84.9%
*-commutative84.9%
distribute-lft-out85.0%
*-commutative85.0%
count-285.0%
associate-*l*85.0%
*-commutative85.0%
Applied egg-rr85.0%
Final simplification90.3%
(FPCore (x.re x.im) :precision binary64 (* (* x.im x.re) (+ x.re (+ x.re x.re))))
double code(double x_46_re, double x_46_im) {
return (x_46_im * x_46_re) * (x_46_re + (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_46im * x_46re) * (x_46re + (x_46re + x_46re))
end function
public static double code(double x_46_re, double x_46_im) {
return (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re));
}
def code(x_46_re, x_46_im): return (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re))
function code(x_46_re, x_46_im) return Float64(Float64(x_46_im * x_46_re) * Float64(x_46_re + Float64(x_46_re + x_46_re))) end
function tmp = code(x_46_re, x_46_im) tmp = (x_46_im * x_46_re) * (x_46_re + (x_46_re + x_46_re)); end
code[x$46$re_, x$46$im_] := N[(N[(x$46$im * x$46$re), $MachinePrecision] * N[(x$46$re + N[(x$46$re + x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.im \cdot x.re\right) \cdot \left(x.re + \left(x.re + x.re\right)\right)
\end{array}
Initial program 84.5%
Taylor expanded in x.re around inf 49.0%
Simplified49.0%
*-commutative49.0%
distribute-lft-in49.0%
*-commutative49.0%
Applied egg-rr49.0%
+-commutative49.0%
associate-*l*49.0%
*-commutative49.0%
associate-*l*53.8%
distribute-rgt-out53.8%
*-commutative53.8%
Applied egg-rr53.8%
Final simplification53.8%
(FPCore (x.re x.im) :precision binary64 (* 3.0 (* x.im (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
return 3.0 * (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 = 3.0d0 * (x_46im * (x_46re * x_46re))
end function
public static double code(double x_46_re, double x_46_im) {
return 3.0 * (x_46_im * (x_46_re * x_46_re));
}
def code(x_46_re, x_46_im): return 3.0 * (x_46_im * (x_46_re * x_46_re))
function code(x_46_re, x_46_im) return Float64(3.0 * Float64(x_46_im * Float64(x_46_re * x_46_re))) end
function tmp = code(x_46_re, x_46_im) tmp = 3.0 * (x_46_im * (x_46_re * x_46_re)); end
code[x$46$re_, x$46$im_] := N[(3.0 * N[(x$46$im * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
3 \cdot \left(x.im \cdot \left(x.re \cdot x.re\right)\right)
\end{array}
Initial program 84.5%
+-commutative84.5%
*-commutative84.5%
sub-neg84.5%
distribute-lft-in81.8%
associate-+r+81.8%
distribute-rgt-neg-out81.8%
unsub-neg81.8%
associate-*r*86.5%
distribute-rgt-out86.5%
*-commutative86.5%
count-286.5%
distribute-lft1-in86.5%
metadata-eval86.5%
*-commutative86.5%
*-commutative86.5%
associate-*r*86.5%
cube-unmult86.6%
Simplified86.6%
Taylor expanded in x.re around 0 86.6%
associate-*r*86.6%
fma-neg88.2%
Applied egg-rr88.2%
Taylor expanded in x.re around inf 49.1%
unpow249.1%
*-commutative49.1%
Simplified49.1%
Final simplification49.1%
(FPCore (x.re x.im) :precision binary64 (* x.im (* x.re x.re)))
double code(double x_46_re, double x_46_im) {
return 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_46im * (x_46re * x_46re)
end function
public static double code(double x_46_re, double x_46_im) {
return x_46_im * (x_46_re * x_46_re);
}
def code(x_46_re, x_46_im): return x_46_im * (x_46_re * x_46_re)
function code(x_46_re, x_46_im) return Float64(x_46_im * Float64(x_46_re * x_46_re)) end
function tmp = code(x_46_re, x_46_im) tmp = x_46_im * (x_46_re * x_46_re); end
code[x$46$re_, x$46$im_] := N[(x$46$im * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.im \cdot \left(x.re \cdot x.re\right)
\end{array}
Initial program 84.5%
Taylor expanded in x.re around inf 49.0%
Simplified49.0%
*-commutative49.0%
expm1-log1p-u38.2%
expm1-udef28.9%
Applied egg-rr0.0%
Simplified19.9%
Taylor expanded in x.re around inf 34.3%
unpow234.3%
*-commutative34.3%
Simplified34.3%
Final simplification34.3%
(FPCore (x.re x.im) :precision binary64 (- x.im))
double code(double x_46_re, double x_46_im) {
return -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
end function
public static double code(double x_46_re, double x_46_im) {
return -x_46_im;
}
def code(x_46_re, x_46_im): return -x_46_im
function code(x_46_re, x_46_im) return Float64(-x_46_im) end
function tmp = code(x_46_re, x_46_im) tmp = -x_46_im; end
code[x$46$re_, x$46$im_] := (-x$46$im)
\begin{array}{l}
\\
-x.im
\end{array}
Initial program 84.5%
+-commutative84.5%
*-commutative84.5%
sub-neg84.5%
distribute-lft-in81.8%
associate-+r+81.8%
distribute-rgt-neg-out81.8%
unsub-neg81.8%
associate-*r*86.5%
distribute-rgt-out86.5%
*-commutative86.5%
count-286.5%
distribute-lft1-in86.5%
metadata-eval86.5%
*-commutative86.5%
*-commutative86.5%
associate-*r*86.5%
cube-unmult86.6%
Simplified86.6%
Taylor expanded in x.re around 0 86.6%
Taylor expanded in x.re around inf 49.1%
Simplified4.3%
Final simplification4.3%
(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 84.5%
+-commutative84.5%
*-commutative84.5%
sub-neg84.5%
distribute-lft-in81.8%
associate-+r+81.8%
distribute-rgt-neg-out81.8%
unsub-neg81.8%
associate-*r*86.5%
distribute-rgt-out86.5%
*-commutative86.5%
count-286.5%
distribute-lft1-in86.5%
metadata-eval86.5%
*-commutative86.5%
*-commutative86.5%
associate-*r*86.5%
cube-unmult86.6%
Simplified86.6%
Taylor expanded in x.re around 0 60.4%
Simplified2.8%
Final simplification2.8%
(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 2023257
(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)))