?

Average Accuracy: 75.4% → 75.5%
Time: 8.1s
Precision: binary64
Cost: 13252

?

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

\mathbf{else}:\\
\;\;\;\;\sin 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) < 0.0

    1. Initial program 100.0%

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

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

    if 0.0 < (exp.f64 re)

    1. Initial program 67.5%

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

      \[\leadsto \color{blue}{\sin im + \sin im \cdot re} \]
    3. Simplified67.6%

      \[\leadsto \color{blue}{\left(re + 1\right) \cdot \sin im} \]
      Proof

      [Start]67.6

      \[ \sin im + \sin im \cdot re \]

      *-commutative [=>]67.6

      \[ \sin im + \color{blue}{re \cdot \sin im} \]

      distribute-rgt1-in [=>]67.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{re} \leq 0:\\ \;\;\;\;e^{re} \cdot im\\ \mathbf{else}:\\ \;\;\;\;\sin im \cdot \left(re + 1\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy74.7%
Cost13124
\[\begin{array}{l} \mathbf{if}\;e^{re} \leq 0.999999999997:\\ \;\;\;\;e^{re} \cdot im\\ \mathbf{else}:\\ \;\;\;\;\sin im\\ \end{array} \]
Alternative 2
Accuracy75.4%
Cost12992
\[e^{re} \cdot \sin im \]
Alternative 3
Accuracy55.6%
Cost6596
\[\begin{array}{l} \mathbf{if}\;re \leq -125000000:\\ \;\;\;\;\left(1 + \left(im + re \cdot im\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\sin im\\ \end{array} \]
Alternative 4
Accuracy32.0%
Cost708
\[\begin{array}{l} \mathbf{if}\;re \leq -125000000:\\ \;\;\;\;\left(1 + \left(im + re \cdot im\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(re + 1\right)\\ \end{array} \]
Alternative 5
Accuracy27.3%
Cost64
\[im \]

Error

Reproduce?

herbie shell --seed 2023153 
(FPCore (re im)
  :name "math.exp on complex, imaginary part"
  :precision binary64
  (* (exp re) (sin im)))