
(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 6 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.im) (* x.re (- x.re x.im))) t_0)
(* (+ -3.0 (/ x.re (* x.im (/ x.im x.re)))) (* x.re (* x.im x.im))))))
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_im) * (x_46_re * (x_46_re - x_46_im))) - t_0;
} else {
tmp = (-3.0 + (x_46_re / (x_46_im * (x_46_im / x_46_re)))) * (x_46_re * (x_46_im * x_46_im));
}
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_im) * (x_46_re * (x_46_re - x_46_im))) - t_0;
} else {
tmp = (-3.0 + (x_46_re / (x_46_im * (x_46_im / x_46_re)))) * (x_46_re * (x_46_im * x_46_im));
}
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_im) * (x_46_re * (x_46_re - x_46_im))) - t_0 else: tmp = (-3.0 + (x_46_re / (x_46_im * (x_46_im / x_46_re)))) * (x_46_re * (x_46_im * x_46_im)) 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 + x_46_im) * Float64(x_46_re * Float64(x_46_re - x_46_im))) - t_0); else tmp = Float64(Float64(-3.0 + Float64(x_46_re / Float64(x_46_im * Float64(x_46_im / x_46_re)))) * Float64(x_46_re * Float64(x_46_im * x_46_im))); 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_im) * (x_46_re * (x_46_re - x_46_im))) - t_0; else tmp = (-3.0 + (x_46_re / (x_46_im * (x_46_im / x_46_re)))) * (x_46_re * (x_46_im * x_46_im)); 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 + x$46$im), $MachinePrecision] * N[(x$46$re * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(-3.0 + N[(x$46$re / N[(x$46$im * N[(x$46$im / x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x$46$re * N[(x$46$im * x$46$im), $MachinePrecision]), $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 + x.im\right) \cdot \left(x.re \cdot \left(x.re - x.im\right)\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(-3 + \frac{x.re}{x.im \cdot \frac{x.im}{x.re}}\right) \cdot \left(x.re \cdot \left(x.im \cdot x.im\right)\right)\\
\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 94.0%
difference-of-squaresN/A
associate-*l*N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f6499.8%
Applied egg-rr99.8%
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-squaresN/A
associate-*l*N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f6432.4%
Applied egg-rr32.4%
Taylor expanded in x.im around inf
mul-1-negN/A
neg-sub0N/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
neg-sub0N/A
*-lowering-*.f64N/A
neg-sub0N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f6432.4%
Simplified32.4%
Taylor expanded in x.im around inf
Simplified67.6%
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
associate-*l/N/A
associate-/r/N/A
associate-/l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (x.re x.im)
:precision binary64
(if (<= x.re 2e-117)
(* -3.0 (* x.im (* x.re x.im)))
(if (<= x.re 1e+101)
(-
(* x.re (- (* x.re x.re) (* x.im x.im)))
(* x.im (* x.re (+ x.im x.im))))
(-
(* (+ x.re x.im) (* x.im (* x.re (+ -1.0 (/ x.re x.im)))))
(+ x.im x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= 2e-117) {
tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
} else if (x_46_re <= 1e+101) {
tmp = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * (x_46_re * (x_46_im + x_46_im)));
} else {
tmp = ((x_46_re + x_46_im) * (x_46_im * (x_46_re * (-1.0 + (x_46_re / 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-117) then
tmp = (-3.0d0) * (x_46im * (x_46re * x_46im))
else if (x_46re <= 1d+101) then
tmp = (x_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * (x_46re * (x_46im + x_46im)))
else
tmp = ((x_46re + x_46im) * (x_46im * (x_46re * ((-1.0d0) + (x_46re / 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-117) {
tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
} else if (x_46_re <= 1e+101) {
tmp = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * (x_46_re * (x_46_im + x_46_im)));
} else {
tmp = ((x_46_re + x_46_im) * (x_46_im * (x_46_re * (-1.0 + (x_46_re / 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-117: tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)) elif x_46_re <= 1e+101: tmp = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * (x_46_re * (x_46_im + x_46_im))) else: tmp = ((x_46_re + x_46_im) * (x_46_im * (x_46_re * (-1.0 + (x_46_re / 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-117) tmp = Float64(-3.0 * Float64(x_46_im * Float64(x_46_re * x_46_im))); elseif (x_46_re <= 1e+101) tmp = Float64(Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im))) - Float64(x_46_im * Float64(x_46_re * Float64(x_46_im + x_46_im)))); else tmp = Float64(Float64(Float64(x_46_re + x_46_im) * Float64(x_46_im * Float64(x_46_re * Float64(-1.0 + Float64(x_46_re / x_46_im))))) - Float64(x_46_im + 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-117) tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)); elseif (x_46_re <= 1e+101) tmp = (x_46_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * (x_46_re * (x_46_im + x_46_im))); else tmp = ((x_46_re + x_46_im) * (x_46_im * (x_46_re * (-1.0 + (x_46_re / x_46_im))))) - (x_46_im + x_46_im); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 2e-117], N[(-3.0 * N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 1e+101], N[(N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im * N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re * N[(-1.0 + N[(x$46$re / x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 2 \cdot 10^{-117}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\
\mathbf{elif}\;x.re \leq 10^{+101}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot \left(x.im + x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re \cdot \left(-1 + \frac{x.re}{x.im}\right)\right)\right) - \left(x.im + x.im\right)\\
\end{array}
\end{array}
if x.re < 2.00000000000000006e-117Initial program 83.8%
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
sub-negN/A
count-2N/A
associate-*l*N/A
Simplified86.7%
Taylor expanded in x.re around 0
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6466.0%
Simplified66.0%
if 2.00000000000000006e-117 < x.re < 9.9999999999999998e100Initial program 99.9%
*-commutativeN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f6499.9%
Applied egg-rr99.9%
if 9.9999999999999998e100 < x.re Initial program 54.5%
difference-of-squaresN/A
associate-*l*N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f6468.2%
Applied egg-rr68.2%
Taylor expanded in x.im around inf
mul-1-negN/A
neg-sub0N/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
neg-sub0N/A
*-lowering-*.f64N/A
neg-sub0N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f6468.2%
Simplified68.2%
*-commutativeN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f6468.2%
Applied egg-rr68.2%
*-commutativeN/A
distribute-lft-inN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
associate-*r/N/A
+-inversesN/A
distribute-lft-out--N/A
+-inversesN/A
flip-+N/A
+-lowering-+.f64100.0%
Applied egg-rr100.0%
Final simplification77.5%
(FPCore (x.re x.im)
:precision binary64
(if (<= x.re 2e-117)
(* -3.0 (* x.im (* x.re x.im)))
(if (<= x.re 1e+101)
(* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0))))
(-
(* (+ x.re x.im) (* x.im (* x.re (+ -1.0 (/ x.re x.im)))))
(+ x.im x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= 2e-117) {
tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
} else if (x_46_re <= 1e+101) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = ((x_46_re + x_46_im) * (x_46_im * (x_46_re * (-1.0 + (x_46_re / 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-117) then
tmp = (-3.0d0) * (x_46im * (x_46re * x_46im))
else if (x_46re <= 1d+101) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = ((x_46re + x_46im) * (x_46im * (x_46re * ((-1.0d0) + (x_46re / 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-117) {
tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
} else if (x_46_re <= 1e+101) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = ((x_46_re + x_46_im) * (x_46_im * (x_46_re * (-1.0 + (x_46_re / 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-117: tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)) elif x_46_re <= 1e+101: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) else: tmp = ((x_46_re + x_46_im) * (x_46_im * (x_46_re * (-1.0 + (x_46_re / 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-117) tmp = Float64(-3.0 * Float64(x_46_im * Float64(x_46_re * x_46_im))); elseif (x_46_re <= 1e+101) tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * Float64(x_46_im * -3.0)))); else tmp = Float64(Float64(Float64(x_46_re + x_46_im) * Float64(x_46_im * Float64(x_46_re * Float64(-1.0 + Float64(x_46_re / x_46_im))))) - Float64(x_46_im + 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-117) tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)); elseif (x_46_re <= 1e+101) tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); else tmp = ((x_46_re + x_46_im) * (x_46_im * (x_46_re * (-1.0 + (x_46_re / x_46_im))))) - (x_46_im + x_46_im); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 2e-117], N[(-3.0 * N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$46$re, 1e+101], N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x$46$re + x$46$im), $MachinePrecision] * N[(x$46$im * N[(x$46$re * N[(-1.0 + N[(x$46$re / x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 2 \cdot 10^{-117}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\
\mathbf{elif}\;x.re \leq 10^{+101}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.re + x.im\right) \cdot \left(x.im \cdot \left(x.re \cdot \left(-1 + \frac{x.re}{x.im}\right)\right)\right) - \left(x.im + x.im\right)\\
\end{array}
\end{array}
if x.re < 2.00000000000000006e-117Initial program 83.8%
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
sub-negN/A
count-2N/A
associate-*l*N/A
Simplified86.7%
Taylor expanded in x.re around 0
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6466.0%
Simplified66.0%
if 2.00000000000000006e-117 < x.re < 9.9999999999999998e100Initial program 99.9%
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
sub-negN/A
count-2N/A
associate-*l*N/A
Simplified99.9%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6499.9%
Applied egg-rr99.9%
if 9.9999999999999998e100 < x.re Initial program 54.5%
difference-of-squaresN/A
associate-*l*N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f6468.2%
Applied egg-rr68.2%
Taylor expanded in x.im around inf
mul-1-negN/A
neg-sub0N/A
associate-+l-N/A
unsub-negN/A
mul-1-negN/A
neg-sub0N/A
*-lowering-*.f64N/A
neg-sub0N/A
mul-1-negN/A
unsub-negN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f6468.2%
Simplified68.2%
*-commutativeN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
+-lowering-+.f6468.2%
Applied egg-rr68.2%
*-commutativeN/A
distribute-lft-inN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
associate-*r/N/A
+-inversesN/A
distribute-lft-out--N/A
+-inversesN/A
flip-+N/A
+-lowering-+.f64100.0%
Applied egg-rr100.0%
Final simplification77.5%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 1.16e+146) (* x.re (+ (* x.re x.re) (* x.im (* x.im -3.0)))) (* -3.0 (* x.im (* x.re x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 1.16e+146) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = -3.0 * (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 <= 1.16d+146) then
tmp = x_46re * ((x_46re * x_46re) + (x_46im * (x_46im * (-3.0d0))))
else
tmp = (-3.0d0) * (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 <= 1.16e+146) {
tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0)));
} else {
tmp = -3.0 * (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 <= 1.16e+146: tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))) else: tmp = -3.0 * (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 <= 1.16e+146) tmp = Float64(x_46_re * Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * Float64(x_46_im * -3.0)))); else tmp = Float64(-3.0 * Float64(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 <= 1.16e+146) tmp = x_46_re * ((x_46_re * x_46_re) + (x_46_im * (x_46_im * -3.0))); else tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 1.16e+146], N[(x$46$re * N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1.16 \cdot 10^{+146}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re + x.im \cdot \left(x.im \cdot -3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.im < 1.16e146Initial program 86.3%
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
sub-negN/A
count-2N/A
associate-*l*N/A
Simplified93.3%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6493.3%
Applied egg-rr93.3%
if 1.16e146 < x.im Initial program 47.9%
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
sub-negN/A
count-2N/A
associate-*l*N/A
Simplified47.9%
Taylor expanded in x.re around 0
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6490.5%
Simplified90.5%
Final simplification93.0%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 1.65e+83) (* x.re (* x.re x.re)) (* -3.0 (* x.im (* x.re x.im)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 1.65e+83) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (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 <= 1.65d+83) then
tmp = x_46re * (x_46re * x_46re)
else
tmp = (-3.0d0) * (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 <= 1.65e+83) {
tmp = x_46_re * (x_46_re * x_46_re);
} else {
tmp = -3.0 * (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 <= 1.65e+83: tmp = x_46_re * (x_46_re * x_46_re) else: tmp = -3.0 * (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 <= 1.65e+83) tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); else tmp = Float64(-3.0 * Float64(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 <= 1.65e+83) tmp = x_46_re * (x_46_re * x_46_re); else tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 1.65e+83], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision], N[(-3.0 * N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 1.65 \cdot 10^{+83}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.im < 1.64999999999999992e83Initial program 87.1%
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
sub-negN/A
count-2N/A
associate-*l*N/A
Simplified92.8%
Taylor expanded in x.re around inf
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6464.2%
Simplified64.2%
if 1.64999999999999992e83 < x.im Initial program 57.7%
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
sub-negN/A
count-2N/A
associate-*l*N/A
Simplified65.8%
Taylor expanded in x.re around 0
*-lowering-*.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6485.6%
Simplified85.6%
Final simplification68.3%
(FPCore (x.re x.im) :precision binary64 (* x.re (* x.re x.re)))
double code(double x_46_re, double x_46_im) {
return 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_46re * (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_re);
}
def code(x_46_re, x_46_im): return x_46_re * (x_46_re * x_46_re)
function code(x_46_re, x_46_im) return Float64(x_46_re * Float64(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_re); end
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot \left(x.re \cdot x.re\right)
\end{array}
Initial program 81.5%
sub-negN/A
+-commutativeN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
distribute-lft-outN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
associate-+l+N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
distribute-rgt-neg-outN/A
sub-negN/A
count-2N/A
associate-*l*N/A
Simplified87.7%
Taylor expanded in x.re around inf
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6454.9%
Simplified54.9%
(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 2024144
(FPCore (x.re x.im)
:name "math.cube on complex, real part"
:precision binary64
:alt
(! :herbie-platform default (+ (* (* x.re x.re) (- x.re x.im)) (* (* x.re x.im) (- x.re (* 3 x.im)))))
(- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))