?

Average Error: 0.0 → 0.1
Time: 12.3s
Precision: binary64
Cost: 39424

?

\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
\[\begin{array}{l} t_0 := e^{-im}\\ \left(0.5 \cdot \cos re\right) \cdot \left(\frac{1}{t_0 + e^{im}} \cdot {\left(e^{im} + t_0\right)}^{2}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (exp (- im))))
   (*
    (* 0.5 (cos re))
    (* (/ 1.0 (+ t_0 (exp im))) (pow (+ (exp im) t_0) 2.0)))))
double code(double re, double im) {
	return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
double code(double re, double im) {
	double t_0 = exp(-im);
	return (0.5 * cos(re)) * ((1.0 / (t_0 + exp(im))) * pow((exp(im) + t_0), 2.0));
}
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 = exp(-im)
    code = (0.5d0 * cos(re)) * ((1.0d0 / (t_0 + exp(im))) * ((exp(im) + t_0) ** 2.0d0))
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 = Math.exp(-im);
	return (0.5 * Math.cos(re)) * ((1.0 / (t_0 + Math.exp(im))) * Math.pow((Math.exp(im) + t_0), 2.0));
}
def code(re, im):
	return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
def code(re, im):
	t_0 = math.exp(-im)
	return (0.5 * math.cos(re)) * ((1.0 / (t_0 + math.exp(im))) * math.pow((math.exp(im) + t_0), 2.0))
function code(re, im)
	return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im)))
end
function code(re, im)
	t_0 = exp(Float64(-im))
	return Float64(Float64(0.5 * cos(re)) * Float64(Float64(1.0 / Float64(t_0 + exp(im))) * (Float64(exp(im) + t_0) ^ 2.0)))
end
function tmp = code(re, im)
	tmp = (0.5 * cos(re)) * (exp(-im) + exp(im));
end
function tmp = code(re, im)
	t_0 = exp(-im);
	tmp = (0.5 * cos(re)) * ((1.0 / (t_0 + exp(im))) * ((exp(im) + t_0) ^ 2.0));
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[Exp[(-im)], $MachinePrecision]}, N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[(t$95$0 + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[Exp[im], $MachinePrecision] + t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\begin{array}{l}
t_0 := e^{-im}\\
\left(0.5 \cdot \cos re\right) \cdot \left(\frac{1}{t_0 + e^{im}} \cdot {\left(e^{im} + t_0\right)}^{2}\right)
\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.0

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
  2. Applied egg-rr0.1

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(\frac{1}{e^{-im} + e^{im}} \cdot \left(\left(e^{-im} + e^{im}\right) \cdot \left(e^{-im} + e^{im}\right)\right)\right)} \]
  3. Taylor expanded in im around inf 0.1

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(\frac{1}{e^{-im} + e^{im}} \cdot \color{blue}{{\left(e^{im} + e^{-im}\right)}^{2}}\right) \]
  4. Final simplification0.1

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(\frac{1}{e^{-im} + e^{im}} \cdot {\left(e^{im} + e^{-im}\right)}^{2}\right) \]

Alternatives

Alternative 1
Error0.0
Cost19712
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
Alternative 2
Error0.8
Cost13312
\[\left(0.5 \cdot \cos re\right) \cdot \left(2 + {im}^{2}\right) \]
Alternative 3
Error1.0
Cost13184
\[{im}^{2} \cdot 0.5 + \cos re \]
Alternative 4
Error1.2
Cost6464
\[\cos re \]
Alternative 5
Error30.1
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (re im)
  :name "math.cos on complex, real part"
  :precision binary64
  (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))