
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (log1p (expm1 (* (cos re) (- im)))))
double code(double re, double im) {
return log1p(expm1((cos(re) * -im)));
}
public static double code(double re, double im) {
return Math.log1p(Math.expm1((Math.cos(re) * -im)));
}
def code(re, im): return math.log1p(math.expm1((math.cos(re) * -im)))
function code(re, im) return log1p(expm1(Float64(cos(re) * Float64(-im)))) end
code[re_, im_] := N[Log[1 + N[(Exp[N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{log1p}\left(\mathsf{expm1}\left(\cos re \cdot \left(-im\right)\right)\right)
\end{array}
Initial program 54.6%
cos-neg54.6%
sub-neg54.6%
neg-sub054.6%
remove-double-neg54.6%
remove-double-neg54.6%
sub0-neg54.6%
distribute-neg-in54.6%
+-commutative54.6%
sub-neg54.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
Simplified54.6%
Taylor expanded in im around 0 52.1%
log1p-expm1-u99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r*99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (re im)
:precision binary64
(if (<= im 3800000.0)
(* (cos re) (- im))
(if (<= im 7e+97)
(- (* -0.041666666666666664 (* im (pow re 4.0))) im)
(* 0.5 (* (cos re) (* -0.3333333333333333 (pow im 3.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 3800000.0) {
tmp = cos(re) * -im;
} else if (im <= 7e+97) {
tmp = (-0.041666666666666664 * (im * pow(re, 4.0))) - im;
} else {
tmp = 0.5 * (cos(re) * (-0.3333333333333333 * pow(im, 3.0)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 3800000.0d0) then
tmp = cos(re) * -im
else if (im <= 7d+97) then
tmp = ((-0.041666666666666664d0) * (im * (re ** 4.0d0))) - im
else
tmp = 0.5d0 * (cos(re) * ((-0.3333333333333333d0) * (im ** 3.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3800000.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 7e+97) {
tmp = (-0.041666666666666664 * (im * Math.pow(re, 4.0))) - im;
} else {
tmp = 0.5 * (Math.cos(re) * (-0.3333333333333333 * Math.pow(im, 3.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3800000.0: tmp = math.cos(re) * -im elif im <= 7e+97: tmp = (-0.041666666666666664 * (im * math.pow(re, 4.0))) - im else: tmp = 0.5 * (math.cos(re) * (-0.3333333333333333 * math.pow(im, 3.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 3800000.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 7e+97) tmp = Float64(Float64(-0.041666666666666664 * Float64(im * (re ^ 4.0))) - im); else tmp = Float64(0.5 * Float64(cos(re) * Float64(-0.3333333333333333 * (im ^ 3.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3800000.0) tmp = cos(re) * -im; elseif (im <= 7e+97) tmp = (-0.041666666666666664 * (im * (re ^ 4.0))) - im; else tmp = 0.5 * (cos(re) * (-0.3333333333333333 * (im ^ 3.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3800000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 7e+97], N[(N[(-0.041666666666666664 * N[(im * N[Power[re, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3800000:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 7 \cdot 10^{+97}:\\
\;\;\;\;-0.041666666666666664 \cdot \left(im \cdot {re}^{4}\right) - im\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\cos re \cdot \left(-0.3333333333333333 \cdot {im}^{3}\right)\right)\\
\end{array}
\end{array}
if im < 3.8e6Initial program 38.8%
cos-neg38.8%
sub-neg38.8%
neg-sub038.8%
remove-double-neg38.8%
remove-double-neg38.8%
sub0-neg38.8%
distribute-neg-in38.8%
+-commutative38.8%
sub-neg38.8%
associate-*l*38.8%
sub-neg38.8%
+-commutative38.8%
distribute-neg-in38.8%
Simplified38.8%
Taylor expanded in im around 0 67.8%
Taylor expanded in im around 0 67.3%
associate-*r*67.3%
*-commutative67.3%
mul-1-neg67.3%
Simplified67.3%
if 3.8e6 < im < 7.0000000000000001e97Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 3.6%
Taylor expanded in re around 0 2.6%
Taylor expanded in re around inf 21.3%
if 7.0000000000000001e97 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 96.4%
Taylor expanded in im around inf 96.4%
Final simplification70.1%
(FPCore (re im) :precision binary64 (* 0.5 (* (cos re) (+ (* im -2.0) (* -0.3333333333333333 (pow im 3.0))))))
double code(double re, double im) {
return 0.5 * (cos(re) * ((im * -2.0) + (-0.3333333333333333 * pow(im, 3.0))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (cos(re) * ((im * (-2.0d0)) + ((-0.3333333333333333d0) * (im ** 3.0d0))))
end function
public static double code(double re, double im) {
return 0.5 * (Math.cos(re) * ((im * -2.0) + (-0.3333333333333333 * Math.pow(im, 3.0))));
}
def code(re, im): return 0.5 * (math.cos(re) * ((im * -2.0) + (-0.3333333333333333 * math.pow(im, 3.0))))
function code(re, im) return Float64(0.5 * Float64(cos(re) * Float64(Float64(im * -2.0) + Float64(-0.3333333333333333 * (im ^ 3.0))))) end
function tmp = code(re, im) tmp = 0.5 * (cos(re) * ((im * -2.0) + (-0.3333333333333333 * (im ^ 3.0)))); end
code[re_, im_] := N[(0.5 * N[(N[Cos[re], $MachinePrecision] * N[(N[(im * -2.0), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(\cos re \cdot \left(im \cdot -2 + -0.3333333333333333 \cdot {im}^{3}\right)\right)
\end{array}
Initial program 54.6%
cos-neg54.6%
sub-neg54.6%
neg-sub054.6%
remove-double-neg54.6%
remove-double-neg54.6%
sub0-neg54.6%
distribute-neg-in54.6%
+-commutative54.6%
sub-neg54.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
Simplified54.6%
Taylor expanded in im around 0 84.8%
Final simplification84.8%
(FPCore (re im)
:precision binary64
(if (<= im 6.5e+42)
(* (cos re) (- im))
(if (<= im 2e+105)
(log1p (expm1 im))
(* 0.5 (+ (* im -2.0) (* -0.3333333333333333 (pow im 3.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 6.5e+42) {
tmp = cos(re) * -im;
} else if (im <= 2e+105) {
tmp = log1p(expm1(im));
} else {
tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * pow(im, 3.0)));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (im <= 6.5e+42) {
tmp = Math.cos(re) * -im;
} else if (im <= 2e+105) {
tmp = Math.log1p(Math.expm1(im));
} else {
tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * Math.pow(im, 3.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 6.5e+42: tmp = math.cos(re) * -im elif im <= 2e+105: tmp = math.log1p(math.expm1(im)) else: tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * math.pow(im, 3.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 6.5e+42) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 2e+105) tmp = log1p(expm1(im)); else tmp = Float64(0.5 * Float64(Float64(im * -2.0) + Float64(-0.3333333333333333 * (im ^ 3.0)))); end return tmp end
code[re_, im_] := If[LessEqual[im, 6.5e+42], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 2e+105], N[Log[1 + N[(Exp[im] - 1), $MachinePrecision]], $MachinePrecision], N[(0.5 * N[(N[(im * -2.0), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.5 \cdot 10^{+42}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+105}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot -2 + -0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 6.50000000000000052e42Initial program 39.7%
cos-neg39.7%
sub-neg39.7%
neg-sub039.7%
remove-double-neg39.7%
remove-double-neg39.7%
sub0-neg39.7%
distribute-neg-in39.7%
+-commutative39.7%
sub-neg39.7%
associate-*l*39.7%
sub-neg39.7%
+-commutative39.7%
distribute-neg-in39.7%
Simplified39.7%
Taylor expanded in im around 0 66.8%
Taylor expanded in im around 0 66.3%
associate-*r*66.3%
*-commutative66.3%
mul-1-neg66.3%
Simplified66.3%
if 6.50000000000000052e42 < im < 1.9999999999999999e105Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 3.8%
Taylor expanded in re around 0 2.9%
add-sqr-sqrt0.0%
sqrt-unprod1.3%
associate-*r*1.3%
associate-*r*1.3%
swap-sqr1.3%
metadata-eval1.3%
metadata-eval1.3%
metadata-eval1.3%
*-un-lft-identity1.3%
sqrt-unprod1.3%
add-sqr-sqrt1.3%
log1p-expm1-u25.0%
Applied egg-rr25.0%
if 1.9999999999999999e105 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 80.9%
Final simplification66.4%
(FPCore (re im)
:precision binary64
(if (<= im 3.8e+40)
(* (cos re) (- im))
(if (<= im 2e+105)
(* im (+ -1.0 (* 0.5 (pow re 2.0))))
(* 0.5 (+ (* im -2.0) (* -0.3333333333333333 (pow im 3.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 3.8e+40) {
tmp = cos(re) * -im;
} else if (im <= 2e+105) {
tmp = im * (-1.0 + (0.5 * pow(re, 2.0)));
} else {
tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * pow(im, 3.0)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 3.8d+40) then
tmp = cos(re) * -im
else if (im <= 2d+105) then
tmp = im * ((-1.0d0) + (0.5d0 * (re ** 2.0d0)))
else
tmp = 0.5d0 * ((im * (-2.0d0)) + ((-0.3333333333333333d0) * (im ** 3.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.8e+40) {
tmp = Math.cos(re) * -im;
} else if (im <= 2e+105) {
tmp = im * (-1.0 + (0.5 * Math.pow(re, 2.0)));
} else {
tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * Math.pow(im, 3.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.8e+40: tmp = math.cos(re) * -im elif im <= 2e+105: tmp = im * (-1.0 + (0.5 * math.pow(re, 2.0))) else: tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * math.pow(im, 3.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.8e+40) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 2e+105) tmp = Float64(im * Float64(-1.0 + Float64(0.5 * (re ^ 2.0)))); else tmp = Float64(0.5 * Float64(Float64(im * -2.0) + Float64(-0.3333333333333333 * (im ^ 3.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.8e+40) tmp = cos(re) * -im; elseif (im <= 2e+105) tmp = im * (-1.0 + (0.5 * (re ^ 2.0))); else tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * (im ^ 3.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.8e+40], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 2e+105], N[(im * N[(-1.0 + N[(0.5 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(im * -2.0), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.8 \cdot 10^{+40}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+105}:\\
\;\;\;\;im \cdot \left(-1 + 0.5 \cdot {re}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot -2 + -0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 3.80000000000000004e40Initial program 39.7%
cos-neg39.7%
sub-neg39.7%
neg-sub039.7%
remove-double-neg39.7%
remove-double-neg39.7%
sub0-neg39.7%
distribute-neg-in39.7%
+-commutative39.7%
sub-neg39.7%
associate-*l*39.7%
sub-neg39.7%
+-commutative39.7%
distribute-neg-in39.7%
Simplified39.7%
Taylor expanded in im around 0 66.8%
Taylor expanded in im around 0 66.3%
associate-*r*66.3%
*-commutative66.3%
mul-1-neg66.3%
Simplified66.3%
if 3.80000000000000004e40 < im < 1.9999999999999999e105Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 3.8%
Taylor expanded in re around 0 27.1%
*-commutative27.1%
*-commutative27.1%
associate-*l*27.1%
distribute-lft-out27.1%
Simplified27.1%
if 1.9999999999999999e105 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in re around 0 80.9%
Final simplification66.6%
(FPCore (re im)
:precision binary64
(if (<= im 480000.0)
(* (cos re) (- im))
(if (<= im 8e+97)
(- (* -0.041666666666666664 (* im (pow re 4.0))) im)
(* 0.5 (+ (* im -2.0) (* -0.3333333333333333 (pow im 3.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 480000.0) {
tmp = cos(re) * -im;
} else if (im <= 8e+97) {
tmp = (-0.041666666666666664 * (im * pow(re, 4.0))) - im;
} else {
tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * pow(im, 3.0)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 480000.0d0) then
tmp = cos(re) * -im
else if (im <= 8d+97) then
tmp = ((-0.041666666666666664d0) * (im * (re ** 4.0d0))) - im
else
tmp = 0.5d0 * ((im * (-2.0d0)) + ((-0.3333333333333333d0) * (im ** 3.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 480000.0) {
tmp = Math.cos(re) * -im;
} else if (im <= 8e+97) {
tmp = (-0.041666666666666664 * (im * Math.pow(re, 4.0))) - im;
} else {
tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * Math.pow(im, 3.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 480000.0: tmp = math.cos(re) * -im elif im <= 8e+97: tmp = (-0.041666666666666664 * (im * math.pow(re, 4.0))) - im else: tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * math.pow(im, 3.0))) return tmp
function code(re, im) tmp = 0.0 if (im <= 480000.0) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 8e+97) tmp = Float64(Float64(-0.041666666666666664 * Float64(im * (re ^ 4.0))) - im); else tmp = Float64(0.5 * Float64(Float64(im * -2.0) + Float64(-0.3333333333333333 * (im ^ 3.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 480000.0) tmp = cos(re) * -im; elseif (im <= 8e+97) tmp = (-0.041666666666666664 * (im * (re ^ 4.0))) - im; else tmp = 0.5 * ((im * -2.0) + (-0.3333333333333333 * (im ^ 3.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 480000.0], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 8e+97], N[(N[(-0.041666666666666664 * N[(im * N[Power[re, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision], N[(0.5 * N[(N[(im * -2.0), $MachinePrecision] + N[(-0.3333333333333333 * N[Power[im, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 480000:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 8 \cdot 10^{+97}:\\
\;\;\;\;-0.041666666666666664 \cdot \left(im \cdot {re}^{4}\right) - im\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot -2 + -0.3333333333333333 \cdot {im}^{3}\right)\\
\end{array}
\end{array}
if im < 4.8e5Initial program 38.8%
cos-neg38.8%
sub-neg38.8%
neg-sub038.8%
remove-double-neg38.8%
remove-double-neg38.8%
sub0-neg38.8%
distribute-neg-in38.8%
+-commutative38.8%
sub-neg38.8%
associate-*l*38.8%
sub-neg38.8%
+-commutative38.8%
distribute-neg-in38.8%
Simplified38.8%
Taylor expanded in im around 0 67.8%
Taylor expanded in im around 0 67.3%
associate-*r*67.3%
*-commutative67.3%
mul-1-neg67.3%
Simplified67.3%
if 4.8e5 < im < 8.0000000000000006e97Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 3.6%
Taylor expanded in re around 0 2.6%
Taylor expanded in re around inf 21.3%
if 8.0000000000000006e97 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 96.4%
Taylor expanded in re around 0 76.4%
Final simplification66.2%
(FPCore (re im)
:precision binary64
(if (<= im 5.2e+40)
(* (cos re) (- im))
(if (<= im 2e+105)
(* im (+ -1.0 (* 0.5 (pow re 2.0))))
(* (pow im 3.0) -0.16666666666666666))))
double code(double re, double im) {
double tmp;
if (im <= 5.2e+40) {
tmp = cos(re) * -im;
} else if (im <= 2e+105) {
tmp = im * (-1.0 + (0.5 * pow(re, 2.0)));
} else {
tmp = pow(im, 3.0) * -0.16666666666666666;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 5.2d+40) then
tmp = cos(re) * -im
else if (im <= 2d+105) then
tmp = im * ((-1.0d0) + (0.5d0 * (re ** 2.0d0)))
else
tmp = (im ** 3.0d0) * (-0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.2e+40) {
tmp = Math.cos(re) * -im;
} else if (im <= 2e+105) {
tmp = im * (-1.0 + (0.5 * Math.pow(re, 2.0)));
} else {
tmp = Math.pow(im, 3.0) * -0.16666666666666666;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.2e+40: tmp = math.cos(re) * -im elif im <= 2e+105: tmp = im * (-1.0 + (0.5 * math.pow(re, 2.0))) else: tmp = math.pow(im, 3.0) * -0.16666666666666666 return tmp
function code(re, im) tmp = 0.0 if (im <= 5.2e+40) tmp = Float64(cos(re) * Float64(-im)); elseif (im <= 2e+105) tmp = Float64(im * Float64(-1.0 + Float64(0.5 * (re ^ 2.0)))); else tmp = Float64((im ^ 3.0) * -0.16666666666666666); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.2e+40) tmp = cos(re) * -im; elseif (im <= 2e+105) tmp = im * (-1.0 + (0.5 * (re ^ 2.0))); else tmp = (im ^ 3.0) * -0.16666666666666666; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.2e+40], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], If[LessEqual[im, 2e+105], N[(im * N[(-1.0 + N[(0.5 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.2 \cdot 10^{+40}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+105}:\\
\;\;\;\;im \cdot \left(-1 + 0.5 \cdot {re}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666\\
\end{array}
\end{array}
if im < 5.2000000000000001e40Initial program 39.7%
cos-neg39.7%
sub-neg39.7%
neg-sub039.7%
remove-double-neg39.7%
remove-double-neg39.7%
sub0-neg39.7%
distribute-neg-in39.7%
+-commutative39.7%
sub-neg39.7%
associate-*l*39.7%
sub-neg39.7%
+-commutative39.7%
distribute-neg-in39.7%
Simplified39.7%
Taylor expanded in im around 0 66.8%
Taylor expanded in im around 0 66.3%
associate-*r*66.3%
*-commutative66.3%
mul-1-neg66.3%
Simplified66.3%
if 5.2000000000000001e40 < im < 1.9999999999999999e105Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 3.8%
Taylor expanded in re around 0 27.1%
*-commutative27.1%
*-commutative27.1%
associate-*l*27.1%
distribute-lft-out27.1%
Simplified27.1%
if 1.9999999999999999e105 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Taylor expanded in im around inf 100.0%
Taylor expanded in re around 0 80.9%
Final simplification66.6%
(FPCore (re im) :precision binary64 (if (<= (cos re) -4e-310) im (* 0.5 (* im -2.0))))
double code(double re, double im) {
double tmp;
if (cos(re) <= -4e-310) {
tmp = im;
} else {
tmp = 0.5 * (im * -2.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (cos(re) <= (-4d-310)) then
tmp = im
else
tmp = 0.5d0 * (im * (-2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.cos(re) <= -4e-310) {
tmp = im;
} else {
tmp = 0.5 * (im * -2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if math.cos(re) <= -4e-310: tmp = im else: tmp = 0.5 * (im * -2.0) return tmp
function code(re, im) tmp = 0.0 if (cos(re) <= -4e-310) tmp = im; else tmp = Float64(0.5 * Float64(im * -2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (cos(re) <= -4e-310) tmp = im; else tmp = 0.5 * (im * -2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], -4e-310], im, N[(0.5 * N[(im * -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq -4 \cdot 10^{-310}:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(im \cdot -2\right)\\
\end{array}
\end{array}
if (cos.f64 re) < -3.999999999999988e-310Initial program 53.6%
cos-neg53.6%
sub-neg53.6%
neg-sub053.6%
remove-double-neg53.6%
remove-double-neg53.6%
sub0-neg53.6%
distribute-neg-in53.6%
+-commutative53.6%
sub-neg53.6%
associate-*l*53.6%
sub-neg53.6%
+-commutative53.6%
distribute-neg-in53.6%
Simplified53.6%
Taylor expanded in im around 0 53.8%
Taylor expanded in re around 0 1.9%
add-sqr-sqrt0.9%
sqrt-unprod15.9%
associate-*r*15.9%
associate-*r*15.9%
swap-sqr15.9%
metadata-eval15.9%
metadata-eval15.9%
metadata-eval15.9%
*-un-lft-identity15.9%
sqrt-unprod7.0%
add-sqr-sqrt13.4%
expm1-log1p-u11.7%
expm1-udef4.0%
Applied egg-rr4.0%
expm1-def11.7%
expm1-log1p13.4%
Simplified13.4%
if -3.999999999999988e-310 < (cos.f64 re) Initial program 54.9%
cos-neg54.9%
sub-neg54.9%
neg-sub054.9%
remove-double-neg54.9%
remove-double-neg54.9%
sub0-neg54.9%
distribute-neg-in54.9%
+-commutative54.9%
sub-neg54.9%
associate-*l*54.9%
sub-neg54.9%
+-commutative54.9%
distribute-neg-in54.9%
Simplified54.9%
Taylor expanded in im around 0 51.6%
Taylor expanded in re around 0 43.4%
Final simplification36.4%
(FPCore (re im) :precision binary64 (if (<= im 2.5) (- im) (* (pow im 3.0) -0.16666666666666666)))
double code(double re, double im) {
double tmp;
if (im <= 2.5) {
tmp = -im;
} else {
tmp = pow(im, 3.0) * -0.16666666666666666;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.5d0) then
tmp = -im
else
tmp = (im ** 3.0d0) * (-0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.5) {
tmp = -im;
} else {
tmp = Math.pow(im, 3.0) * -0.16666666666666666;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.5: tmp = -im else: tmp = math.pow(im, 3.0) * -0.16666666666666666 return tmp
function code(re, im) tmp = 0.0 if (im <= 2.5) tmp = Float64(-im); else tmp = Float64((im ^ 3.0) * -0.16666666666666666); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.5) tmp = -im; else tmp = (im ^ 3.0) * -0.16666666666666666; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.5], (-im), N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.5:\\
\;\;\;\;-im\\
\mathbf{else}:\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666\\
\end{array}
\end{array}
if im < 2.5Initial program 38.8%
cos-neg38.8%
sub-neg38.8%
neg-sub038.8%
remove-double-neg38.8%
remove-double-neg38.8%
sub0-neg38.8%
distribute-neg-in38.8%
+-commutative38.8%
sub-neg38.8%
associate-*l*38.8%
sub-neg38.8%
+-commutative38.8%
distribute-neg-in38.8%
Simplified38.8%
Taylor expanded in im around 0 67.8%
Taylor expanded in re around 0 43.3%
mul-1-neg43.3%
Simplified43.3%
if 2.5 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 74.4%
Taylor expanded in im around inf 74.4%
Taylor expanded in re around 0 59.0%
Final simplification47.4%
(FPCore (re im) :precision binary64 (if (<= im 8e+51) (* (cos re) (- im)) (* (pow im 3.0) -0.16666666666666666)))
double code(double re, double im) {
double tmp;
if (im <= 8e+51) {
tmp = cos(re) * -im;
} else {
tmp = pow(im, 3.0) * -0.16666666666666666;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 8d+51) then
tmp = cos(re) * -im
else
tmp = (im ** 3.0d0) * (-0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 8e+51) {
tmp = Math.cos(re) * -im;
} else {
tmp = Math.pow(im, 3.0) * -0.16666666666666666;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 8e+51: tmp = math.cos(re) * -im else: tmp = math.pow(im, 3.0) * -0.16666666666666666 return tmp
function code(re, im) tmp = 0.0 if (im <= 8e+51) tmp = Float64(cos(re) * Float64(-im)); else tmp = Float64((im ^ 3.0) * -0.16666666666666666); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 8e+51) tmp = cos(re) * -im; else tmp = (im ^ 3.0) * -0.16666666666666666; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 8e+51], N[(N[Cos[re], $MachinePrecision] * (-im)), $MachinePrecision], N[(N[Power[im, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 8 \cdot 10^{+51}:\\
\;\;\;\;\cos re \cdot \left(-im\right)\\
\mathbf{else}:\\
\;\;\;\;{im}^{3} \cdot -0.16666666666666666\\
\end{array}
\end{array}
if im < 8e51Initial program 40.7%
cos-neg40.7%
sub-neg40.7%
neg-sub040.7%
remove-double-neg40.7%
remove-double-neg40.7%
sub0-neg40.7%
distribute-neg-in40.7%
+-commutative40.7%
sub-neg40.7%
associate-*l*40.7%
sub-neg40.7%
+-commutative40.7%
distribute-neg-in40.7%
Simplified40.7%
Taylor expanded in im around 0 65.8%
Taylor expanded in im around 0 65.4%
associate-*r*65.4%
*-commutative65.4%
mul-1-neg65.4%
Simplified65.4%
if 8e51 < im Initial program 100.0%
cos-neg100.0%
sub-neg100.0%
neg-sub0100.0%
remove-double-neg100.0%
remove-double-neg100.0%
sub0-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l*100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
Simplified100.0%
Taylor expanded in im around 0 81.4%
Taylor expanded in im around inf 81.4%
Taylor expanded in re around 0 64.5%
Final simplification65.2%
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
return -im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -im
end function
public static double code(double re, double im) {
return -im;
}
def code(re, im): return -im
function code(re, im) return Float64(-im) end
function tmp = code(re, im) tmp = -im; end
code[re_, im_] := (-im)
\begin{array}{l}
\\
-im
\end{array}
Initial program 54.6%
cos-neg54.6%
sub-neg54.6%
neg-sub054.6%
remove-double-neg54.6%
remove-double-neg54.6%
sub0-neg54.6%
distribute-neg-in54.6%
+-commutative54.6%
sub-neg54.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
Simplified54.6%
Taylor expanded in im around 0 52.1%
Taylor expanded in re around 0 33.4%
mul-1-neg33.4%
Simplified33.4%
Final simplification33.4%
(FPCore (re im) :precision binary64 im)
double code(double re, double im) {
return im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im
end function
public static double code(double re, double im) {
return im;
}
def code(re, im): return im
function code(re, im) return im end
function tmp = code(re, im) tmp = im; end
code[re_, im_] := im
\begin{array}{l}
\\
im
\end{array}
Initial program 54.6%
cos-neg54.6%
sub-neg54.6%
neg-sub054.6%
remove-double-neg54.6%
remove-double-neg54.6%
sub0-neg54.6%
distribute-neg-in54.6%
+-commutative54.6%
sub-neg54.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-neg-in54.6%
Simplified54.6%
Taylor expanded in im around 0 52.1%
Taylor expanded in re around 0 33.7%
add-sqr-sqrt16.8%
sqrt-unprod22.1%
associate-*r*22.1%
associate-*r*22.1%
swap-sqr22.1%
metadata-eval22.1%
metadata-eval22.1%
metadata-eval22.1%
*-un-lft-identity22.1%
sqrt-unprod2.4%
add-sqr-sqrt4.7%
expm1-log1p-u4.2%
expm1-udef3.0%
Applied egg-rr3.0%
expm1-def4.2%
expm1-log1p4.7%
Simplified4.7%
Final simplification4.7%
(FPCore (re im)
:precision binary64
(if (< (fabs im) 1.0)
(-
(*
(cos re)
(+
(+ im (* (* (* 0.16666666666666666 im) im) im))
(* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
double code(double re, double im) {
double tmp;
if (fabs(im) < 1.0) {
tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (abs(im) < 1.0d0) then
tmp = -(cos(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
else
tmp = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.abs(im) < 1.0) {
tmp = -(Math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if math.fabs(im) < 1.0: tmp = -(math.cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))) else: tmp = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (abs(im) < 1.0) tmp = Float64(-Float64(cos(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im)))); else tmp = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (abs(im) < 1.0) tmp = -(cos(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))); else tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Cos[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
\end{array}
\end{array}
herbie shell --seed 2024027
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))