(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
(FPCore (re im) :precision binary64 (let* ((t_0 (* 0.5 (cos re)))) (+ (* t_0 (exp (- im))) (* t_0 (exp im)))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
return (t_0 * exp(-im)) + (t_0 * exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
t_0 = 0.5d0 * cos(re)
code = (t_0 * exp(-im)) + (t_0 * exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
return (t_0 * Math.exp(-im)) + (t_0 * Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
def code(re, im): t_0 = 0.5 * math.cos(re) return (t_0 * math.exp(-im)) + (t_0 * math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function code(re, im) t_0 = Float64(0.5 * cos(re)) return Float64(Float64(t_0 * exp(Float64(-im))) + Float64(t_0 * exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
function tmp = code(re, im) t_0 = 0.5 * cos(re); tmp = (t_0 * exp(-im)) + (t_0 * exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 * N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
t_0 \cdot e^{-im} + t_0 \cdot e^{im}
\end{array}



Bits error versus re



Bits error versus im
Results
Initial program 0.0
Applied egg-rr0.0
Final simplification0.0
herbie shell --seed 2022153
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))