?

Average Accuracy: 75.1% → 75.4%
Time: 10.5s
Precision: binary64
Cost: 13252

?

\[e^{re} \cdot \cos im \]
\[\begin{array}{l} \mathbf{if}\;e^{re} \leq 5 \cdot 10^{-25}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(re + 1\right)\\ \end{array} \]
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
(FPCore (re im)
 :precision binary64
 (if (<= (exp re) 5e-25) (exp re) (* (cos im) (+ re 1.0))))
double code(double re, double im) {
	return exp(re) * cos(im);
}
double code(double re, double im) {
	double tmp;
	if (exp(re) <= 5e-25) {
		tmp = exp(re);
	} else {
		tmp = cos(im) * (re + 1.0);
	}
	return tmp;
}
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
    real(8) :: tmp
    if (exp(re) <= 5d-25) then
        tmp = exp(re)
    else
        tmp = cos(im) * (re + 1.0d0)
    end if
    code = tmp
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) {
	double tmp;
	if (Math.exp(re) <= 5e-25) {
		tmp = Math.exp(re);
	} else {
		tmp = Math.cos(im) * (re + 1.0);
	}
	return tmp;
}
def code(re, im):
	return math.exp(re) * math.cos(im)
def code(re, im):
	tmp = 0
	if math.exp(re) <= 5e-25:
		tmp = math.exp(re)
	else:
		tmp = math.cos(im) * (re + 1.0)
	return tmp
function code(re, im)
	return Float64(exp(re) * cos(im))
end
function code(re, im)
	tmp = 0.0
	if (exp(re) <= 5e-25)
		tmp = exp(re);
	else
		tmp = Float64(cos(im) * Float64(re + 1.0));
	end
	return tmp
end
function tmp = code(re, im)
	tmp = exp(re) * cos(im);
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (exp(re) <= 5e-25)
		tmp = exp(re);
	else
		tmp = cos(im) * (re + 1.0);
	end
	tmp_2 = tmp;
end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 5e-25], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
e^{re} \cdot \cos im
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;e^{re}\\

\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if (exp.f64 re) < 4.99999999999999962e-25

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Taylor expanded in im around 0 100.0%

      \[\leadsto \color{blue}{e^{re}} \]

    if 4.99999999999999962e-25 < (exp.f64 re)

    1. Initial program 67.9%

      \[e^{re} \cdot \cos im \]
    2. Taylor expanded in re around 0 68.0%

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Simplified68.0%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
      Step-by-step derivation

      [Start]68.0

      \[ \cos im \cdot re + \cos im \]

      *-rgt-identity [<=]68.0

      \[ \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]

      distribute-lft-in [<=]68.0

      \[ \color{blue}{\cos im \cdot \left(re + 1\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{re} \leq 5 \cdot 10^{-25}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(re + 1\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy74.8%
Cost13124
\[\begin{array}{l} \mathbf{if}\;e^{re} \leq 5 \cdot 10^{-25}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;re + \cos im\\ \end{array} \]
Alternative 2
Accuracy75.1%
Cost12992
\[e^{re} \cdot \cos im \]
Alternative 3
Accuracy74.5%
Cost6596
\[\begin{array}{l} \mathbf{if}\;re \leq -0.00092:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im\\ \end{array} \]
Alternative 4
Accuracy50.3%
Cost6464
\[\cos im \]
Alternative 5
Accuracy28.4%
Cost192
\[re + 1 \]

Error

Reproduce?

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