
(FPCore (x.re x.im) :precision binary64 (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im): return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
function code(x_46_re, x_46_im) return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im)) end
function tmp = code(x_46_re, x_46_im) tmp = (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im); end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im) :precision binary64 (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = (((x_46re * x_46re) - (x_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)
end function
public static double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
def code(x_46_re, x_46_im): return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)
function code(x_46_re, x_46_im) return Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im)) end
function tmp = code(x_46_re, x_46_im) tmp = (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im); end
code[x$46$re_, x$46$im_] := N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im
\end{array}
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.im (+ (* x.re x.im) (* x.re x.im)))))
(if (<= (- (* x.re (- (* x.re x.re) (* x.im x.im))) t_0) INFINITY)
(- (* (* x.re (- x.re x.im)) (+ x.re x.im)) t_0)
(- (* x.re (* (- x.re x.im) (+ x.re x.im))) (* x.im -3.0)))))
double code(double x_46_re, double x_46_im) {
double t_0 = x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im));
double tmp;
if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - t_0) <= ((double) INFINITY)) {
tmp = ((x_46_re * (x_46_re - x_46_im)) * (x_46_re + x_46_im)) - t_0;
} else {
tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.0);
}
return tmp;
}
public static double code(double x_46_re, double x_46_im) {
double t_0 = x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im));
double tmp;
if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - t_0) <= Double.POSITIVE_INFINITY) {
tmp = ((x_46_re * (x_46_re - x_46_im)) * (x_46_re + x_46_im)) - t_0;
} else {
tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): t_0 = x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)) tmp = 0 if ((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - t_0) <= math.inf: tmp = ((x_46_re * (x_46_re - x_46_im)) * (x_46_re + x_46_im)) - t_0 else: tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.0) return tmp
function code(x_46_re, x_46_im) t_0 = Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im))) tmp = 0.0 if (Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - t_0) <= Inf) tmp = Float64(Float64(Float64(x_46_re * Float64(x_46_re - x_46_im)) * Float64(x_46_re + x_46_im)) - t_0); else tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im))) - Float64(x_46_im * -3.0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) t_0 = x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)); tmp = 0.0; if (((x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - t_0) <= Inf) tmp = ((x_46_re * (x_46_re - x_46_im)) * (x_46_re + x_46_im)) - t_0; else tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], Infinity], N[(N[(N[(x$46$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(x$46$re * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right)\\
\mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - t_0 \leq \infty:\\
\;\;\;\;\left(x.re \cdot \left(x.re - x.im\right)\right) \cdot \left(x.re + x.im\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) - x.im \cdot -3\\
\end{array}
\end{array}
if (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) < +inf.0Initial program 91.4%
difference-of-squares91.4%
*-commutative91.4%
Applied egg-rr91.4%
*-commutative91.4%
distribute-rgt-in90.5%
distribute-rgt-in84.1%
Applied egg-rr84.1%
*-commutative84.1%
associate-*l*88.8%
*-commutative88.8%
distribute-rgt-out99.7%
Applied egg-rr99.7%
if +inf.0 < (-.f64 (*.f64 (-.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)) x.re) (*.f64 (+.f64 (*.f64 x.re x.im) (*.f64 x.im x.re)) x.im)) Initial program 0.0%
difference-of-squares25.0%
*-commutative25.0%
Applied egg-rr25.0%
*-commutative25.0%
flip-+0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
*-commutative0.0%
*-commutative0.0%
distribute-neg-frac0.0%
*-commutative0.0%
+-inverses0.0%
+-inverses0.0%
*-commutative0.0%
flip-+75.0%
*-commutative75.0%
neg-sub075.0%
*-commutative75.0%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.re (* (- x.re x.im) (+ x.re x.im)))))
(if (or (<= x.re -1e+119) (not (<= x.re 1e+82)))
(- t_0 (* x.im -3.0))
(- t_0 (* x.im (* (* x.re x.im) 2.0))))))
double code(double x_46_re, double x_46_im) {
double t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
double tmp;
if ((x_46_re <= -1e+119) || !(x_46_re <= 1e+82)) {
tmp = t_0 - (x_46_im * -3.0);
} else {
tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 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) :: t_0
real(8) :: tmp
t_0 = x_46re * ((x_46re - x_46im) * (x_46re + x_46im))
if ((x_46re <= (-1d+119)) .or. (.not. (x_46re <= 1d+82))) then
tmp = t_0 - (x_46im * (-3.0d0))
else
tmp = t_0 - (x_46im * ((x_46re * x_46im) * 2.0d0))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
double tmp;
if ((x_46_re <= -1e+119) || !(x_46_re <= 1e+82)) {
tmp = t_0 - (x_46_im * -3.0);
} else {
tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0));
}
return tmp;
}
def code(x_46_re, x_46_im): t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im)) tmp = 0 if (x_46_re <= -1e+119) or not (x_46_re <= 1e+82): tmp = t_0 - (x_46_im * -3.0) else: tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0)) return tmp
function code(x_46_re, x_46_im) t_0 = Float64(x_46_re * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im))) tmp = 0.0 if ((x_46_re <= -1e+119) || !(x_46_re <= 1e+82)) tmp = Float64(t_0 - Float64(x_46_im * -3.0)); else tmp = Float64(t_0 - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * 2.0))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im)); tmp = 0.0; if ((x_46_re <= -1e+119) || ~((x_46_re <= 1e+82))) tmp = t_0 - (x_46_im * -3.0); else tmp = t_0 - (x_46_im * ((x_46_re * x_46_im) * 2.0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[x$46$re, -1e+119], N[Not[LessEqual[x$46$re, 1e+82]], $MachinePrecision]], N[(t$95$0 - N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)\\
\mathbf{if}\;x.re \leq -1 \cdot 10^{+119} \lor \neg \left(x.re \leq 10^{+82}\right):\\
\;\;\;\;t_0 - x.im \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t_0 - x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)\\
\end{array}
\end{array}
if x.re < -9.99999999999999944e118 or 9.9999999999999996e81 < x.re Initial program 59.1%
difference-of-squares69.3%
*-commutative69.3%
Applied egg-rr69.3%
*-commutative69.3%
flip-+0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
*-commutative0.0%
*-commutative0.0%
distribute-neg-frac0.0%
*-commutative0.0%
+-inverses0.0%
+-inverses0.0%
*-commutative0.0%
flip-+82.9%
*-commutative82.9%
neg-sub082.9%
*-commutative82.9%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified100.0%
if -9.99999999999999944e118 < x.re < 9.9999999999999996e81Initial program 88.7%
difference-of-squares88.7%
*-commutative88.7%
Applied egg-rr88.7%
*-commutative33.4%
*-un-lft-identity33.4%
*-un-lft-identity33.4%
distribute-rgt-out33.4%
*-commutative33.4%
metadata-eval33.4%
Applied egg-rr88.7%
Final simplification92.6%
(FPCore (x.re x.im) :precision binary64 (if (or (<= x.re -1.8e-96) (not (<= x.re 5.2e-78))) (- (* x.re (* (- x.re x.im) (+ x.re x.im))) (* x.im -3.0)) (- (* (* x.re x.im) -27.0) (* x.im (* (* x.re x.im) 2.0)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if ((x_46_re <= -1.8e-96) || !(x_46_re <= 5.2e-78)) {
tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.0);
} else {
tmp = ((x_46_re * x_46_im) * -27.0) - (x_46_im * ((x_46_re * x_46_im) * 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_46re <= (-1.8d-96)) .or. (.not. (x_46re <= 5.2d-78))) then
tmp = (x_46re * ((x_46re - x_46im) * (x_46re + x_46im))) - (x_46im * (-3.0d0))
else
tmp = ((x_46re * x_46im) * (-27.0d0)) - (x_46im * ((x_46re * x_46im) * 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_re <= -1.8e-96) || !(x_46_re <= 5.2e-78)) {
tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.0);
} else {
tmp = ((x_46_re * x_46_im) * -27.0) - (x_46_im * ((x_46_re * x_46_im) * 2.0));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if (x_46_re <= -1.8e-96) or not (x_46_re <= 5.2e-78): tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.0) else: tmp = ((x_46_re * x_46_im) * -27.0) - (x_46_im * ((x_46_re * x_46_im) * 2.0)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if ((x_46_re <= -1.8e-96) || !(x_46_re <= 5.2e-78)) tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im))) - Float64(x_46_im * -3.0)); else tmp = Float64(Float64(Float64(x_46_re * x_46_im) * -27.0) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * 2.0))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if ((x_46_re <= -1.8e-96) || ~((x_46_re <= 5.2e-78))) tmp = (x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im))) - (x_46_im * -3.0); else tmp = ((x_46_re * x_46_im) * -27.0) - (x_46_im * ((x_46_re * x_46_im) * 2.0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[Or[LessEqual[x$46$re, -1.8e-96], N[Not[LessEqual[x$46$re, 5.2e-78]], $MachinePrecision]], N[(N[(x$46$re * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] * -27.0), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1.8 \cdot 10^{-96} \lor \neg \left(x.re \leq 5.2 \cdot 10^{-78}\right):\\
\;\;\;\;x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right) - x.im \cdot -3\\
\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot -27 - x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)\\
\end{array}
\end{array}
if x.re < -1.80000000000000004e-96 or 5.2000000000000002e-78 < x.re Initial program 77.1%
difference-of-squares82.6%
*-commutative82.6%
Applied egg-rr82.6%
*-commutative82.6%
flip-+0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
*-commutative0.0%
*-commutative0.0%
distribute-neg-frac0.0%
*-commutative0.0%
+-inverses0.0%
+-inverses0.0%
*-commutative0.0%
flip-+71.2%
*-commutative71.2%
neg-sub071.2%
*-commutative71.2%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified85.6%
if -1.80000000000000004e-96 < x.re < 5.2000000000000002e-78Initial program 81.1%
difference-of-squares81.1%
Applied egg-rr81.1%
Simplified38.0%
Taylor expanded in x.re around 0 43.1%
*-commutative43.1%
*-un-lft-identity43.1%
*-un-lft-identity43.1%
distribute-rgt-out43.1%
*-commutative43.1%
metadata-eval43.1%
Applied egg-rr43.1%
Final simplification70.0%
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* x.re (* (- x.re x.im) (+ x.re x.im)))))
(if (<= x.im 6.4e+30)
(+ t_0 (* x.im (* x.re x.im)))
(- t_0 (* x.im -3.0)))))
double code(double x_46_re, double x_46_im) {
double t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
double tmp;
if (x_46_im <= 6.4e+30) {
tmp = t_0 + (x_46_im * (x_46_re * x_46_im));
} else {
tmp = t_0 - (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) :: t_0
real(8) :: tmp
t_0 = x_46re * ((x_46re - x_46im) * (x_46re + x_46im))
if (x_46im <= 6.4d+30) then
tmp = t_0 + (x_46im * (x_46re * x_46im))
else
tmp = t_0 - (x_46im * (-3.0d0))
end if
code = tmp
end function
public static double code(double x_46_re, double x_46_im) {
double t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im));
double tmp;
if (x_46_im <= 6.4e+30) {
tmp = t_0 + (x_46_im * (x_46_re * x_46_im));
} else {
tmp = t_0 - (x_46_im * -3.0);
}
return tmp;
}
def code(x_46_re, x_46_im): t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im)) tmp = 0 if x_46_im <= 6.4e+30: tmp = t_0 + (x_46_im * (x_46_re * x_46_im)) else: tmp = t_0 - (x_46_im * -3.0) return tmp
function code(x_46_re, x_46_im) t_0 = Float64(x_46_re * Float64(Float64(x_46_re - x_46_im) * Float64(x_46_re + x_46_im))) tmp = 0.0 if (x_46_im <= 6.4e+30) tmp = Float64(t_0 + Float64(x_46_im * Float64(x_46_re * x_46_im))); else tmp = Float64(t_0 - Float64(x_46_im * -3.0)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) t_0 = x_46_re * ((x_46_re - x_46_im) * (x_46_re + x_46_im)); tmp = 0.0; if (x_46_im <= 6.4e+30) tmp = t_0 + (x_46_im * (x_46_re * x_46_im)); else tmp = t_0 - (x_46_im * -3.0); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(x$46$re * N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$46$im, 6.4e+30], N[(t$95$0 + N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.re \cdot \left(\left(x.re - x.im\right) \cdot \left(x.re + x.im\right)\right)\\
\mathbf{if}\;x.im \leq 6.4 \cdot 10^{+30}:\\
\;\;\;\;t_0 + x.im \cdot \left(x.re \cdot x.im\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 - x.im \cdot -3\\
\end{array}
\end{array}
if x.im < 6.39999999999999945e30Initial program 88.4%
difference-of-squares89.9%
*-commutative89.9%
Applied egg-rr89.9%
Taylor expanded in x.re around 0 89.9%
Simplified71.2%
if 6.39999999999999945e30 < x.im Initial program 45.0%
difference-of-squares55.3%
*-commutative55.3%
Applied egg-rr55.3%
*-commutative55.3%
flip-+0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
*-commutative0.0%
*-commutative0.0%
distribute-neg-frac0.0%
*-commutative0.0%
+-inverses0.0%
+-inverses0.0%
*-commutative0.0%
flip-+24.7%
*-commutative24.7%
neg-sub024.7%
*-commutative24.7%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified53.9%
Final simplification67.3%
(FPCore (x.re x.im) :precision binary64 (if (<= x.re 4.1e+186) (- (* (* x.re x.im) -27.0) (* x.im (* (* x.re x.im) 2.0))) (* x.im (* x.re (- x.re 27.0)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= 4.1e+186) {
tmp = ((x_46_re * x_46_im) * -27.0) - (x_46_im * ((x_46_re * x_46_im) * 2.0));
} else {
tmp = x_46_im * (x_46_re * (x_46_re - 27.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 <= 4.1d+186) then
tmp = ((x_46re * x_46im) * (-27.0d0)) - (x_46im * ((x_46re * x_46im) * 2.0d0))
else
tmp = x_46im * (x_46re * (x_46re - 27.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 <= 4.1e+186) {
tmp = ((x_46_re * x_46_im) * -27.0) - (x_46_im * ((x_46_re * x_46_im) * 2.0));
} else {
tmp = x_46_im * (x_46_re * (x_46_re - 27.0));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_re <= 4.1e+186: tmp = ((x_46_re * x_46_im) * -27.0) - (x_46_im * ((x_46_re * x_46_im) * 2.0)) else: tmp = x_46_im * (x_46_re * (x_46_re - 27.0)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_re <= 4.1e+186) tmp = Float64(Float64(Float64(x_46_re * x_46_im) * -27.0) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) * 2.0))); else tmp = Float64(x_46_im * Float64(x_46_re * Float64(x_46_re - 27.0))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_re <= 4.1e+186) tmp = ((x_46_re * x_46_im) * -27.0) - (x_46_im * ((x_46_re * x_46_im) * 2.0)); else tmp = x_46_im * (x_46_re * (x_46_re - 27.0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 4.1e+186], N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] * -27.0), $MachinePrecision] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$im * N[(x$46$re * N[(x$46$re - 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 4.1 \cdot 10^{+186}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot -27 - x.im \cdot \left(\left(x.re \cdot x.im\right) \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\
\end{array}
\end{array}
if x.re < 4.1e186Initial program 81.1%
difference-of-squares84.9%
Applied egg-rr84.9%
Simplified48.4%
Taylor expanded in x.re around 0 28.7%
*-commutative28.7%
*-un-lft-identity28.7%
*-un-lft-identity28.7%
distribute-rgt-out28.7%
*-commutative28.7%
metadata-eval28.7%
Applied egg-rr28.7%
if 4.1e186 < x.re Initial program 54.2%
difference-of-squares54.2%
Applied egg-rr54.2%
Simplified54.2%
Taylor expanded in x.im around inf 20.8%
Taylor expanded in x.im around 0 45.8%
Final simplification30.3%
(FPCore (x.re x.im) :precision binary64 (if (<= x.re 4.8e+189) (* (* x.re x.im) -27.0) (* x.im (* x.re (- x.re 27.0)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= 4.8e+189) {
tmp = (x_46_re * x_46_im) * -27.0;
} else {
tmp = x_46_im * (x_46_re * (x_46_re - 27.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 <= 4.8d+189) then
tmp = (x_46re * x_46im) * (-27.0d0)
else
tmp = x_46im * (x_46re * (x_46re - 27.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 <= 4.8e+189) {
tmp = (x_46_re * x_46_im) * -27.0;
} else {
tmp = x_46_im * (x_46_re * (x_46_re - 27.0));
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if x_46_re <= 4.8e+189: tmp = (x_46_re * x_46_im) * -27.0 else: tmp = x_46_im * (x_46_re * (x_46_re - 27.0)) return tmp
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_re <= 4.8e+189) tmp = Float64(Float64(x_46_re * x_46_im) * -27.0); else tmp = Float64(x_46_im * Float64(x_46_re * Float64(x_46_re - 27.0))); end return tmp end
function tmp_2 = code(x_46_re, x_46_im) tmp = 0.0; if (x_46_re <= 4.8e+189) tmp = (x_46_re * x_46_im) * -27.0; else tmp = x_46_im * (x_46_re * (x_46_re - 27.0)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 4.8e+189], N[(N[(x$46$re * x$46$im), $MachinePrecision] * -27.0), $MachinePrecision], N[(x$46$im * N[(x$46$re * N[(x$46$re - 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 4.8 \cdot 10^{+189}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot -27\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(x.re \cdot \left(x.re - 27\right)\right)\\
\end{array}
\end{array}
if x.re < 4.8000000000000001e189Initial program 81.1%
difference-of-squares84.9%
Applied egg-rr84.9%
Simplified48.4%
Taylor expanded in x.re around 0 28.7%
Taylor expanded in x.im around 0 21.1%
if 4.8000000000000001e189 < x.re Initial program 54.2%
difference-of-squares54.2%
Applied egg-rr54.2%
Simplified54.2%
Taylor expanded in x.im around inf 20.8%
Taylor expanded in x.im around 0 45.8%
Final simplification23.4%
(FPCore (x.re x.im) :precision binary64 (* (* x.re x.im) -27.0))
double code(double x_46_re, double x_46_im) {
return (x_46_re * x_46_im) * -27.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_46im) * (-27.0d0)
end function
public static double code(double x_46_re, double x_46_im) {
return (x_46_re * x_46_im) * -27.0;
}
def code(x_46_re, x_46_im): return (x_46_re * x_46_im) * -27.0
function code(x_46_re, x_46_im) return Float64(Float64(x_46_re * x_46_im) * -27.0) end
function tmp = code(x_46_re, x_46_im) tmp = (x_46_re * x_46_im) * -27.0; end
code[x$46$re_, x$46$im_] := N[(N[(x$46$re * x$46$im), $MachinePrecision] * -27.0), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.im\right) \cdot -27
\end{array}
Initial program 78.5%
difference-of-squares82.1%
Applied egg-rr82.1%
Simplified49.0%
Taylor expanded in x.re around 0 26.1%
Taylor expanded in x.im around 0 20.8%
Final simplification20.8%
(FPCore (x.re x.im) :precision binary64 (* x.im 3.0))
double code(double x_46_re, double x_46_im) {
return 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_46im * 3.0d0
end function
public static double code(double x_46_re, double x_46_im) {
return x_46_im * 3.0;
}
def code(x_46_re, x_46_im): return x_46_im * 3.0
function code(x_46_re, x_46_im) return Float64(x_46_im * 3.0) end
function tmp = code(x_46_re, x_46_im) tmp = x_46_im * 3.0; end
code[x$46$re_, x$46$im_] := N[(x$46$im * 3.0), $MachinePrecision]
\begin{array}{l}
\\
x.im \cdot 3
\end{array}
Initial program 78.5%
difference-of-squares82.1%
Applied egg-rr82.1%
Simplified49.0%
Taylor expanded in x.im around inf 29.1%
*-commutative82.1%
flip-+0.0%
+-inverses0.0%
metadata-eval0.0%
+-inverses0.0%
*-commutative0.0%
*-commutative0.0%
distribute-neg-frac0.0%
*-commutative0.0%
+-inverses0.0%
+-inverses0.0%
*-commutative0.0%
flip-+60.4%
*-commutative60.4%
neg-sub060.4%
*-commutative60.4%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified16.7%
Taylor expanded in x.re around 0 3.6%
Simplified3.6%
Final simplification3.6%
(FPCore (x.re x.im) :precision binary64 (- x.re))
double code(double x_46_re, double x_46_im) {
return -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
end function
public static double code(double x_46_re, double x_46_im) {
return -x_46_re;
}
def code(x_46_re, x_46_im): return -x_46_re
function code(x_46_re, x_46_im) return Float64(-x_46_re) end
function tmp = code(x_46_re, x_46_im) tmp = -x_46_re; end
code[x$46$re_, x$46$im_] := (-x$46$re)
\begin{array}{l}
\\
-x.re
\end{array}
Initial program 78.5%
Simplified76.2%
Taylor expanded in x.re around 0 46.9%
Simplified3.1%
Final simplification3.1%
(FPCore (x.re x.im) :precision binary64 (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im)))))
double code(double x_46_re, double x_46_im) {
return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)));
}
real(8) function code(x_46re, x_46im)
real(8), intent (in) :: x_46re
real(8), intent (in) :: x_46im
code = ((x_46re * x_46re) * (x_46re - x_46im)) + ((x_46re * x_46im) * (x_46re - (3.0d0 * x_46im)))
end function
public static double code(double x_46_re, double x_46_im) {
return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)));
}
def code(x_46_re, x_46_im): return ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im)))
function code(x_46_re, x_46_im) return Float64(Float64(Float64(x_46_re * x_46_re) * Float64(x_46_re - x_46_im)) + Float64(Float64(x_46_re * x_46_im) * Float64(x_46_re - Float64(3.0 * x_46_im)))) end
function tmp = code(x_46_re, x_46_im) tmp = ((x_46_re * x_46_re) * (x_46_re - x_46_im)) + ((x_46_re * x_46_im) * (x_46_re - (3.0 * x_46_im))); end
code[x$46$re_, x$46$im_] := N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision] + N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$re - N[(3.0 * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re\right) \cdot \left(x.re - x.im\right) + \left(x.re \cdot x.im\right) \cdot \left(x.re - 3 \cdot x.im\right)
\end{array}
herbie shell --seed 2023320
(FPCore (x.re x.im)
:name "math.cube on complex, real part"
:precision binary64
:herbie-target
(+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3.0 x.im))))
(- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))