
(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 x.re) (* x.im x.im)) x.re)
(* (+ (* x.im x.re) (* x.im x.re)) x.im))
INFINITY)
(- (* (- x.re x.im) (* (+ x.im x.re) x.re)) (* (* (+ x.im x.im) x.re) x.im))
(* (* (fma (/ x.re x.im) (/ x.re x.im) -3.0) x.re) (* x.im x.im))))
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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= ((double) INFINITY)) {
tmp = ((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);
} else {
tmp = (fma((x_46_re / x_46_im), (x_46_re / x_46_im), -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 (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_im * x_46_re) + Float64(x_46_im * x_46_re)) * x_46_im)) <= Inf) tmp = Float64(Float64(Float64(x_46_re - x_46_im) * Float64(Float64(x_46_im + x_46_re) * x_46_re)) - Float64(Float64(Float64(x_46_im + x_46_im) * x_46_re) * x_46_im)); else tmp = Float64(Float64(fma(Float64(x_46_re / x_46_im), Float64(x_46_re / x_46_im), -3.0) * x_46_re) * Float64(x_46_im * x_46_im)); end return 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$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(N[(x$46$im + x$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(x$46$im + x$46$im), $MachinePrecision] * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x$46$re / x$46$im), $MachinePrecision] * N[(x$46$re / x$46$im), $MachinePrecision] + -3.0), $MachinePrecision] * x$46$re), $MachinePrecision] * N[(x$46$im * x$46$im), $MachinePrecision]), $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.im \cdot x.re + x.im \cdot x.re\right) \cdot x.im \leq \infty:\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(\left(x.im + x.re\right) \cdot x.re\right) - \left(\left(x.im + x.im\right) \cdot x.re\right) \cdot x.im\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{x.re}{x.im}, \frac{x.re}{x.im}, -3\right) \cdot x.re\right) \cdot \left(x.im \cdot x.im\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 92.9%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-outN/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%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6414.8
Applied rewrites14.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
+-commutativeN/A
lift-+.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift-+.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f6414.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.8
Applied rewrites14.8%
Taylor expanded in x.im around inf
Applied rewrites100.0%
Final simplification99.7%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.im x.re) (* x.im x.re)) x.im))
INFINITY)
(- (* (- x.re x.im) (* (+ x.im x.re) x.re)) (* (* (+ x.im x.im) x.re) x.im))
(* (* x.im x.im) 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= ((double) INFINITY)) {
tmp = ((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);
} else {
tmp = (x_46_im * x_46_im) * x_46_re;
}
return tmp;
}
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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= Double.POSITIVE_INFINITY) {
tmp = ((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);
} else {
tmp = (x_46_im * x_46_im) * 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= math.inf: tmp = ((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) else: tmp = (x_46_im * x_46_im) * 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_im * x_46_re) + Float64(x_46_im * x_46_re)) * x_46_im)) <= Inf) tmp = Float64(Float64(Float64(x_46_re - x_46_im) * Float64(Float64(x_46_im + x_46_re) * x_46_re)) - Float64(Float64(Float64(x_46_im + x_46_im) * x_46_re) * x_46_im)); else tmp = Float64(Float64(x_46_im * x_46_im) * 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= Inf) tmp = ((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); else tmp = (x_46_im * x_46_im) * 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$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(x$46$re - x$46$im), $MachinePrecision] * N[(N[(x$46$im + x$46$re), $MachinePrecision] * x$46$re), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(x$46$im + x$46$im), $MachinePrecision] * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * x$46$im), $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.im \cdot x.re + x.im \cdot x.re\right) \cdot x.im \leq \infty:\\
\;\;\;\;\left(x.re - x.im\right) \cdot \left(\left(x.im + x.re\right) \cdot x.re\right) - \left(\left(x.im + x.im\right) \cdot x.re\right) \cdot x.im\\
\mathbf{else}:\\
\;\;\;\;\left(x.im \cdot x.im\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 92.9%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-outN/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.im around 0
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
flip-+N/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
distribute-neg-fracN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
distribute-neg-inN/A
lower-+.f64N/A
lower-neg.f64N/A
lower-neg.f6485.2
Applied rewrites85.2%
Taylor expanded in x.im around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.2
Applied rewrites85.2%
Final simplification98.2%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.im x.re) (* x.im x.re)) x.im))
INFINITY)
(fma (* x.re x.re) x.re (* (* (* -3.0 x.re) x.im) x.im))
(* (* x.im x.im) 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= ((double) INFINITY)) {
tmp = fma((x_46_re * x_46_re), x_46_re, (((-3.0 * x_46_re) * x_46_im) * x_46_im));
} else {
tmp = (x_46_im * x_46_im) * 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_im * x_46_re) + Float64(x_46_im * x_46_re)) * x_46_im)) <= Inf) tmp = fma(Float64(x_46_re * x_46_re), x_46_re, Float64(Float64(Float64(-3.0 * x_46_re) * x_46_im) * x_46_im)); else tmp = Float64(Float64(x_46_im * x_46_im) * x_46_re); end return 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$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x$46$re * x$46$re), $MachinePrecision] * x$46$re + N[(N[(N[(-3.0 * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], N[(N[(x$46$im * x$46$im), $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.im \cdot x.re + x.im \cdot x.re\right) \cdot x.im \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x.re \cdot x.re, x.re, \left(\left(-3 \cdot x.re\right) \cdot x.im\right) \cdot x.im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x.im \cdot x.im\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 92.9%
lift-*.f64N/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
Applied rewrites40.8%
Taylor expanded in x.im around 0
+-commutativeN/A
mul-1-negN/A
unpow3N/A
unpow2N/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
distribute-rgt-out--N/A
distribute-rgt-inN/A
associate--l+N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.8%
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.im around 0
unpow2N/A
lower-*.f640.0
Applied rewrites0.0%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
flip-+N/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
distribute-neg-fracN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
distribute-neg-inN/A
lower-+.f64N/A
lower-neg.f64N/A
lower-neg.f6485.2
Applied rewrites85.2%
Taylor expanded in x.im around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.2
Applied rewrites85.2%
Final simplification98.1%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.im x.re) (* x.im x.re)) x.im))
-5e-324)
(* (* -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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324) {
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_46im * x_46re) + (x_46im * x_46re)) * x_46im)) <= (-5d-324)) 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324) {
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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324: 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_im * x_46_re) + Float64(x_46_im * x_46_re)) * x_46_im)) <= -5e-324) tmp = Float64(Float64(-3.0 * 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324) 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$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], -5e-324], N[(N[(-3.0 * N[(x$46$im * x$46$re), $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.im \cdot x.re + x.im \cdot x.re\right) \cdot x.im \leq -5 \cdot 10^{-324}:\\
\;\;\;\;\left(-3 \cdot \left(x.im \cdot x.re\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)) < -4.94066e-324Initial program 93.9%
Taylor expanded in x.im around inf
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6452.1
Applied rewrites52.1%
Applied rewrites57.9%
if -4.94066e-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 76.5%
lift-*.f64N/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
Applied rewrites34.7%
Taylor expanded in x.im around 0
+-commutativeN/A
mul-1-negN/A
unpow3N/A
unpow2N/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
distribute-rgt-out--N/A
distribute-rgt-inN/A
associate--l+N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.3%
Taylor expanded in x.im around 0
Applied rewrites60.5%
Final simplification59.5%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.im x.re) (* x.im x.re)) x.im))
-5e-324)
(* (* (* x.im x.re) 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324) {
tmp = ((x_46_im * x_46_re) * 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_46im * x_46re) + (x_46im * x_46re)) * x_46im)) <= (-5d-324)) then
tmp = ((x_46im * x_46re) * 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324) {
tmp = ((x_46_im * x_46_re) * 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324: tmp = ((x_46_im * x_46_re) * 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_im * x_46_re) + Float64(x_46_im * x_46_re)) * x_46_im)) <= -5e-324) tmp = Float64(Float64(Float64(x_46_im * x_46_re) * 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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324) tmp = ((x_46_im * x_46_re) * 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$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], -5e-324], N[(N[(N[(x$46$im * x$46$re), $MachinePrecision] * x$46$im), $MachinePrecision] * -3.0), $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.im \cdot x.re + x.im \cdot x.re\right) \cdot x.im \leq -5 \cdot 10^{-324}:\\
\;\;\;\;\left(\left(x.im \cdot x.re\right) \cdot x.im\right) \cdot -3\\
\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)) < -4.94066e-324Initial program 93.9%
Taylor expanded in x.im around inf
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6452.1
Applied rewrites52.1%
Applied rewrites57.9%
if -4.94066e-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 76.5%
lift-*.f64N/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
Applied rewrites34.7%
Taylor expanded in x.im around 0
+-commutativeN/A
mul-1-negN/A
unpow3N/A
unpow2N/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
distribute-rgt-out--N/A
distribute-rgt-inN/A
associate--l+N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.3%
Taylor expanded in x.im around 0
Applied rewrites60.5%
Final simplification59.5%
(FPCore (x.re x.im)
:precision binary64
(if (<=
(-
(* (- (* x.re x.re) (* x.im x.im)) x.re)
(* (+ (* x.im x.re) (* x.im x.re)) x.im))
-5e-324)
(* (* (* 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_im * x_46_im)) * x_46_re) - (((x_46_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324) {
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_46im * x_46im)) * x_46re) - (((x_46im * x_46re) + (x_46im * x_46re)) * x_46im)) <= (-5d-324)) 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_im * x_46_im)) * x_46_re) - (((x_46_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324) {
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_im * x_46_im)) * x_46_re) - (((x_46_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324: 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(Float64(Float64(x_46_re * x_46_re) - Float64(x_46_im * x_46_im)) * x_46_re) - Float64(Float64(Float64(x_46_im * x_46_re) + Float64(x_46_im * x_46_re)) * x_46_im)) <= -5e-324) tmp = Float64(Float64(Float64(x_46_im * x_46_im) * x_46_re) * -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_im * x_46_re) + (x_46_im * x_46_re)) * x_46_im)) <= -5e-324) 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[(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$im * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$re), $MachinePrecision]), $MachinePrecision] * x$46$im), $MachinePrecision]), $MachinePrecision], -5e-324], N[(N[(N[(x$46$im * x$46$im), $MachinePrecision] * x$46$re), $MachinePrecision] * -3.0), $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.im \cdot x.re + x.im \cdot x.re\right) \cdot x.im \leq -5 \cdot 10^{-324}:\\
\;\;\;\;\left(\left(x.im \cdot x.im\right) \cdot x.re\right) \cdot -3\\
\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)) < -4.94066e-324Initial program 93.9%
Taylor expanded in x.im around inf
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6452.1
Applied rewrites52.1%
if -4.94066e-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 76.5%
lift-*.f64N/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
Applied rewrites34.7%
Taylor expanded in x.im around 0
+-commutativeN/A
mul-1-negN/A
unpow3N/A
unpow2N/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
distribute-rgt-out--N/A
distribute-rgt-inN/A
associate--l+N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites85.3%
Taylor expanded in x.im around 0
Applied rewrites60.5%
Final simplification57.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(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 83.1%
lift-*.f64N/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
pow2N/A
lift-*.f64N/A
pow-prod-downN/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
Applied rewrites36.5%
Taylor expanded in x.im around 0
+-commutativeN/A
mul-1-negN/A
unpow3N/A
unpow2N/A
distribute-rgt-neg-inN/A
distribute-rgt1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*l*N/A
metadata-evalN/A
distribute-rgt-out--N/A
distribute-rgt-inN/A
associate--l+N/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.5%
Taylor expanded in x.im around 0
Applied rewrites54.1%
(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 83.1%
Taylor expanded in x.im around 0
unpow2N/A
lower-*.f6461.9
Applied rewrites61.9%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
flip-+N/A
+-inversesN/A
metadata-evalN/A
+-inversesN/A
distribute-neg-fracN/A
+-inversesN/A
+-inversesN/A
flip-+N/A
distribute-neg-inN/A
lower-+.f64N/A
lower-neg.f64N/A
lower-neg.f6453.6
Applied rewrites53.6%
Taylor expanded in x.im around inf
distribute-rgt-out--N/A
metadata-evalN/A
*-rgt-identityN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6422.8
Applied rewrites22.8%
(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 2024250
(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)))