?

Average Error: 0.01% → 0.02%
Time: 8.4s
Precision: binary64
Cost: 13056

?

\[e^{re} \cdot \cos im \]
\[\frac{\cos im}{e^{-re}} \]
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
(FPCore (re im) :precision binary64 (/ (cos im) (exp (- re))))
double code(double re, double im) {
	return exp(re) * cos(im);
}
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 = exp(re) * cos(im)
end function
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.exp(re) * Math.cos(im);
}
public static double code(double re, double im) {
	return Math.cos(im) / Math.exp(-re);
}
def code(re, im):
	return math.exp(re) * math.cos(im)
def code(re, im):
	return math.cos(im) / math.exp(-re)
function code(re, im)
	return Float64(exp(re) * cos(im))
end
function code(re, im)
	return Float64(cos(im) / exp(Float64(-re)))
end
function tmp = code(re, im)
	tmp = exp(re) * cos(im);
end
function tmp = code(re, im)
	tmp = cos(im) / exp(-re);
end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
code[re_, im_] := N[(N[Cos[im], $MachinePrecision] / N[Exp[(-re)], $MachinePrecision]), $MachinePrecision]
e^{re} \cdot \cos im
\frac{\cos im}{e^{-re}}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 0.01

    \[e^{re} \cdot \cos im \]
  2. Applied egg-rr0.53

    \[\leadsto \color{blue}{\left(1 + e^{re} \cdot \cos im\right) - 1} \]
  3. Applied egg-rr0.15

    \[\leadsto \color{blue}{\frac{1}{\frac{1}{e^{re} \cdot \cos im}}} \]
  4. Applied egg-rr25.36

    \[\leadsto \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\frac{e^{-re}}{\cos im}\right)} - 1}} \]
  5. Simplified0.15

    \[\leadsto \frac{1}{\color{blue}{\frac{e^{-re}}{\cos im}}} \]
    Proof

    [Start]25.36

    \[ \frac{1}{e^{\mathsf{log1p}\left(\frac{e^{-re}}{\cos im}\right)} - 1} \]

    expm1-def [=>]25.16

    \[ \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{e^{-re}}{\cos im}\right)\right)}} \]

    expm1-log1p [=>]0.15

    \[ \frac{1}{\color{blue}{\frac{e^{-re}}{\cos im}}} \]
  6. Taylor expanded in re around inf 0.02

    \[\leadsto \color{blue}{\frac{\cos im}{e^{-re}}} \]
  7. Final simplification0.02

    \[\leadsto \frac{\cos im}{e^{-re}} \]

Alternatives

Alternative 1
Error0.64%
Cost13892
\[\begin{array}{l} \mathbf{if}\;e^{re} \leq 0.99:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right)\right)\\ \end{array} \]
Alternative 2
Error0.75%
Cost13636
\[\begin{array}{l} \mathbf{if}\;e^{re} \leq 0.99:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\ \end{array} \]
Alternative 3
Error0.98%
Cost13252
\[\begin{array}{l} \mathbf{if}\;e^{re} \leq 0.99:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(re + 1\right)\\ \end{array} \]
Alternative 4
Error1.39%
Cost13124
\[\begin{array}{l} \mathbf{if}\;e^{re} \leq 0.99:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im + re\\ \end{array} \]
Alternative 5
Error1.76%
Cost12996
\[\begin{array}{l} \mathbf{if}\;e^{re} \leq 0.99:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im\\ \end{array} \]
Alternative 6
Error0.01%
Cost12992
\[\cos im \cdot e^{re} \]
Alternative 7
Error33.36%
Cost6464
\[\cos im \]
Alternative 8
Error62.64%
Cost320
\[\left(re + 2\right) + -1 \]
Alternative 9
Error62.63%
Cost192
\[re + 1 \]

Error

Reproduce?

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