
(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 8 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
(if (<= x.re 7.2e+206)
(fma
(* x.re (+ x.im x.im))
(- x.im)
(* (* x.re (+ x.re x.im)) (- x.re x.im)))
(* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= 7.2e+206) {
tmp = fma((x_46_re * (x_46_im + x_46_im)), -x_46_im, ((x_46_re * (x_46_re + x_46_im)) * (x_46_re - x_46_im)));
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
return tmp;
}
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_re <= 7.2e+206) tmp = fma(Float64(x_46_re * Float64(x_46_im + x_46_im)), Float64(-x_46_im), Float64(Float64(x_46_re * Float64(x_46_re + x_46_im)) * Float64(x_46_re - x_46_im))); else tmp = Float64(x_46_re * Float64(x_46_re * x_46_re)); end return tmp end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 7.2e+206], N[(N[(x$46$re * N[(x$46$im + x$46$im), $MachinePrecision]), $MachinePrecision] * (-x$46$im) + N[(N[(x$46$re * N[(x$46$re + x$46$im), $MachinePrecision]), $MachinePrecision] * N[(x$46$re - x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 7.2 \cdot 10^{+206}:\\
\;\;\;\;\mathsf{fma}\left(x.re \cdot \left(x.im + x.im\right), -x.im, \left(x.re \cdot \left(x.re + x.im\right)\right) \cdot \left(x.re - x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\right)\\
\end{array}
\end{array}
if x.re < 7.20000000000000057e206Initial program 90.3%
Applied egg-rr99.8%
if 7.20000000000000057e206 < x.re Initial program 66.7%
Taylor expanded in x.re around inf
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Simplified100.0%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* x.re (- (* x.re x.re) (* x.im x.im)))
(* x.im (+ (* x.re x.im) (* x.re x.im))))
-1e-323)
(* (* x.re x.im) (* x.im -3.0))
(* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (((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_re * x_46_im)))) <= -1e-323) {
tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
} else {
tmp = x_46_re * (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_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))) <= (-1d-323)) then
tmp = (x_46re * x_46im) * (x_46im * (-3.0d0))
else
tmp = x_46re * (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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= -1e-323) {
tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if ((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_re * x_46_im)))) <= -1e-323: tmp = (x_46_re * x_46_im) * (x_46_im * -3.0) else: tmp = x_46_re * (x_46_re * x_46_re) return tmp
function code(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))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= -1e-323) tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0)); else tmp = Float64(x_46_re * 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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= -1e-323) tmp = (x_46_re * x_46_im) * (x_46_im * -3.0); else tmp = x_46_re * (x_46_re * x_46_re); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := 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] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-323], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq -1 \cdot 10^{-323}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\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)) < -9.88131e-324Initial program 92.8%
Taylor expanded in x.re around 0
lower-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-eval41.0
Simplified41.0%
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6447.9
Applied egg-rr47.9%
if -9.88131e-324 < (-.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 86.2%
Taylor expanded in x.re around inf
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6463.5
Simplified63.5%
Final simplification57.1%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* x.re (- (* x.re x.re) (* x.im x.im)))
(* x.im (+ (* x.re x.im) (* x.re x.im))))
-1e-323)
(* -3.0 (* x.im (* x.re x.im)))
(* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (((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_re * x_46_im)))) <= -1e-323) {
tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
} else {
tmp = x_46_re * (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_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))) <= (-1d-323)) then
tmp = (-3.0d0) * (x_46im * (x_46re * x_46im))
else
tmp = x_46re * (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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= -1e-323) {
tmp = -3.0 * (x_46_im * (x_46_re * x_46_im));
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if ((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_re * x_46_im)))) <= -1e-323: tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)) else: tmp = x_46_re * (x_46_re * x_46_re) return tmp
function code(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))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= -1e-323) tmp = Float64(-3.0 * Float64(x_46_im * Float64(x_46_re * x_46_im))); else tmp = Float64(x_46_re * 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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= -1e-323) tmp = -3.0 * (x_46_im * (x_46_re * x_46_im)); else tmp = x_46_re * (x_46_re * x_46_re); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := 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] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-323], N[(-3.0 * N[(x$46$im * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq -1 \cdot 10^{-323}:\\
\;\;\;\;-3 \cdot \left(x.im \cdot \left(x.re \cdot x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\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)) < -9.88131e-324Initial program 92.8%
Taylor expanded in x.re around 0
lower-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-eval41.0
Simplified41.0%
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6441.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6447.9
Applied egg-rr47.9%
if -9.88131e-324 < (-.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 86.2%
Taylor expanded in x.re around inf
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6463.5
Simplified63.5%
Final simplification57.1%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* x.re (- (* x.re x.re) (* x.im x.im)))
(* x.im (+ (* x.re x.im) (* x.re x.im))))
-1e-323)
(* x.im (* x.im (* x.re -3.0)))
(* x.re (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (((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_re * x_46_im)))) <= -1e-323) {
tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
} else {
tmp = x_46_re * (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_46re * ((x_46re * x_46re) - (x_46im * x_46im))) - (x_46im * ((x_46re * x_46im) + (x_46re * x_46im)))) <= (-1d-323)) then
tmp = x_46im * (x_46im * (x_46re * (-3.0d0)))
else
tmp = x_46re * (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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= -1e-323) {
tmp = x_46_im * (x_46_im * (x_46_re * -3.0));
} else {
tmp = x_46_re * (x_46_re * x_46_re);
}
return tmp;
}
def code(x_46_re, x_46_im): tmp = 0 if ((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_re * x_46_im)))) <= -1e-323: tmp = x_46_im * (x_46_im * (x_46_re * -3.0)) else: tmp = x_46_re * (x_46_re * x_46_re) return tmp
function code(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))) - Float64(x_46_im * Float64(Float64(x_46_re * x_46_im) + Float64(x_46_re * x_46_im)))) <= -1e-323) tmp = Float64(x_46_im * Float64(x_46_im * Float64(x_46_re * -3.0))); else tmp = Float64(x_46_re * 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_re * ((x_46_re * x_46_re) - (x_46_im * x_46_im))) - (x_46_im * ((x_46_re * x_46_im) + (x_46_re * x_46_im)))) <= -1e-323) tmp = x_46_im * (x_46_im * (x_46_re * -3.0)); else tmp = x_46_re * (x_46_re * x_46_re); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_] := 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] - N[(x$46$im * N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-323], N[(x$46$im * N[(x$46$im * N[(x$46$re * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \cdot \left(x.re \cdot x.re - x.im \cdot x.im\right) - x.im \cdot \left(x.re \cdot x.im + x.re \cdot x.im\right) \leq -1 \cdot 10^{-323}:\\
\;\;\;\;x.im \cdot \left(x.im \cdot \left(x.re \cdot -3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \left(x.re \cdot x.re\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)) < -9.88131e-324Initial program 92.8%
Applied egg-rr99.8%
Taylor expanded in x.im around inf
Simplified87.0%
Taylor expanded in x.re around 0
Simplified47.9%
if -9.88131e-324 < (-.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 86.2%
Taylor expanded in x.re around inf
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6463.5
Simplified63.5%
Final simplification57.1%
(FPCore (x.re x.im) :precision binary64 (if (<= x.re 2.25e-86) (fma (* x.re x.im) (* x.im -3.0) (* x.re (* x.re x.re))) (* x.re (fma x.im (* x.im -3.0) (* x.re x.re)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= 2.25e-86) {
tmp = fma((x_46_re * x_46_im), (x_46_im * -3.0), (x_46_re * (x_46_re * x_46_re)));
} else {
tmp = x_46_re * fma(x_46_im, (x_46_im * -3.0), (x_46_re * x_46_re));
}
return tmp;
}
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_re <= 2.25e-86) tmp = fma(Float64(x_46_re * x_46_im), Float64(x_46_im * -3.0), Float64(x_46_re * Float64(x_46_re * x_46_re))); else tmp = Float64(x_46_re * fma(x_46_im, Float64(x_46_im * -3.0), Float64(x_46_re * x_46_re))); end return tmp end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 2.25e-86], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 2.25 \cdot 10^{-86}:\\
\;\;\;\;\mathsf{fma}\left(x.re \cdot x.im, x.im \cdot -3, x.re \cdot \left(x.re \cdot x.re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\
\end{array}
\end{array}
if x.re < 2.2499999999999999e-86Initial program 89.3%
Taylor expanded in x.re around 0
lower-*.f64N/A
+-commutativeN/A
associate--l+N/A
unpow2N/A
lower-fma.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-eval91.0
Simplified91.0%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6498.2
Applied egg-rr98.2%
if 2.2499999999999999e-86 < x.re Initial program 88.0%
Taylor expanded in x.re around 0
lower-*.f64N/A
+-commutativeN/A
associate--l+N/A
unpow2N/A
lower-fma.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-eval97.2
Simplified97.2%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f6497.2
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6497.2
Applied egg-rr97.2%
Final simplification97.9%
(FPCore (x.re x.im) :precision binary64 (if (<= x.re 6e-119) (* (* x.re x.im) (* x.im -3.0)) (* x.re (fma x.im (* x.im -3.0) (* x.re x.re)))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= 6e-119) {
tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
} else {
tmp = x_46_re * fma(x_46_im, (x_46_im * -3.0), (x_46_re * x_46_re));
}
return tmp;
}
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_re <= 6e-119) tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0)); else tmp = Float64(x_46_re * fma(x_46_im, Float64(x_46_im * -3.0), Float64(x_46_re * x_46_re))); end return tmp end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 6e-119], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$im * N[(x$46$im * -3.0), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 6 \cdot 10^{-119}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.im, x.im \cdot -3, x.re \cdot x.re\right)\\
\end{array}
\end{array}
if x.re < 6.0000000000000004e-119Initial program 88.9%
Taylor expanded in x.re around 0
lower-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-eval56.9
Simplified56.9%
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.1
Applied egg-rr66.1%
if 6.0000000000000004e-119 < x.re Initial program 89.1%
Taylor expanded in x.re around 0
lower-*.f64N/A
+-commutativeN/A
associate--l+N/A
unpow2N/A
lower-fma.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-eval97.5
Simplified97.5%
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-*.f6497.5
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6497.5
Applied egg-rr97.5%
Final simplification76.4%
(FPCore (x.re x.im) :precision binary64 (if (<= x.re 7e-107) (* (* x.re x.im) (* x.im -3.0)) (* x.re (fma x.re x.re (* -3.0 (* x.im x.im))))))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_re <= 7e-107) {
tmp = (x_46_re * x_46_im) * (x_46_im * -3.0);
} else {
tmp = x_46_re * fma(x_46_re, x_46_re, (-3.0 * (x_46_im * x_46_im)));
}
return tmp;
}
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_re <= 7e-107) tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0)); else tmp = Float64(x_46_re * fma(x_46_re, x_46_re, Float64(-3.0 * Float64(x_46_im * x_46_im)))); end return tmp end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$re, 7e-107], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(x$46$re * N[(x$46$re * x$46$re + N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 7 \cdot 10^{-107}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot \mathsf{fma}\left(x.re, x.re, -3 \cdot \left(x.im \cdot x.im\right)\right)\\
\end{array}
\end{array}
if x.re < 6.99999999999999971e-107Initial program 89.1%
Taylor expanded in x.re around 0
lower-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-eval57.8
Simplified57.8%
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.9
Applied egg-rr66.9%
if 6.99999999999999971e-107 < x.re Initial program 88.6%
Taylor expanded in x.re around 0
lower-*.f64N/A
+-commutativeN/A
associate--l+N/A
unpow2N/A
lower-fma.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-eval97.3
Simplified97.3%
Final simplification76.4%
(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 88.9%
Taylor expanded in x.re around inf
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6459.5
Simplified59.5%
(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 2024207
(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)))