
(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)
use fmin_fmax_functions
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]
\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
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im) :precision binary64 (- (* (- (* x.re x.re) (* x.im x.im)) x.re) (* (+ (* x.re x.im) (* x.im x.re)) x.im)))
double code(double x_46_re, double x_46_im) {
return (((x_46_re * x_46_re) - (x_46_im * x_46_im)) * x_46_re) - (((x_46_re * x_46_im) + (x_46_im * x_46_re)) * x_46_im);
}
real(8) function code(x_46re, x_46im)
use fmin_fmax_functions
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]
\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
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* (fabs x.re) (fabs x.re))))
(*
(copysign 1.0 x.re)
(if (<= (fabs x.re) 2.5e-104)
(fma (* (* x.im (fabs x.re)) -3.0) x.im (* t_0 (fabs x.re)))
(if (<= (fabs x.re) 5.8e+222)
(*
(fabs x.re)
(fma (fabs x.re) (fabs x.re) (* -3.0 (* x.im x.im))))
(* (fabs x.re) (fma (* -3.0 x.im) x.im t_0)))))))double code(double x_46_re, double x_46_im) {
double t_0 = fabs(x_46_re) * fabs(x_46_re);
double tmp;
if (fabs(x_46_re) <= 2.5e-104) {
tmp = fma(((x_46_im * fabs(x_46_re)) * -3.0), x_46_im, (t_0 * fabs(x_46_re)));
} else if (fabs(x_46_re) <= 5.8e+222) {
tmp = fabs(x_46_re) * fma(fabs(x_46_re), fabs(x_46_re), (-3.0 * (x_46_im * x_46_im)));
} else {
tmp = fabs(x_46_re) * fma((-3.0 * x_46_im), x_46_im, t_0);
}
return copysign(1.0, x_46_re) * tmp;
}
function code(x_46_re, x_46_im) t_0 = Float64(abs(x_46_re) * abs(x_46_re)) tmp = 0.0 if (abs(x_46_re) <= 2.5e-104) tmp = fma(Float64(Float64(x_46_im * abs(x_46_re)) * -3.0), x_46_im, Float64(t_0 * abs(x_46_re))); elseif (abs(x_46_re) <= 5.8e+222) tmp = Float64(abs(x_46_re) * fma(abs(x_46_re), abs(x_46_re), Float64(-3.0 * Float64(x_46_im * x_46_im)))); else tmp = Float64(abs(x_46_re) * fma(Float64(-3.0 * x_46_im), x_46_im, t_0)); end return Float64(copysign(1.0, x_46_re) * tmp) end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[Abs[x$46$re], $MachinePrecision] * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x$46$re], $MachinePrecision], 2.5e-104], N[(N[(N[(x$46$im * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision] * -3.0), $MachinePrecision] * x$46$im + N[(t$95$0 * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[x$46$re], $MachinePrecision], 5.8e+222], N[(N[Abs[x$46$re], $MachinePrecision] * N[(N[Abs[x$46$re], $MachinePrecision] * N[Abs[x$46$re], $MachinePrecision] + N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[x$46$re], $MachinePrecision] * N[(N[(-3.0 * x$46$im), $MachinePrecision] * x$46$im + t$95$0), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|x.re\right| \cdot \left|x.re\right|\\
\mathsf{copysign}\left(1, x.re\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x.re\right| \leq 2.5 \cdot 10^{-104}:\\
\;\;\;\;\mathsf{fma}\left(\left(x.im \cdot \left|x.re\right|\right) \cdot -3, x.im, t\_0 \cdot \left|x.re\right|\right)\\
\mathbf{elif}\;\left|x.re\right| \leq 5.8 \cdot 10^{+222}:\\
\;\;\;\;\left|x.re\right| \cdot \mathsf{fma}\left(\left|x.re\right|, \left|x.re\right|, -3 \cdot \left(x.im \cdot x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left|x.re\right| \cdot \mathsf{fma}\left(-3 \cdot x.im, x.im, t\_0\right)\\
\end{array}
\end{array}
if x.re < 2.4999999999999999e-104Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6488.1%
Applied rewrites88.1%
if 2.4999999999999999e-104 < x.re < 5.7999999999999996e222Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.8%
Applied rewrites90.8%
if 5.7999999999999996e222 < x.re Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6487.7%
Applied rewrites87.7%
lift-fma.f64N/A
lift-*.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
sqr-neg-revN/A
lift-*.f64N/A
lower-fma.f6490.7%
Applied rewrites90.7%
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* (fabs x.re) (fabs x.re))))
(*
(copysign 1.0 x.re)
(if (<= (fabs x.re) 5e+19)
(fma (* (* -3.0 x.im) (fabs x.re)) x.im (* t_0 (fabs x.re)))
(if (<= (fabs x.re) 5.8e+222)
(*
(fabs x.re)
(fma (fabs x.re) (fabs x.re) (* -3.0 (* x.im x.im))))
(* (fabs x.re) (fma (* -3.0 x.im) x.im t_0)))))))double code(double x_46_re, double x_46_im) {
double t_0 = fabs(x_46_re) * fabs(x_46_re);
double tmp;
if (fabs(x_46_re) <= 5e+19) {
tmp = fma(((-3.0 * x_46_im) * fabs(x_46_re)), x_46_im, (t_0 * fabs(x_46_re)));
} else if (fabs(x_46_re) <= 5.8e+222) {
tmp = fabs(x_46_re) * fma(fabs(x_46_re), fabs(x_46_re), (-3.0 * (x_46_im * x_46_im)));
} else {
tmp = fabs(x_46_re) * fma((-3.0 * x_46_im), x_46_im, t_0);
}
return copysign(1.0, x_46_re) * tmp;
}
function code(x_46_re, x_46_im) t_0 = Float64(abs(x_46_re) * abs(x_46_re)) tmp = 0.0 if (abs(x_46_re) <= 5e+19) tmp = fma(Float64(Float64(-3.0 * x_46_im) * abs(x_46_re)), x_46_im, Float64(t_0 * abs(x_46_re))); elseif (abs(x_46_re) <= 5.8e+222) tmp = Float64(abs(x_46_re) * fma(abs(x_46_re), abs(x_46_re), Float64(-3.0 * Float64(x_46_im * x_46_im)))); else tmp = Float64(abs(x_46_re) * fma(Float64(-3.0 * x_46_im), x_46_im, t_0)); end return Float64(copysign(1.0, x_46_re) * tmp) end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[Abs[x$46$re], $MachinePrecision] * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x$46$re], $MachinePrecision], 5e+19], N[(N[(N[(-3.0 * x$46$im), $MachinePrecision] * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision] * x$46$im + N[(t$95$0 * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[x$46$re], $MachinePrecision], 5.8e+222], N[(N[Abs[x$46$re], $MachinePrecision] * N[(N[Abs[x$46$re], $MachinePrecision] * N[Abs[x$46$re], $MachinePrecision] + N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[x$46$re], $MachinePrecision] * N[(N[(-3.0 * x$46$im), $MachinePrecision] * x$46$im + t$95$0), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|x.re\right| \cdot \left|x.re\right|\\
\mathsf{copysign}\left(1, x.re\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x.re\right| \leq 5 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(\left(-3 \cdot x.im\right) \cdot \left|x.re\right|, x.im, t\_0 \cdot \left|x.re\right|\right)\\
\mathbf{elif}\;\left|x.re\right| \leq 5.8 \cdot 10^{+222}:\\
\;\;\;\;\left|x.re\right| \cdot \mathsf{fma}\left(\left|x.re\right|, \left|x.re\right|, -3 \cdot \left(x.im \cdot x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left|x.re\right| \cdot \mathsf{fma}\left(-3 \cdot x.im, x.im, t\_0\right)\\
\end{array}
\end{array}
if x.re < 5e19Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6487.7%
Applied rewrites87.7%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
distribute-rgt-inN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f6488.1%
Applied rewrites88.1%
if 5e19 < x.re < 5.7999999999999996e222Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.8%
Applied rewrites90.8%
if 5.7999999999999996e222 < x.re Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6487.7%
Applied rewrites87.7%
lift-fma.f64N/A
lift-*.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
sqr-neg-revN/A
lift-*.f64N/A
lower-fma.f6490.7%
Applied rewrites90.7%
(FPCore (x.re x.im)
:precision binary64
(let* ((t_0 (* (fabs x.re) (fabs x.re))))
(*
(copysign 1.0 x.re)
(if (<= (fabs x.re) 5e+19)
(fma (* -3.0 x.im) (* x.im (fabs x.re)) (* t_0 (fabs x.re)))
(if (<= (fabs x.re) 5.8e+222)
(*
(fabs x.re)
(fma (fabs x.re) (fabs x.re) (* -3.0 (* x.im x.im))))
(* (fabs x.re) (fma (* -3.0 x.im) x.im t_0)))))))double code(double x_46_re, double x_46_im) {
double t_0 = fabs(x_46_re) * fabs(x_46_re);
double tmp;
if (fabs(x_46_re) <= 5e+19) {
tmp = fma((-3.0 * x_46_im), (x_46_im * fabs(x_46_re)), (t_0 * fabs(x_46_re)));
} else if (fabs(x_46_re) <= 5.8e+222) {
tmp = fabs(x_46_re) * fma(fabs(x_46_re), fabs(x_46_re), (-3.0 * (x_46_im * x_46_im)));
} else {
tmp = fabs(x_46_re) * fma((-3.0 * x_46_im), x_46_im, t_0);
}
return copysign(1.0, x_46_re) * tmp;
}
function code(x_46_re, x_46_im) t_0 = Float64(abs(x_46_re) * abs(x_46_re)) tmp = 0.0 if (abs(x_46_re) <= 5e+19) tmp = fma(Float64(-3.0 * x_46_im), Float64(x_46_im * abs(x_46_re)), Float64(t_0 * abs(x_46_re))); elseif (abs(x_46_re) <= 5.8e+222) tmp = Float64(abs(x_46_re) * fma(abs(x_46_re), abs(x_46_re), Float64(-3.0 * Float64(x_46_im * x_46_im)))); else tmp = Float64(abs(x_46_re) * fma(Float64(-3.0 * x_46_im), x_46_im, t_0)); end return Float64(copysign(1.0, x_46_re) * tmp) end
code[x$46$re_, x$46$im_] := Block[{t$95$0 = N[(N[Abs[x$46$re], $MachinePrecision] * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x$46$re], $MachinePrecision], 5e+19], N[(N[(-3.0 * x$46$im), $MachinePrecision] * N[(x$46$im * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[x$46$re], $MachinePrecision], 5.8e+222], N[(N[Abs[x$46$re], $MachinePrecision] * N[(N[Abs[x$46$re], $MachinePrecision] * N[Abs[x$46$re], $MachinePrecision] + N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[x$46$re], $MachinePrecision] * N[(N[(-3.0 * x$46$im), $MachinePrecision] * x$46$im + t$95$0), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|x.re\right| \cdot \left|x.re\right|\\
\mathsf{copysign}\left(1, x.re\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x.re\right| \leq 5 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(-3 \cdot x.im, x.im \cdot \left|x.re\right|, t\_0 \cdot \left|x.re\right|\right)\\
\mathbf{elif}\;\left|x.re\right| \leq 5.8 \cdot 10^{+222}:\\
\;\;\;\;\left|x.re\right| \cdot \mathsf{fma}\left(\left|x.re\right|, \left|x.re\right|, -3 \cdot \left(x.im \cdot x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left|x.re\right| \cdot \mathsf{fma}\left(-3 \cdot x.im, x.im, t\_0\right)\\
\end{array}
\end{array}
if x.re < 5e19Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f6488.1%
Applied rewrites88.1%
if 5e19 < x.re < 5.7999999999999996e222Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.8%
Applied rewrites90.8%
if 5.7999999999999996e222 < x.re Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6487.7%
Applied rewrites87.7%
lift-fma.f64N/A
lift-*.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
sqr-neg-revN/A
lift-*.f64N/A
lower-fma.f6490.7%
Applied rewrites90.7%
(FPCore (x.re x.im)
:precision binary64
(*
(copysign 1.0 x.re)
(if (<= (fabs x.re) 5.8e+222)
(*
(fabs x.re)
(fma (fabs x.re) (fabs x.re) (* -3.0 (* x.im x.im))))
(*
(fabs x.re)
(fma (* -3.0 x.im) x.im (* (fabs x.re) (fabs x.re)))))))double code(double x_46_re, double x_46_im) {
double tmp;
if (fabs(x_46_re) <= 5.8e+222) {
tmp = fabs(x_46_re) * fma(fabs(x_46_re), fabs(x_46_re), (-3.0 * (x_46_im * x_46_im)));
} else {
tmp = fabs(x_46_re) * fma((-3.0 * x_46_im), x_46_im, (fabs(x_46_re) * fabs(x_46_re)));
}
return copysign(1.0, x_46_re) * tmp;
}
function code(x_46_re, x_46_im) tmp = 0.0 if (abs(x_46_re) <= 5.8e+222) tmp = Float64(abs(x_46_re) * fma(abs(x_46_re), abs(x_46_re), Float64(-3.0 * Float64(x_46_im * x_46_im)))); else tmp = Float64(abs(x_46_re) * fma(Float64(-3.0 * x_46_im), x_46_im, Float64(abs(x_46_re) * abs(x_46_re)))); end return Float64(copysign(1.0, x_46_re) * tmp) end
code[x$46$re_, x$46$im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x$46$re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[x$46$re], $MachinePrecision], 5.8e+222], N[(N[Abs[x$46$re], $MachinePrecision] * N[(N[Abs[x$46$re], $MachinePrecision] * N[Abs[x$46$re], $MachinePrecision] + N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[x$46$re], $MachinePrecision] * N[(N[(-3.0 * x$46$im), $MachinePrecision] * x$46$im + N[(N[Abs[x$46$re], $MachinePrecision] * N[Abs[x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, x.re\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|x.re\right| \leq 5.8 \cdot 10^{+222}:\\
\;\;\;\;\left|x.re\right| \cdot \mathsf{fma}\left(\left|x.re\right|, \left|x.re\right|, -3 \cdot \left(x.im \cdot x.im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left|x.re\right| \cdot \mathsf{fma}\left(-3 \cdot x.im, x.im, \left|x.re\right| \cdot \left|x.re\right|\right)\\
\end{array}
if x.re < 5.7999999999999996e222Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.8%
Applied rewrites90.8%
if 5.7999999999999996e222 < x.re Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6487.7%
Applied rewrites87.7%
lift-fma.f64N/A
lift-*.f64N/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
sqr-neg-revN/A
lift-*.f64N/A
lower-fma.f6490.7%
Applied rewrites90.7%
(FPCore (x.re x.im) :precision binary64 (* x.re (fma x.re x.re (* -3.0 (* x.im x.im)))))
double code(double x_46_re, double x_46_im) {
return x_46_re * fma(x_46_re, x_46_re, (-3.0 * (x_46_im * x_46_im)));
}
function code(x_46_re, x_46_im) return Float64(x_46_re * fma(x_46_re, x_46_re, Float64(-3.0 * Float64(x_46_im * x_46_im)))) end
code[x$46$re_, x$46$im_] := 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]
x.re \cdot \mathsf{fma}\left(x.re, x.re, -3 \cdot \left(x.im \cdot x.im\right)\right)
Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f64N/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6490.8%
Applied rewrites90.8%
(FPCore (x.re x.im) :precision binary64 (* x.re (fma -3.0 (* x.im x.im) (* x.re x.re))))
double code(double x_46_re, double x_46_im) {
return x_46_re * fma(-3.0, (x_46_im * x_46_im), (x_46_re * x_46_re));
}
function code(x_46_re, x_46_im) return Float64(x_46_re * fma(-3.0, Float64(x_46_im * x_46_im), Float64(x_46_re * x_46_re))) end
code[x$46$re_, x$46$im_] := N[(x$46$re * N[(-3.0 * N[(x$46$im * x$46$im), $MachinePrecision] + N[(x$46$re * x$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x.re \cdot \mathsf{fma}\left(-3, x.im \cdot x.im, x.re \cdot x.re\right)
Initial program 82.4%
Taylor expanded in x.im around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6485.3%
Applied rewrites85.3%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
metadata-eval80.1%
lift-pow.f64N/A
unpow3N/A
lift-*.f64N/A
lower-*.f6480.0%
Applied rewrites80.0%
lift-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6487.7%
Applied rewrites87.7%
(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)
use fmin_fmax_functions
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]
\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)
herbie shell --seed 2025313 -o setup:search
(FPCore (x.re x.im)
:name "math.cube on complex, real part"
:precision binary64
:alt
(! :herbie-platform c (+ (* (* 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)))