
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
(FPCore (re im) :precision binary64 (* (cos im) (exp re)))
double code(double re, double im) {
return cos(im) * exp(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(im) * exp(re)
end function
public static double code(double re, double im) {
return Math.cos(im) * Math.exp(re);
}
def code(re, im): return math.cos(im) * math.exp(re)
function code(re, im) return Float64(cos(im) * exp(re)) end
function tmp = code(re, im) tmp = cos(im) * exp(re); end
code[re_, im_] := N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos im \cdot e^{re}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ 1.0 re) (cos im)))
(t_1 (* (cos im) (exp re)))
(t_2 (* (* (* im im) -0.5) (exp re))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -0.01)
t_0
(if (<= t_1 0.0)
t_2
(if (<= t_1 0.999)
t_0
(*
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0))))))))
double code(double re, double im) {
double t_0 = (1.0 + re) * cos(im);
double t_1 = cos(im) * exp(re);
double t_2 = ((im * im) * -0.5) * exp(re);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -0.01) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 0.999) {
tmp = t_0;
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(1.0 + re) * cos(im)) t_1 = Float64(cos(im) * exp(re)) t_2 = Float64(Float64(Float64(im * im) * -0.5) * exp(re)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= -0.01) tmp = t_0; elseif (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= 0.999) tmp = t_0; else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, -0.01], t$95$0, If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, 0.999], t$95$0, N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + re\right) \cdot \cos im\\
t_1 := \cos im \cdot e^{re}\\
t_2 := \left(\left(im \cdot im\right) \cdot -0.5\right) \cdot e^{re}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -0.01:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.999:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0 or -0.0100000000000000002 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.9
Applied rewrites78.9%
Taylor expanded in im around inf
Applied rewrites78.9%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < -0.0100000000000000002 or 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.998999999999999999Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6496.9
Applied rewrites96.9%
if 0.998999999999999999 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.9
Applied rewrites84.9%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.9
Applied rewrites87.9%
Final simplification87.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ 1.0 re) (cos im)))
(t_1 (* (cos im) (exp re)))
(t_2 (fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0)))
(if (<= t_1 (- INFINITY))
(*
(fma
(fma
(fma -0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
-0.5)
(* im im)
1.0)
t_2)
(if (<= t_1 -0.01)
t_0
(if (<= t_1 0.0)
(* (* (pow im 4.0) 0.041666666666666664) (+ 1.0 re))
(if (<= t_1 0.999)
t_0
(*
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)
t_2)))))))
double code(double re, double im) {
double t_0 = (1.0 + re) * cos(im);
double t_1 = cos(im) * exp(re);
double t_2 = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(fma(fma(-0.001388888888888889, (im * im), 0.041666666666666664), (im * im), -0.5), (im * im), 1.0) * t_2;
} else if (t_1 <= -0.01) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = (pow(im, 4.0) * 0.041666666666666664) * (1.0 + re);
} else if (t_1 <= 0.999) {
tmp = t_0;
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0) * t_2;
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(1.0 + re) * cos(im)) t_1 = Float64(cos(im) * exp(re)) t_2 = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(fma(fma(fma(-0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), -0.5), Float64(im * im), 1.0) * t_2); elseif (t_1 <= -0.01) tmp = t_0; elseif (t_1 <= 0.0) tmp = Float64(Float64((im ^ 4.0) * 0.041666666666666664) * Float64(1.0 + re)); elseif (t_1 <= 0.999) tmp = t_0; else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0) * t_2); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(N[(-0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$1, -0.01], t$95$0, If[LessEqual[t$95$1, 0.0], N[(N[(N[Power[im, 4.0], $MachinePrecision] * 0.041666666666666664), $MachinePrecision] * N[(1.0 + re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.999], t$95$0, N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + re\right) \cdot \cos im\\
t_1 := \cos im \cdot e^{re}\\
t_2 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot t\_2\\
\mathbf{elif}\;t\_1 \leq -0.01:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\left({im}^{4} \cdot 0.041666666666666664\right) \cdot \left(1 + re\right)\\
\mathbf{elif}\;t\_1 \leq 0.999:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot t\_2\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6466.4
Applied rewrites66.4%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.8
Applied rewrites90.8%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < -0.0100000000000000002 or 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.998999999999999999Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6496.9
Applied rewrites96.9%
if -0.0100000000000000002 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-+.f642.2
Applied rewrites2.2%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f641.9
Applied rewrites1.9%
Taylor expanded in im around inf
Applied rewrites29.1%
if 0.998999999999999999 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.9
Applied rewrites84.9%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.9
Applied rewrites87.9%
Final simplification75.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (+ 1.0 re) (cos im)))
(t_1 (* (cos im) (exp re)))
(t_2 (fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0)))
(if (<= t_1 (- INFINITY))
(*
(fma
(fma
(fma -0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
-0.5)
(* im im)
1.0)
t_2)
(if (<= t_1 -0.01)
t_0
(if (<= t_1 0.0)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(if (<= t_1 0.999)
t_0
(*
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)
t_2)))))))
double code(double re, double im) {
double t_0 = (1.0 + re) * cos(im);
double t_1 = cos(im) * exp(re);
double t_2 = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = fma(fma(fma(-0.001388888888888889, (im * im), 0.041666666666666664), (im * im), -0.5), (im * im), 1.0) * t_2;
} else if (t_1 <= -0.01) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else if (t_1 <= 0.999) {
tmp = t_0;
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0) * t_2;
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(1.0 + re) * cos(im)) t_1 = Float64(cos(im) * exp(re)) t_2 = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(fma(fma(fma(-0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), -0.5), Float64(im * im), 1.0) * t_2); elseif (t_1 <= -0.01) tmp = t_0; elseif (t_1 <= 0.0) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); elseif (t_1 <= 0.999) tmp = t_0; else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0) * t_2); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(N[(-0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[t$95$1, -0.01], t$95$0, If[LessEqual[t$95$1, 0.0], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[t$95$1, 0.999], t$95$0, N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + re\right) \cdot \cos im\\
t_1 := \cos im \cdot e^{re}\\
t_2 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot t\_2\\
\mathbf{elif}\;t\_1 \leq -0.01:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{elif}\;t\_1 \leq 0.999:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot t\_2\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6466.4
Applied rewrites66.4%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.8
Applied rewrites90.8%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < -0.0100000000000000002 or 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.998999999999999999Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6496.9
Applied rewrites96.9%
if -0.0100000000000000002 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f643.2
Applied rewrites3.2%
Taylor expanded in im around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites17.4%
Applied rewrites17.9%
if 0.998999999999999999 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.9
Applied rewrites84.9%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.9
Applied rewrites87.9%
Final simplification73.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (cos im) (exp re)))
(t_1 (fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0)))
(if (<= t_0 (- INFINITY))
(*
(fma
(fma
(fma -0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
-0.5)
(* im im)
1.0)
t_1)
(if (<= t_0 -4e-24)
(cos im)
(if (<= t_0 0.0)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(if (<= t_0 0.999)
(cos im)
(*
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)
t_1)))))))
double code(double re, double im) {
double t_0 = cos(im) * exp(re);
double t_1 = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma(fma(fma(-0.001388888888888889, (im * im), 0.041666666666666664), (im * im), -0.5), (im * im), 1.0) * t_1;
} else if (t_0 <= -4e-24) {
tmp = cos(im);
} else if (t_0 <= 0.0) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else if (t_0 <= 0.999) {
tmp = cos(im);
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0) * t_1;
}
return tmp;
}
function code(re, im) t_0 = Float64(cos(im) * exp(re)) t_1 = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(fma(fma(fma(-0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), -0.5), Float64(im * im), 1.0) * t_1); elseif (t_0 <= -4e-24) tmp = cos(im); elseif (t_0 <= 0.0) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); elseif (t_0 <= 0.999) tmp = cos(im); else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0) * t_1); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(N[(-0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, -4e-24], N[Cos[im], $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[t$95$0, 0.999], N[Cos[im], $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos im \cdot e^{re}\\
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq -4 \cdot 10^{-24}:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{elif}\;t\_0 \leq 0.999:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6466.4
Applied rewrites66.4%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.8
Applied rewrites90.8%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < -3.99999999999999969e-24 or 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.998999999999999999Initial program 99.9%
Taylor expanded in re around 0
lower-cos.f6494.5
Applied rewrites94.5%
if -3.99999999999999969e-24 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f643.1
Applied rewrites3.1%
Taylor expanded in im around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites17.6%
Applied rewrites18.1%
if 0.998999999999999999 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6484.9
Applied rewrites84.9%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.9
Applied rewrites87.9%
Final simplification72.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (fma 0.041666666666666664 (* im im) -0.5))
(t_1 (* (cos im) (exp re))))
(if (<= t_1 -0.2)
(*
(fma (* im im) -0.5 1.0)
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0))
(if (<= t_1 0.0)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(if (<= t_1 2.0)
(* (fma (* t_0 im) im 1.0) (+ 1.0 re))
(* (* (fma 0.5 re 1.0) re) (fma t_0 (* im im) 1.0)))))))
double code(double re, double im) {
double t_0 = fma(0.041666666666666664, (im * im), -0.5);
double t_1 = cos(im) * exp(re);
double tmp;
if (t_1 <= -0.2) {
tmp = fma((im * im), -0.5, 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
} else if (t_1 <= 0.0) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else if (t_1 <= 2.0) {
tmp = fma((t_0 * im), im, 1.0) * (1.0 + re);
} else {
tmp = (fma(0.5, re, 1.0) * re) * fma(t_0, (im * im), 1.0);
}
return tmp;
}
function code(re, im) t_0 = fma(0.041666666666666664, Float64(im * im), -0.5) t_1 = Float64(cos(im) * exp(re)) tmp = 0.0 if (t_1 <= -0.2) tmp = Float64(fma(Float64(im * im), -0.5, 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0)); elseif (t_1 <= 0.0) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); elseif (t_1 <= 2.0) tmp = Float64(fma(Float64(t_0 * im), im, 1.0) * Float64(1.0 + re)); else tmp = Float64(Float64(fma(0.5, re, 1.0) * re) * fma(t_0, Float64(im * im), 1.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.2], N[(N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(N[(N[(t$95$0 * im), $MachinePrecision] * im + 1.0), $MachinePrecision] * N[(1.0 + re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 * re + 1.0), $MachinePrecision] * re), $MachinePrecision] * N[(t$95$0 * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right)\\
t_1 := \cos im \cdot e^{re}\\
\mathbf{if}\;t\_1 \leq -0.2:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.5, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot im, im, 1\right) \cdot \left(1 + re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.5, re, 1\right) \cdot re\right) \cdot \mathsf{fma}\left(t\_0, im \cdot im, 1\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -0.20000000000000001Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6485.2
Applied rewrites85.2%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6436.7
Applied rewrites36.7%
if -0.20000000000000001 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f646.3
Applied rewrites6.3%
Taylor expanded in im around 0
Applied rewrites2.6%
Taylor expanded in im around inf
Applied rewrites16.8%
Applied rewrites17.3%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 2Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6499.1
Applied rewrites99.1%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.9
Applied rewrites55.9%
Applied rewrites55.9%
if 2 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6458.4
Applied rewrites58.4%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6462.9
Applied rewrites62.9%
Taylor expanded in re around inf
Applied rewrites62.8%
Final simplification43.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (fma 0.041666666666666664 (* im im) -0.5))
(t_1 (* (cos im) (exp re))))
(if (<= t_1 -0.2)
(*
(fma (* im im) -0.5 1.0)
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0))
(if (<= t_1 0.0)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(if (<= t_1 2.0)
(* (fma (* t_0 im) im 1.0) (+ 1.0 re))
(* (fma t_0 (* im im) 1.0) (* (* re re) 0.5)))))))
double code(double re, double im) {
double t_0 = fma(0.041666666666666664, (im * im), -0.5);
double t_1 = cos(im) * exp(re);
double tmp;
if (t_1 <= -0.2) {
tmp = fma((im * im), -0.5, 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
} else if (t_1 <= 0.0) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else if (t_1 <= 2.0) {
tmp = fma((t_0 * im), im, 1.0) * (1.0 + re);
} else {
tmp = fma(t_0, (im * im), 1.0) * ((re * re) * 0.5);
}
return tmp;
}
function code(re, im) t_0 = fma(0.041666666666666664, Float64(im * im), -0.5) t_1 = Float64(cos(im) * exp(re)) tmp = 0.0 if (t_1 <= -0.2) tmp = Float64(fma(Float64(im * im), -0.5, 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0)); elseif (t_1 <= 0.0) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); elseif (t_1 <= 2.0) tmp = Float64(fma(Float64(t_0 * im), im, 1.0) * Float64(1.0 + re)); else tmp = Float64(fma(t_0, Float64(im * im), 1.0) * Float64(Float64(re * re) * 0.5)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.2], N[(N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(N[(N[(t$95$0 * im), $MachinePrecision] * im + 1.0), $MachinePrecision] * N[(1.0 + re), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right)\\
t_1 := \cos im \cdot e^{re}\\
\mathbf{if}\;t\_1 \leq -0.2:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.5, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot im, im, 1\right) \cdot \left(1 + re\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0, im \cdot im, 1\right) \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -0.20000000000000001Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6485.2
Applied rewrites85.2%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6436.7
Applied rewrites36.7%
if -0.20000000000000001 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f646.3
Applied rewrites6.3%
Taylor expanded in im around 0
Applied rewrites2.6%
Taylor expanded in im around inf
Applied rewrites16.8%
Applied rewrites17.3%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 2Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6499.1
Applied rewrites99.1%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6455.9
Applied rewrites55.9%
Applied rewrites55.9%
if 2 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6458.4
Applied rewrites58.4%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6462.9
Applied rewrites62.9%
Taylor expanded in re around inf
Applied rewrites62.8%
Final simplification43.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0))
(t_1 (* (cos im) (exp re))))
(if (<= t_1 -500.0)
(*
(fma
(fma
(fma -0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
-0.5)
(* im im)
1.0)
t_0)
(if (<= t_1 0.0)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(*
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)
t_0)))))
double code(double re, double im) {
double t_0 = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
double t_1 = cos(im) * exp(re);
double tmp;
if (t_1 <= -500.0) {
tmp = fma(fma(fma(-0.001388888888888889, (im * im), 0.041666666666666664), (im * im), -0.5), (im * im), 1.0) * t_0;
} else if (t_1 <= 0.0) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0) * t_0;
}
return tmp;
}
function code(re, im) t_0 = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) t_1 = Float64(cos(im) * exp(re)) tmp = 0.0 if (t_1 <= -500.0) tmp = Float64(fma(fma(fma(-0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), -0.5), Float64(im * im), 1.0) * t_0); elseif (t_1 <= 0.0) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0) * t_0); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -500.0], N[(N[(N[(N[(-0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
t_1 := \cos im \cdot e^{re}\\
\mathbf{if}\;t\_1 \leq -500:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -500Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6464.0
Applied rewrites64.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6486.6
Applied rewrites86.6%
if -500 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f6433.5
Applied rewrites33.5%
Taylor expanded in im around 0
Applied rewrites3.3%
Taylor expanded in im around inf
Applied rewrites13.2%
Applied rewrites13.5%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6489.5
Applied rewrites89.5%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
Final simplification45.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (cos im) (exp re))))
(if (<= t_0 -500.0)
(*
(fma
(fma
(fma -0.001388888888888889 (* im im) 0.041666666666666664)
(* im im)
-0.5)
(* im im)
1.0)
(fma (fma 0.5 re 1.0) re 1.0))
(if (<= t_0 0.0)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(*
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0))))))
double code(double re, double im) {
double t_0 = cos(im) * exp(re);
double tmp;
if (t_0 <= -500.0) {
tmp = fma(fma(fma(-0.001388888888888889, (im * im), 0.041666666666666664), (im * im), -0.5), (im * im), 1.0) * fma(fma(0.5, re, 1.0), re, 1.0);
} else if (t_0 <= 0.0) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(cos(im) * exp(re)) tmp = 0.0 if (t_0 <= -500.0) tmp = Float64(fma(fma(fma(-0.001388888888888889, Float64(im * im), 0.041666666666666664), Float64(im * im), -0.5), Float64(im * im), 1.0) * fma(fma(0.5, re, 1.0), re, 1.0)); elseif (t_0 <= 0.0) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -500.0], N[(N[(N[(N[(-0.001388888888888889 * N[(im * im), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(0.5 * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos im \cdot e^{re}\\
\mathbf{if}\;t\_0 \leq -500:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889, im \cdot im, 0.041666666666666664\right), im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, re, 1\right), re, 1\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -500Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6446.5
Applied rewrites46.5%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6486.5
Applied rewrites86.5%
if -500 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f6433.5
Applied rewrites33.5%
Taylor expanded in im around 0
Applied rewrites3.3%
Taylor expanded in im around inf
Applied rewrites13.2%
Applied rewrites13.5%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6489.5
Applied rewrites89.5%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
Final simplification45.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (cos im) (exp re))))
(if (<= t_0 (- INFINITY))
(*
(fma
(fma (* -0.001388888888888889 (* im im)) (* im im) -0.5)
(* im im)
1.0)
(+ 1.0 re))
(if (<= t_0 0.0)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(*
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0))))))
double code(double re, double im) {
double t_0 = cos(im) * exp(re);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma(fma((-0.001388888888888889 * (im * im)), (im * im), -0.5), (im * im), 1.0) * (1.0 + re);
} else if (t_0 <= 0.0) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(cos(im) * exp(re)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(fma(fma(Float64(-0.001388888888888889 * Float64(im * im)), Float64(im * im), -0.5), Float64(im * im), 1.0) * Float64(1.0 + re)); elseif (t_0 <= 0.0) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(N[(-0.001388888888888889 * N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(1.0 + re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos im \cdot e^{re}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889 \cdot \left(im \cdot im\right), im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot \left(1 + re\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0
lower-+.f644.9
Applied rewrites4.9%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.9
Applied rewrites85.9%
Taylor expanded in im around inf
Applied rewrites85.9%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f6433.3
Applied rewrites33.3%
Taylor expanded in im around 0
Applied rewrites3.3%
Taylor expanded in im around inf
Applied rewrites13.1%
Applied rewrites13.4%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6489.5
Applied rewrites89.5%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6462.6
Applied rewrites62.6%
Final simplification45.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (cos im) (exp re))))
(if (<= t_0 (- INFINITY))
(*
(fma
(fma (* -0.001388888888888889 (* im im)) (* im im) -0.5)
(* im im)
1.0)
(+ 1.0 re))
(if (<= t_0 0.0)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(*
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)
(fma (fma 0.5 re 1.0) re 1.0))))))
double code(double re, double im) {
double t_0 = cos(im) * exp(re);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma(fma((-0.001388888888888889 * (im * im)), (im * im), -0.5), (im * im), 1.0) * (1.0 + re);
} else if (t_0 <= 0.0) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0) * fma(fma(0.5, re, 1.0), re, 1.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(cos(im) * exp(re)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(fma(fma(Float64(-0.001388888888888889 * Float64(im * im)), Float64(im * im), -0.5), Float64(im * im), 1.0) * Float64(1.0 + re)); elseif (t_0 <= 0.0) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0) * fma(fma(0.5, re, 1.0), re, 1.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(N[(-0.001388888888888889 * N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(1.0 + re), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(0.5 * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos im \cdot e^{re}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(-0.001388888888888889 \cdot \left(im \cdot im\right), im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot \left(1 + re\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, re, 1\right), re, 1\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -inf.0Initial program 100.0%
Taylor expanded in re around 0
lower-+.f644.9
Applied rewrites4.9%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6485.9
Applied rewrites85.9%
Taylor expanded in im around inf
Applied rewrites85.9%
if -inf.0 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f6433.3
Applied rewrites33.3%
Taylor expanded in im around 0
Applied rewrites3.3%
Taylor expanded in im around inf
Applied rewrites13.1%
Applied rewrites13.4%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6485.9
Applied rewrites85.9%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6458.3
Applied rewrites58.3%
Final simplification43.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (cos im) (exp re))))
(if (<= t_0 -0.2)
(*
(fma (* im im) -0.5 1.0)
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0))
(if (<= t_0 0.0)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(*
(fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)
(fma (fma 0.5 re 1.0) re 1.0))))))
double code(double re, double im) {
double t_0 = cos(im) * exp(re);
double tmp;
if (t_0 <= -0.2) {
tmp = fma((im * im), -0.5, 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
} else if (t_0 <= 0.0) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0) * fma(fma(0.5, re, 1.0), re, 1.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(cos(im) * exp(re)) tmp = 0.0 if (t_0 <= -0.2) tmp = Float64(fma(Float64(im * im), -0.5, 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0)); elseif (t_0 <= 0.0) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); else tmp = Float64(fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0) * fma(fma(0.5, re, 1.0), re, 1.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], N[(N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(0.5 * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos im \cdot e^{re}\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.5, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.5, re, 1\right), re, 1\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < -0.20000000000000001Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6485.2
Applied rewrites85.2%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6436.7
Applied rewrites36.7%
if -0.20000000000000001 < (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f646.3
Applied rewrites6.3%
Taylor expanded in im around 0
Applied rewrites2.6%
Taylor expanded in im around inf
Applied rewrites16.8%
Applied rewrites17.3%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6485.9
Applied rewrites85.9%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
sub-negN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6458.3
Applied rewrites58.3%
Final simplification43.1%
(FPCore (re im) :precision binary64 (if (<= (* (cos im) (exp re)) 0.0) (* (* im im) -0.5) (fma (fma 0.041666666666666664 (* im im) -0.5) (* im im) 1.0)))
double code(double re, double im) {
double tmp;
if ((cos(im) * exp(re)) <= 0.0) {
tmp = (im * im) * -0.5;
} else {
tmp = fma(fma(0.041666666666666664, (im * im), -0.5), (im * im), 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(cos(im) * exp(re)) <= 0.0) tmp = Float64(Float64(im * im) * -0.5); else tmp = fma(fma(0.041666666666666664, Float64(im * im), -0.5), Float64(im * im), 1.0); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[Cos[im], $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(0.041666666666666664 * N[(im * im), $MachinePrecision] + -0.5), $MachinePrecision] * N[(im * im), $MachinePrecision] + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos im \cdot e^{re} \leq 0:\\
\;\;\;\;\left(im \cdot im\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.041666666666666664, im \cdot im, -0.5\right), im \cdot im, 1\right)\\
\end{array}
\end{array}
if (*.f64 (exp.f64 re) (cos.f64 im)) < 0.0Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f6428.2
Applied rewrites28.2%
Taylor expanded in im around 0
Applied rewrites12.4%
Taylor expanded in im around inf
Applied rewrites20.5%
if 0.0 < (*.f64 (exp.f64 re) (cos.f64 im)) Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f6467.2
Applied rewrites67.2%
Taylor expanded in im around 0
Applied rewrites45.4%
Final simplification33.8%
(FPCore (re im)
:precision binary64
(if (<= (exp re) 1e-23)
(* (/ 1.0 (/ 1.0 (* im im))) -0.5)
(*
(fma (* im im) -0.5 1.0)
(fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 1e-23) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else {
tmp = fma((im * im), -0.5, 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 1e-23) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); else tmp = Float64(fma(Float64(im * im), -0.5, 1.0) * fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 1e-23], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 10^{-23}:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.5, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 9.9999999999999996e-24Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f643.2
Applied rewrites3.2%
Taylor expanded in im around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites17.4%
Applied rewrites17.9%
if 9.9999999999999996e-24 < (exp.f64 re) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6488.1
Applied rewrites88.1%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6447.2
Applied rewrites47.2%
Final simplification39.8%
(FPCore (re im)
:precision binary64
(if (<= re -1.6)
(* (* (* im im) -0.5) (exp re))
(if (<= re 0.049)
(* (fma (fma (fma 0.16666666666666666 re 0.5) re 1.0) re 1.0) (cos im))
(if (<= re 1.02e+103)
(* (fma (* im im) -0.5 1.0) (exp re))
(* (* (* (fma 0.16666666666666666 re 0.5) re) re) (cos im))))))
double code(double re, double im) {
double tmp;
if (re <= -1.6) {
tmp = ((im * im) * -0.5) * exp(re);
} else if (re <= 0.049) {
tmp = fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * cos(im);
} else if (re <= 1.02e+103) {
tmp = fma((im * im), -0.5, 1.0) * exp(re);
} else {
tmp = ((fma(0.16666666666666666, re, 0.5) * re) * re) * cos(im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (re <= -1.6) tmp = Float64(Float64(Float64(im * im) * -0.5) * exp(re)); elseif (re <= 0.049) tmp = Float64(fma(fma(fma(0.16666666666666666, re, 0.5), re, 1.0), re, 1.0) * cos(im)); elseif (re <= 1.02e+103) tmp = Float64(fma(Float64(im * im), -0.5, 1.0) * exp(re)); else tmp = Float64(Float64(Float64(fma(0.16666666666666666, re, 0.5) * re) * re) * cos(im)); end return tmp end
code[re_, im_] := If[LessEqual[re, -1.6], N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.049], N[(N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.02e+103], N[(N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.6:\\
\;\;\;\;\left(\left(im \cdot im\right) \cdot -0.5\right) \cdot e^{re}\\
\mathbf{elif}\;re \leq 0.049:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right), re, 1\right), re, 1\right) \cdot \cos im\\
\mathbf{elif}\;re \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.5, 1\right) \cdot e^{re}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right) \cdot re\right) \cdot re\right) \cdot \cos im\\
\end{array}
\end{array}
if re < -1.6000000000000001Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6472.4
Applied rewrites72.4%
Taylor expanded in im around inf
Applied rewrites72.4%
if -1.6000000000000001 < re < 0.049000000000000002Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6499.3
Applied rewrites99.3%
if 0.049000000000000002 < re < 1.01999999999999991e103Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.5
Applied rewrites83.5%
if 1.01999999999999991e103 < re Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in re around inf
Applied rewrites100.0%
Final simplification91.1%
(FPCore (re im)
:precision binary64
(if (<= re -400.0)
(* (* (* im im) -0.5) (exp re))
(if (<= re 0.048)
(* (fma (* re re) 0.5 (+ 1.0 re)) (cos im))
(if (<= re 1.02e+103)
(* (fma (* im im) -0.5 1.0) (exp re))
(* (* (* (fma 0.16666666666666666 re 0.5) re) re) (cos im))))))
double code(double re, double im) {
double tmp;
if (re <= -400.0) {
tmp = ((im * im) * -0.5) * exp(re);
} else if (re <= 0.048) {
tmp = fma((re * re), 0.5, (1.0 + re)) * cos(im);
} else if (re <= 1.02e+103) {
tmp = fma((im * im), -0.5, 1.0) * exp(re);
} else {
tmp = ((fma(0.16666666666666666, re, 0.5) * re) * re) * cos(im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (re <= -400.0) tmp = Float64(Float64(Float64(im * im) * -0.5) * exp(re)); elseif (re <= 0.048) tmp = Float64(fma(Float64(re * re), 0.5, Float64(1.0 + re)) * cos(im)); elseif (re <= 1.02e+103) tmp = Float64(fma(Float64(im * im), -0.5, 1.0) * exp(re)); else tmp = Float64(Float64(Float64(fma(0.16666666666666666, re, 0.5) * re) * re) * cos(im)); end return tmp end
code[re_, im_] := If[LessEqual[re, -400.0], N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.048], N[(N[(N[(re * re), $MachinePrecision] * 0.5 + N[(1.0 + re), $MachinePrecision]), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.02e+103], N[(N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.16666666666666666 * re + 0.5), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -400:\\
\;\;\;\;\left(\left(im \cdot im\right) \cdot -0.5\right) \cdot e^{re}\\
\mathbf{elif}\;re \leq 0.048:\\
\;\;\;\;\mathsf{fma}\left(re \cdot re, 0.5, 1 + re\right) \cdot \cos im\\
\mathbf{elif}\;re \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.5, 1\right) \cdot e^{re}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(0.16666666666666666, re, 0.5\right) \cdot re\right) \cdot re\right) \cdot \cos im\\
\end{array}
\end{array}
if re < -400Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6473.4
Applied rewrites73.4%
Taylor expanded in im around inf
Applied rewrites73.4%
if -400 < re < 0.048000000000000001Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6498.5
Applied rewrites98.5%
Applied rewrites98.5%
if 0.048000000000000001 < re < 1.01999999999999991e103Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.5
Applied rewrites83.5%
if 1.01999999999999991e103 < re Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in re around inf
Applied rewrites100.0%
Final simplification91.1%
(FPCore (re im) :precision binary64 (if (<= (exp re) 1e-23) (* (/ 1.0 (/ 1.0 (* im im))) -0.5) (* (fma (fma 0.5 re 1.0) re 1.0) (fma (* im im) -0.5 1.0))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 1e-23) {
tmp = (1.0 / (1.0 / (im * im))) * -0.5;
} else {
tmp = fma(fma(0.5, re, 1.0), re, 1.0) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 1e-23) tmp = Float64(Float64(1.0 / Float64(1.0 / Float64(im * im))) * -0.5); else tmp = Float64(fma(fma(0.5, re, 1.0), re, 1.0) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 1e-23], N[(N[(1.0 / N[(1.0 / N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(N[(0.5 * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 10^{-23}:\\
\;\;\;\;\frac{1}{\frac{1}{im \cdot im}} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, re, 1\right), re, 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 9.9999999999999996e-24Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f643.2
Applied rewrites3.2%
Taylor expanded in im around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites17.4%
Applied rewrites17.9%
if 9.9999999999999996e-24 < (exp.f64 re) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6483.5
Applied rewrites83.5%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6445.1
Applied rewrites45.1%
(FPCore (re im)
:precision binary64
(if (<= re -400.0)
(* (* (* im im) -0.5) (exp re))
(if (<= re 0.048)
(* (fma (* re re) 0.5 (+ 1.0 re)) (cos im))
(if (<= re 1.35e+154)
(* (fma (* im im) -0.5 1.0) (exp re))
(* (* (* re re) 0.5) (cos im))))))
double code(double re, double im) {
double tmp;
if (re <= -400.0) {
tmp = ((im * im) * -0.5) * exp(re);
} else if (re <= 0.048) {
tmp = fma((re * re), 0.5, (1.0 + re)) * cos(im);
} else if (re <= 1.35e+154) {
tmp = fma((im * im), -0.5, 1.0) * exp(re);
} else {
tmp = ((re * re) * 0.5) * cos(im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (re <= -400.0) tmp = Float64(Float64(Float64(im * im) * -0.5) * exp(re)); elseif (re <= 0.048) tmp = Float64(fma(Float64(re * re), 0.5, Float64(1.0 + re)) * cos(im)); elseif (re <= 1.35e+154) tmp = Float64(fma(Float64(im * im), -0.5, 1.0) * exp(re)); else tmp = Float64(Float64(Float64(re * re) * 0.5) * cos(im)); end return tmp end
code[re_, im_] := If[LessEqual[re, -400.0], N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.048], N[(N[(N[(re * re), $MachinePrecision] * 0.5 + N[(1.0 + re), $MachinePrecision]), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], N[(N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -400:\\
\;\;\;\;\left(\left(im \cdot im\right) \cdot -0.5\right) \cdot e^{re}\\
\mathbf{elif}\;re \leq 0.048:\\
\;\;\;\;\mathsf{fma}\left(re \cdot re, 0.5, 1 + re\right) \cdot \cos im\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.5, 1\right) \cdot e^{re}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot \cos im\\
\end{array}
\end{array}
if re < -400Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6473.4
Applied rewrites73.4%
Taylor expanded in im around inf
Applied rewrites73.4%
if -400 < re < 0.048000000000000001Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6498.5
Applied rewrites98.5%
Applied rewrites98.5%
if 0.048000000000000001 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6484.9
Applied rewrites84.9%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in re around inf
Applied rewrites100.0%
Final simplification90.7%
(FPCore (re im)
:precision binary64
(if (<= re -400.0)
(* (* (* im im) -0.5) (exp re))
(if (<= re 0.048)
(* (fma (fma 0.5 re 1.0) re 1.0) (cos im))
(if (<= re 1.35e+154)
(* (fma (* im im) -0.5 1.0) (exp re))
(* (* (* re re) 0.5) (cos im))))))
double code(double re, double im) {
double tmp;
if (re <= -400.0) {
tmp = ((im * im) * -0.5) * exp(re);
} else if (re <= 0.048) {
tmp = fma(fma(0.5, re, 1.0), re, 1.0) * cos(im);
} else if (re <= 1.35e+154) {
tmp = fma((im * im), -0.5, 1.0) * exp(re);
} else {
tmp = ((re * re) * 0.5) * cos(im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (re <= -400.0) tmp = Float64(Float64(Float64(im * im) * -0.5) * exp(re)); elseif (re <= 0.048) tmp = Float64(fma(fma(0.5, re, 1.0), re, 1.0) * cos(im)); elseif (re <= 1.35e+154) tmp = Float64(fma(Float64(im * im), -0.5, 1.0) * exp(re)); else tmp = Float64(Float64(Float64(re * re) * 0.5) * cos(im)); end return tmp end
code[re_, im_] := If[LessEqual[re, -400.0], N[(N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.048], N[(N[(N[(0.5 * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], N[(N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -400:\\
\;\;\;\;\left(\left(im \cdot im\right) \cdot -0.5\right) \cdot e^{re}\\
\mathbf{elif}\;re \leq 0.048:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, re, 1\right), re, 1\right) \cdot \cos im\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.5, 1\right) \cdot e^{re}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot \cos im\\
\end{array}
\end{array}
if re < -400Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6473.4
Applied rewrites73.4%
Taylor expanded in im around inf
Applied rewrites73.4%
if -400 < re < 0.048000000000000001Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6498.5
Applied rewrites98.5%
if 0.048000000000000001 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6484.9
Applied rewrites84.9%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in re around inf
Applied rewrites100.0%
Final simplification90.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (fma (* im im) -0.5 1.0) (exp re))))
(if (<= re -1.4e-7)
t_0
(if (<= re 0.00135)
(* (+ 1.0 re) (cos im))
(if (<= re 1.35e+154) t_0 (* (* (* re re) 0.5) (cos im)))))))
double code(double re, double im) {
double t_0 = fma((im * im), -0.5, 1.0) * exp(re);
double tmp;
if (re <= -1.4e-7) {
tmp = t_0;
} else if (re <= 0.00135) {
tmp = (1.0 + re) * cos(im);
} else if (re <= 1.35e+154) {
tmp = t_0;
} else {
tmp = ((re * re) * 0.5) * cos(im);
}
return tmp;
}
function code(re, im) t_0 = Float64(fma(Float64(im * im), -0.5, 1.0) * exp(re)) tmp = 0.0 if (re <= -1.4e-7) tmp = t_0; elseif (re <= 0.00135) tmp = Float64(Float64(1.0 + re) * cos(im)); elseif (re <= 1.35e+154) tmp = t_0; else tmp = Float64(Float64(Float64(re * re) * 0.5) * cos(im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Exp[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -1.4e-7], t$95$0, If[LessEqual[re, 0.00135], N[(N[(1.0 + re), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], t$95$0, N[(N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(im \cdot im, -0.5, 1\right) \cdot e^{re}\\
\mathbf{if}\;re \leq -1.4 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;re \leq 0.00135:\\
\;\;\;\;\left(1 + re\right) \cdot \cos im\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot 0.5\right) \cdot \cos im\\
\end{array}
\end{array}
if re < -1.4000000000000001e-7 or 0.0013500000000000001 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.1
Applied rewrites76.1%
if -1.4000000000000001e-7 < re < 0.0013500000000000001Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6499.6
Applied rewrites99.6%
if 1.35000000000000003e154 < re Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
Taylor expanded in re around inf
Applied rewrites100.0%
Final simplification90.5%
(FPCore (re im) :precision binary64 (if (<= (exp re) 1e-23) (* (* im im) -0.5) (* (fma (fma 0.5 re 1.0) re 1.0) (fma (* im im) -0.5 1.0))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 1e-23) {
tmp = (im * im) * -0.5;
} else {
tmp = fma(fma(0.5, re, 1.0), re, 1.0) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 1e-23) tmp = Float64(Float64(im * im) * -0.5); else tmp = Float64(fma(fma(0.5, re, 1.0), re, 1.0) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 1e-23], N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(N[(0.5 * re + 1.0), $MachinePrecision] * re + 1.0), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 10^{-23}:\\
\;\;\;\;\left(im \cdot im\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.5, re, 1\right), re, 1\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 9.9999999999999996e-24Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f643.2
Applied rewrites3.2%
Taylor expanded in im around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites17.4%
if 9.9999999999999996e-24 < (exp.f64 re) Initial program 100.0%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6483.5
Applied rewrites83.5%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6445.1
Applied rewrites45.1%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.5) (* (* im im) -0.5) (* (+ 1.0 re) (fma (* im im) -0.5 1.0))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.5) {
tmp = (im * im) * -0.5;
} else {
tmp = (1.0 + re) * fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 0.5) tmp = Float64(Float64(im * im) * -0.5); else tmp = Float64(Float64(1.0 + re) * fma(Float64(im * im), -0.5, 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.5], N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(1.0 + re), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.5:\\
\;\;\;\;\left(im \cdot im\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re\right) \cdot \mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.5Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f643.4
Applied rewrites3.4%
Taylor expanded in im around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites17.2%
if 0.5 < (exp.f64 re) Initial program 100.0%
Taylor expanded in re around 0
lower-+.f6466.6
Applied rewrites66.6%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6435.8
Applied rewrites35.8%
(FPCore (re im) :precision binary64 (if (<= (exp re) 1.65e-183) (* (* im im) -0.5) (fma (* im im) -0.5 1.0)))
double code(double re, double im) {
double tmp;
if (exp(re) <= 1.65e-183) {
tmp = (im * im) * -0.5;
} else {
tmp = fma((im * im), -0.5, 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (exp(re) <= 1.65e-183) tmp = Float64(Float64(im * im) * -0.5); else tmp = fma(Float64(im * im), -0.5, 1.0); end return tmp end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 1.65e-183], N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(im * im), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1.65 \cdot 10^{-183}:\\
\;\;\;\;\left(im \cdot im\right) \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.5, 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 1.65e-183Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f643.1
Applied rewrites3.1%
Taylor expanded in im around 0
Applied rewrites2.5%
Taylor expanded in im around inf
Applied rewrites17.6%
if 1.65e-183 < (exp.f64 re) Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f6464.4
Applied rewrites64.4%
Taylor expanded in im around 0
Applied rewrites33.2%
(FPCore (re im) :precision binary64 (* (* im im) -0.5))
double code(double re, double im) {
return (im * im) * -0.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (im * im) * (-0.5d0)
end function
public static double code(double re, double im) {
return (im * im) * -0.5;
}
def code(re, im): return (im * im) * -0.5
function code(re, im) return Float64(Float64(im * im) * -0.5) end
function tmp = code(re, im) tmp = (im * im) * -0.5; end
code[re_, im_] := N[(N[(im * im), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(im \cdot im\right) \cdot -0.5
\end{array}
Initial program 100.0%
Taylor expanded in re around 0
lower-cos.f6449.1
Applied rewrites49.1%
Taylor expanded in im around 0
Applied rewrites25.5%
Taylor expanded in im around inf
Applied rewrites10.3%
herbie shell --seed 2024304
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))