
(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.re x.im) (* x.im x.re)) x.im)))
(if (<= (- (* (- (* x.re x.re) (* x.im x.im)) x.re) t_0) INFINITY)
(- (* (+ x.im x.re) (* (- x.re x.im) x.re)) t_0)
(* (* (fma (/ x.re x.im) (/ x.re x.im) -3.0) (* x.im x.im)) x.re))))
double code(double x_46_re, double x_46_im) {
double t_0 = ((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im;
double tmp;
if (((((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - t_0) <= ((double) INFINITY)) {
tmp = ((x_46_im + x_46_re) * ((x_46_re - x_46_im) * x_46_re)) - t_0;
} else {
tmp = (fma((x_46_re / x_46_im), (x_46_re / x_46_im), -3.0) * (x_46_im * x_46_im)) * x_46_re;
}
return tmp;
}
function code(x_46_re, x_46_im) t_0 = Float64(Float64(Float64(x_46_re * x_46_im) + Float64(x_46_im * x_46_re)) * x_46_im) tmp = 0.0 if (Float64(Float64(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - t_0) <= Inf) tmp = Float64(Float64(Float64(x_46_im + x_46_re) * Float64(Float64(x_46_re - x_46_im) * x_46_re)) - t_0); else tmp = Float64(Float64(fma(Float64(x_46_re / x_46_im), Float64(x_46_re / x_46_im), -3.0) * Float64(x_46_im * x_46_im)) * x_46_re); end return tmp end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[(N[(x$46$re * x$46$im), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(x$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision] - t$95$0), $MachinePrecision], Infinity], N[(N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(N[(x$46$re - x$46$im), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(N[(x$46$re / x$46$im), $MachinePrecision] * N[(x$46$re / x$46$im), $MachinePrecision] + -3.0), $MachinePrecision] * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\\
\mathbf{if}\;\left(x.re \cdot x.re - x.im \cdot x.im\right) \cdot x.re - t\_0 \leq \infty:\\
\;\;\;\;\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{x.re}{x.im}, \frac{x.re}{x.im}, -3\right) \cdot \left(x.im \cdot x.im\right)\right) \cdot x.re\\
\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 95.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6499.7
Applied rewrites99.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%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6428.6
Applied rewrites28.6%
Taylor expanded in x.re around 0
*-commutativeN/A
+-commutativeN/A
associate-+r-N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6442.9
Applied rewrites42.9%
Taylor expanded in x.im around inf
Applied rewrites100.0%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.re x.im) (* x.im x.re)) x.im))
-2e-319)
(* (* 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) {
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_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)) <= (-2d-319)) 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) {
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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319: 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(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)) <= -2e-319) tmp = Float64(Float64(x_46_re * x_46_im) * Float64(x_46_im * -3.0)); else tmp = Float64(Float64(x_46_re * 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) 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[(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], -2e-319], N[(N[(x$46$re * x$46$im), $MachinePrecision] * N[(x$46$im * -3.0), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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 \leq -2 \cdot 10^{-319}:\\
\;\;\;\;\left(x.re \cdot x.im\right) \cdot \left(x.im \cdot -3\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot x.re\\
\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)) < -1.99998e-319Initial program 94.7%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6450.2
Applied rewrites50.2%
Applied rewrites50.3%
if -1.99998e-319 < (-.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 83.2%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6462.7
Applied rewrites62.7%
Taylor expanded in x.re around 0
*-commutativeN/A
+-commutativeN/A
associate-+r-N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6488.6
Applied rewrites88.6%
Taylor expanded in x.re around inf
Applied rewrites62.3%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.re x.im) (* x.im x.re)) x.im))
-2e-319)
(* (* -3.0 (* x.re x.im)) 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) {
tmp = (-3.0 * (x_46_re * x_46_im)) * 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_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)) <= (-2d-319)) then
tmp = ((-3.0d0) * (x_46re * x_46im)) * 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) {
tmp = (-3.0 * (x_46_re * x_46_im)) * 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319: tmp = (-3.0 * (x_46_re * x_46_im)) * 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(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)) <= -2e-319) tmp = Float64(Float64(-3.0 * Float64(x_46_re * x_46_im)) * x_46_im); else tmp = Float64(Float64(x_46_re * 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) tmp = (-3.0 * (x_46_re * x_46_im)) * 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[(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], -2e-319], N[(N[(-3.0 * N[(x$46$re * x$46$im), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision], N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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 \leq -2 \cdot 10^{-319}:\\
\;\;\;\;\left(-3 \cdot \left(x.re \cdot x.im\right)\right) \cdot x.im\\
\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot x.re\\
\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)) < -1.99998e-319Initial program 94.7%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6450.2
Applied rewrites50.2%
Applied rewrites50.2%
if -1.99998e-319 < (-.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 83.2%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6462.7
Applied rewrites62.7%
Taylor expanded in x.re around 0
*-commutativeN/A
+-commutativeN/A
associate-+r-N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6488.6
Applied rewrites88.6%
Taylor expanded in x.re around inf
Applied rewrites62.3%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.re x.im) (* x.im x.re)) x.im))
-2e-319)
(* -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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) {
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_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)) <= (-2d-319)) 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) {
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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319: 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(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)) <= -2e-319) tmp = Float64(-3.0 * Float64(Float64(x_46_im * x_46_re) * x_46_im)); else tmp = Float64(Float64(x_46_re * 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) 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[(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], -2e-319], N[(-3.0 * N[(N[(x$46$im * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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 \leq -2 \cdot 10^{-319}:\\
\;\;\;\;-3 \cdot \left(\left(x.im \cdot x.re\right) \cdot x.im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot x.re\\
\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)) < -1.99998e-319Initial program 94.7%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6450.2
Applied rewrites50.2%
if -1.99998e-319 < (-.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 83.2%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6462.7
Applied rewrites62.7%
Taylor expanded in x.re around 0
*-commutativeN/A
+-commutativeN/A
associate-+r-N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6488.6
Applied rewrites88.6%
Taylor expanded in x.re around inf
Applied rewrites62.3%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.re x.im) (* x.im x.re)) x.im))
-2e-319)
(* -3.0 (* (* x.im x.im) x.re))
(* (* 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) {
tmp = -3.0 * ((x_46_im * x_46_im) * x_46_re);
} 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_46im * x_46im)) * x_46re) - (((x_46re * x_46im) + (x_46im * x_46re)) * x_46im)) <= (-2d-319)) then
tmp = (-3.0d0) * ((x_46im * x_46im) * x_46re)
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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) {
tmp = -3.0 * ((x_46_im * x_46_im) * x_46_re);
} 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319: tmp = -3.0 * ((x_46_im * x_46_im) * x_46_re) 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(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)) <= -2e-319) tmp = Float64(-3.0 * Float64(Float64(x_46_im * x_46_im) * x_46_re)); else tmp = Float64(Float64(x_46_re * 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_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im)) <= -2e-319) tmp = -3.0 * ((x_46_im * x_46_im) * x_46_re); 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[(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], -2e-319], N[(-3.0 * N[(N[(x$46$im * x$46$im), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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 \leq -2 \cdot 10^{-319}:\\
\;\;\;\;-3 \cdot \left(\left(x.im \cdot x.im\right) \cdot x.re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot x.re\\
\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)) < -1.99998e-319Initial program 94.7%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6450.2
Applied rewrites50.2%
Applied rewrites45.2%
if -1.99998e-319 < (-.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 83.2%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6462.7
Applied rewrites62.7%
Taylor expanded in x.re around 0
*-commutativeN/A
+-commutativeN/A
associate-+r-N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6488.6
Applied rewrites88.6%
Taylor expanded in x.re around inf
Applied rewrites62.3%
(FPCore (x.re x.im)
:precision binary64
(if (<= x.re 4.4e+193)
(-
(* (+ x.im x.re) (* (- x.re x.im) x.re))
(* (+ (* x.re x.im) (* 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 <= 4.4e+193) {
tmp = ((x_46_im + x_46_re) * ((x_46_re - x_46_im) * x_46_re)) - (((x_46_re * x_46_im) + (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 <= 4.4d+193) then
tmp = ((x_46im + x_46re) * ((x_46re - x_46im) * x_46re)) - (((x_46re * x_46im) + (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 <= 4.4e+193) {
tmp = ((x_46_im + x_46_re) * ((x_46_re - x_46_im) * x_46_re)) - (((x_46_re * x_46_im) + (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 <= 4.4e+193: tmp = ((x_46_im + x_46_re) * ((x_46_re - x_46_im) * x_46_re)) - (((x_46_re * x_46_im) + (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 <= 4.4e+193) tmp = Float64(Float64(Float64(x_46_im + x_46_re) * Float64(Float64(x_46_re - 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)); else tmp = Float64(Float64(x_46_re * 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 <= 4.4e+193) tmp = ((x_46_im + x_46_re) * ((x_46_re - x_46_im) * x_46_re)) - (((x_46_re * x_46_im) + (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[x$46$re, 4.4e+193], N[(N[(N[(x$46$im + x$46$re), $MachinePrecision] * N[(N[(x$46$re - x$46$im), $MachinePrecision] * x$46$re), $MachinePrecision]), $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], N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq 4.4 \cdot 10^{+193}:\\
\;\;\;\;\left(x.im + x.re\right) \cdot \left(\left(x.re - x.im\right) \cdot x.re\right) - \left(x.re \cdot x.im + x.im \cdot x.re\right) \cdot x.im\\
\mathbf{else}:\\
\;\;\;\;\left(x.re \cdot x.re\right) \cdot x.re\\
\end{array}
\end{array}
if x.re < 4.39999999999999972e193Initial program 89.5%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f6496.3
Applied rewrites96.3%
if 4.39999999999999972e193 < x.re Initial program 61.9%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f645.1
Applied rewrites5.1%
Taylor expanded in x.re around 0
*-commutativeN/A
+-commutativeN/A
associate-+r-N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.0
Applied rewrites81.0%
Taylor expanded in x.re around inf
Applied rewrites95.2%
(FPCore (x.re x.im) :precision binary64 (if (<= x.im 7.6e+153) (* (fma -3.0 (* x.im x.im) (* x.re x.re)) x.re) (* (* (* -3.0 x.re) x.im) x.im)))
double code(double x_46_re, double x_46_im) {
double tmp;
if (x_46_im <= 7.6e+153) {
tmp = fma(-3.0, (x_46_im * x_46_im), (x_46_re * x_46_re)) * x_46_re;
} else {
tmp = ((-3.0 * x_46_re) * x_46_im) * x_46_im;
}
return tmp;
}
function code(x_46_re, x_46_im) tmp = 0.0 if (x_46_im <= 7.6e+153) tmp = Float64(fma(-3.0, Float64(x_46_im * x_46_im), Float64(x_46_re * x_46_re)) * x_46_re); else tmp = Float64(Float64(Float64(-3.0 * x_46_re) * x_46_im) * x_46_im); end return tmp end
code[x$46$re_, x$46$im_] := If[LessEqual[x$46$im, 7.6e+153], N[(N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$re), $MachinePrecision], N[(N[(N[(-3.0 * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision] * x$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq 7.6 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(-3, x.im \cdot x.im, x.re \cdot x.re\right) \cdot x.re\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-3 \cdot x.re\right) \cdot x.im\right) \cdot x.im\\
\end{array}
\end{array}
if x.im < 7.59999999999999933e153Initial program 90.8%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6454.9
Applied rewrites54.9%
Taylor expanded in x.re around 0
*-commutativeN/A
+-commutativeN/A
associate-+r-N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6494.8
Applied rewrites94.8%
if 7.59999999999999933e153 < x.im Initial program 58.1%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6485.6
Applied rewrites85.6%
Applied rewrites85.5%
Applied rewrites85.5%
(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(Float64(x_46_re * 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[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]
\begin{array}{l}
\\
\left(x.re \cdot x.re\right) \cdot x.re
\end{array}
Initial program 87.2%
Taylor expanded in x.re around 0
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6458.2
Applied rewrites58.2%
Taylor expanded in x.re around 0
*-commutativeN/A
+-commutativeN/A
associate-+r-N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.8
Applied rewrites90.8%
Taylor expanded in x.re around inf
Applied rewrites59.0%
(FPCore (x.re x.im) :precision binary64 (* (* x.im x.im) x.re))
double code(double x_46_re, double x_46_im) {
return (x_46_im * x_46_im) * 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_46im) * x_46re
end function
public static double code(double x_46_re, double x_46_im) {
return (x_46_im * x_46_im) * x_46_re;
}
def code(x_46_re, x_46_im): return (x_46_im * x_46_im) * x_46_re
function code(x_46_re, x_46_im) return Float64(Float64(x_46_im * x_46_im) * x_46_re) end
function tmp = code(x_46_re, x_46_im) tmp = (x_46_im * x_46_im) * x_46_re; end
code[x$46$re_, x$46$im_] := N[(N[(x$46$im * x$46$im), $MachinePrecision] * x$46$re), $MachinePrecision]
\begin{array}{l}
\\
\left(x.im \cdot x.im\right) \cdot x.re
\end{array}
Initial program 87.2%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
flip-+N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
distribute-neg-frac2N/A
Applied rewrites56.5%
Taylor expanded in x.re around 0
*-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6423.9
Applied rewrites23.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 2024318
(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)))