math.exp on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.8s
Alternatives: 11
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ e^{re} \cdot \cos im \end{array} \]
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
	return exp(re) * cos(im);
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
	return Math.exp(re) * Math.cos(im);
}
def code(re, im):
	return math.exp(re) * math.cos(im)
function code(re, im)
	return Float64(exp(re) * cos(im))
end
function tmp = code(re, im)
	tmp = exp(re) * cos(im);
end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e^{re} \cdot \cos im
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

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

\\
e^{re} \cdot \cos im
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

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

\\
e^{re} \cdot \cos im
\end{array}
Derivation
  1. Initial program 100.0%

    \[e^{re} \cdot \cos im \]
  2. Final simplification100.0%

    \[\leadsto e^{re} \cdot \cos im \]

Alternative 2: 70.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{re} \leq 1:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;e^{re} \leq 2:\\ \;\;\;\;\cos im\\ \mathbf{else}:\\ \;\;\;\;e^{re}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (exp re) 1.0) (exp re) (if (<= (exp re) 2.0) (cos im) (exp re))))
double code(double re, double im) {
	double tmp;
	if (exp(re) <= 1.0) {
		tmp = exp(re);
	} else if (exp(re) <= 2.0) {
		tmp = cos(im);
	} else {
		tmp = exp(re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (exp(re) <= 1.0d0) then
        tmp = exp(re)
    else if (exp(re) <= 2.0d0) then
        tmp = cos(im)
    else
        tmp = exp(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (Math.exp(re) <= 1.0) {
		tmp = Math.exp(re);
	} else if (Math.exp(re) <= 2.0) {
		tmp = Math.cos(im);
	} else {
		tmp = Math.exp(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if math.exp(re) <= 1.0:
		tmp = math.exp(re)
	elif math.exp(re) <= 2.0:
		tmp = math.cos(im)
	else:
		tmp = math.exp(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if (exp(re) <= 1.0)
		tmp = exp(re);
	elseif (exp(re) <= 2.0)
		tmp = cos(im);
	else
		tmp = exp(re);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (exp(re) <= 1.0)
		tmp = exp(re);
	elseif (exp(re) <= 2.0)
		tmp = cos(im);
	else
		tmp = exp(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1:\\
\;\;\;\;e^{re}\\

\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\cos im\\

\mathbf{else}:\\
\;\;\;\;e^{re}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (exp.f64 re) < 1 or 2 < (exp.f64 re)

    1. Initial program 100.0%

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

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

    if 1 < (exp.f64 re) < 2

    1. Initial program 98.4%

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

      \[\leadsto \color{blue}{\cos im} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{re} \leq 1:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;e^{re} \leq 2:\\ \;\;\;\;\cos im\\ \mathbf{else}:\\ \;\;\;\;e^{re}\\ \end{array} \]

Alternative 3: 91.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 5 \cdot 10^{-83}:\\
\;\;\;\;e^{re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (exp.f64 re) < 5e-83

    1. Initial program 100.0%

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

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

    if 5e-83 < (exp.f64 re)

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.16666666666666666 \cdot \left(\cos im \cdot {re}^{3}\right) + \left(0.5 \cdot \left(\cos im \cdot {re}^{2}\right) + \left(\cos im \cdot re + \cos im\right)\right)} \]
    3. Step-by-step derivation
      1. associate-+r+91.8%

        \[\leadsto \color{blue}{\left(0.16666666666666666 \cdot \left(\cos im \cdot {re}^{3}\right) + 0.5 \cdot \left(\cos im \cdot {re}^{2}\right)\right) + \left(\cos im \cdot re + \cos im\right)} \]
      2. *-commutative91.8%

        \[\leadsto \left(0.16666666666666666 \cdot \color{blue}{\left({re}^{3} \cdot \cos im\right)} + 0.5 \cdot \left(\cos im \cdot {re}^{2}\right)\right) + \left(\cos im \cdot re + \cos im\right) \]
      3. associate-*r*91.8%

        \[\leadsto \left(\color{blue}{\left(0.16666666666666666 \cdot {re}^{3}\right) \cdot \cos im} + 0.5 \cdot \left(\cos im \cdot {re}^{2}\right)\right) + \left(\cos im \cdot re + \cos im\right) \]
      4. *-commutative91.8%

        \[\leadsto \left(\left(0.16666666666666666 \cdot {re}^{3}\right) \cdot \cos im + 0.5 \cdot \color{blue}{\left({re}^{2} \cdot \cos im\right)}\right) + \left(\cos im \cdot re + \cos im\right) \]
      5. associate-*r*91.8%

        \[\leadsto \left(\left(0.16666666666666666 \cdot {re}^{3}\right) \cdot \cos im + \color{blue}{\left(0.5 \cdot {re}^{2}\right) \cdot \cos im}\right) + \left(\cos im \cdot re + \cos im\right) \]
      6. distribute-rgt-out91.8%

        \[\leadsto \color{blue}{\cos im \cdot \left(0.16666666666666666 \cdot {re}^{3} + 0.5 \cdot {re}^{2}\right)} + \left(\cos im \cdot re + \cos im\right) \]
      7. *-commutative91.8%

        \[\leadsto \color{blue}{\left(0.16666666666666666 \cdot {re}^{3} + 0.5 \cdot {re}^{2}\right) \cdot \cos im} + \left(\cos im \cdot re + \cos im\right) \]
      8. *-commutative91.8%

        \[\leadsto \left(0.16666666666666666 \cdot {re}^{3} + 0.5 \cdot {re}^{2}\right) \cdot \cos im + \left(\color{blue}{re \cdot \cos im} + \cos im\right) \]
      9. distribute-lft1-in91.8%

        \[\leadsto \left(0.16666666666666666 \cdot {re}^{3} + 0.5 \cdot {re}^{2}\right) \cdot \cos im + \color{blue}{\left(re + 1\right) \cdot \cos im} \]
      10. distribute-rgt-out91.8%

        \[\leadsto \color{blue}{\cos im \cdot \left(\left(0.16666666666666666 \cdot {re}^{3} + 0.5 \cdot {re}^{2}\right) + \left(re + 1\right)\right)} \]
      11. +-commutative91.8%

        \[\leadsto \cos im \cdot \color{blue}{\left(\left(re + 1\right) + \left(0.16666666666666666 \cdot {re}^{3} + 0.5 \cdot {re}^{2}\right)\right)} \]
      12. cube-mult91.8%

        \[\leadsto \cos im \cdot \left(\left(re + 1\right) + \left(0.16666666666666666 \cdot \color{blue}{\left(re \cdot \left(re \cdot re\right)\right)} + 0.5 \cdot {re}^{2}\right)\right) \]
      13. unpow291.8%

        \[\leadsto \cos im \cdot \left(\left(re + 1\right) + \left(0.16666666666666666 \cdot \left(re \cdot \color{blue}{{re}^{2}}\right) + 0.5 \cdot {re}^{2}\right)\right) \]
      14. associate-*r*91.8%

        \[\leadsto \cos im \cdot \left(\left(re + 1\right) + \left(\color{blue}{\left(0.16666666666666666 \cdot re\right) \cdot {re}^{2}} + 0.5 \cdot {re}^{2}\right)\right) \]
    4. Simplified91.8%

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

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

Alternative 4: 96.3% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -0.038 \lor \neg \left(re \leq 0.04\right) \land re \leq 1.9 \cdot 10^{+154}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= re -0.038) (and (not (<= re 0.04)) (<= re 1.9e+154)))
   (exp re)
   (* (cos im) (+ (+ re 1.0) (* re (* re 0.5))))))
double code(double re, double im) {
	double tmp;
	if ((re <= -0.038) || (!(re <= 0.04) && (re <= 1.9e+154))) {
		tmp = exp(re);
	} else {
		tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if ((re <= (-0.038d0)) .or. (.not. (re <= 0.04d0)) .and. (re <= 1.9d+154)) then
        tmp = exp(re)
    else
        tmp = cos(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((re <= -0.038) || (!(re <= 0.04) && (re <= 1.9e+154))) {
		tmp = Math.exp(re);
	} else {
		tmp = Math.cos(im) * ((re + 1.0) + (re * (re * 0.5)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (re <= -0.038) or (not (re <= 0.04) and (re <= 1.9e+154)):
		tmp = math.exp(re)
	else:
		tmp = math.cos(im) * ((re + 1.0) + (re * (re * 0.5)))
	return tmp
function code(re, im)
	tmp = 0.0
	if ((re <= -0.038) || (!(re <= 0.04) && (re <= 1.9e+154)))
		tmp = exp(re);
	else
		tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((re <= -0.038) || (~((re <= 0.04)) && (re <= 1.9e+154)))
		tmp = exp(re);
	else
		tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[re, -0.038], And[N[Not[LessEqual[re, 0.04]], $MachinePrecision], LessEqual[re, 1.9e+154]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.038 \lor \neg \left(re \leq 0.04\right) \land re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -0.0379999999999999991 or 0.0400000000000000008 < re < 1.8999999999999999e154

    1. Initial program 100.0%

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

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

    if -0.0379999999999999991 < re < 0.0400000000000000008 or 1.8999999999999999e154 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{0.5 \cdot \left(\cos im \cdot {re}^{2}\right) + \left(\cos im \cdot re + \cos im\right)} \]
    3. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto 0.5 \cdot \color{blue}{\left({re}^{2} \cdot \cos im\right)} + \left(\cos im \cdot re + \cos im\right) \]
      2. associate-*r*99.6%

        \[\leadsto \color{blue}{\left(0.5 \cdot {re}^{2}\right) \cdot \cos im} + \left(\cos im \cdot re + \cos im\right) \]
      3. *-commutative99.6%

        \[\leadsto \left(0.5 \cdot {re}^{2}\right) \cdot \cos im + \left(\color{blue}{re \cdot \cos im} + \cos im\right) \]
      4. distribute-lft1-in99.6%

        \[\leadsto \left(0.5 \cdot {re}^{2}\right) \cdot \cos im + \color{blue}{\left(re + 1\right) \cdot \cos im} \]
      5. distribute-rgt-out99.6%

        \[\leadsto \color{blue}{\cos im \cdot \left(0.5 \cdot {re}^{2} + \left(re + 1\right)\right)} \]
      6. +-commutative99.6%

        \[\leadsto \cos im \cdot \color{blue}{\left(\left(re + 1\right) + 0.5 \cdot {re}^{2}\right)} \]
      7. *-commutative99.6%

        \[\leadsto \cos im \cdot \left(\left(re + 1\right) + \color{blue}{{re}^{2} \cdot 0.5}\right) \]
      8. unpow299.6%

        \[\leadsto \cos im \cdot \left(\left(re + 1\right) + \color{blue}{\left(re \cdot re\right)} \cdot 0.5\right) \]
      9. associate-*l*99.6%

        \[\leadsto \cos im \cdot \left(\left(re + 1\right) + \color{blue}{re \cdot \left(re \cdot 0.5\right)}\right) \]
    4. Simplified99.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -0.038 \lor \neg \left(re \leq 0.04\right) \land re \leq 1.9 \cdot 10^{+154}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\ \end{array} \]

Alternative 5: 92.8% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -2.25 \cdot 10^{-6}:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;re \leq 0.01:\\ \;\;\;\;\cos im \cdot \left(re + 1\right)\\ \mathbf{else}:\\ \;\;\;\;e^{re}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re -2.25e-6)
   (exp re)
   (if (<= re 0.01) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
	double tmp;
	if (re <= -2.25e-6) {
		tmp = exp(re);
	} else if (re <= 0.01) {
		tmp = cos(im) * (re + 1.0);
	} else {
		tmp = exp(re);
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= (-2.25d-6)) then
        tmp = exp(re)
    else if (re <= 0.01d0) then
        tmp = cos(im) * (re + 1.0d0)
    else
        tmp = exp(re)
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= -2.25e-6) {
		tmp = Math.exp(re);
	} else if (re <= 0.01) {
		tmp = Math.cos(im) * (re + 1.0);
	} else {
		tmp = Math.exp(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= -2.25e-6:
		tmp = math.exp(re)
	elif re <= 0.01:
		tmp = math.cos(im) * (re + 1.0)
	else:
		tmp = math.exp(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= -2.25e-6)
		tmp = exp(re);
	elseif (re <= 0.01)
		tmp = Float64(cos(im) * Float64(re + 1.0));
	else
		tmp = exp(re);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= -2.25e-6)
		tmp = exp(re);
	elseif (re <= 0.01)
		tmp = cos(im) * (re + 1.0);
	else
		tmp = exp(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, -2.25e-6], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.01], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -2.25 \cdot 10^{-6}:\\
\;\;\;\;e^{re}\\

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

\mathbf{else}:\\
\;\;\;\;e^{re}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -2.25000000000000006e-6 or 0.0100000000000000002 < re

    1. Initial program 100.0%

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

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

    if -2.25000000000000006e-6 < re < 0.0100000000000000002

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity100.0%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in100.0%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified100.0%

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

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

Alternative 6: 56.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -0.5 \cdot \left(im \cdot im\right)\\ t_1 := re \cdot t_0\\ \mathbf{if}\;re \leq 5.6 \cdot 10^{+51}:\\ \;\;\;\;\cos im\\ \mathbf{elif}\;re \leq 2.3 \cdot 10^{+144}:\\ \;\;\;\;1 + re \cdot \left(1 + t_0\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{t_1 \cdot t_1 - re \cdot re}{t_1 - re}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* -0.5 (* im im))) (t_1 (* re t_0)))
   (if (<= re 5.6e+51)
     (cos im)
     (if (<= re 2.3e+144)
       (+ 1.0 (* re (+ 1.0 t_0)))
       (+ 1.0 (/ (- (* t_1 t_1) (* re re)) (- t_1 re)))))))
double code(double re, double im) {
	double t_0 = -0.5 * (im * im);
	double t_1 = re * t_0;
	double tmp;
	if (re <= 5.6e+51) {
		tmp = cos(im);
	} else if (re <= 2.3e+144) {
		tmp = 1.0 + (re * (1.0 + t_0));
	} else {
		tmp = 1.0 + (((t_1 * t_1) - (re * re)) / (t_1 - re));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (-0.5d0) * (im * im)
    t_1 = re * t_0
    if (re <= 5.6d+51) then
        tmp = cos(im)
    else if (re <= 2.3d+144) then
        tmp = 1.0d0 + (re * (1.0d0 + t_0))
    else
        tmp = 1.0d0 + (((t_1 * t_1) - (re * re)) / (t_1 - re))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = -0.5 * (im * im);
	double t_1 = re * t_0;
	double tmp;
	if (re <= 5.6e+51) {
		tmp = Math.cos(im);
	} else if (re <= 2.3e+144) {
		tmp = 1.0 + (re * (1.0 + t_0));
	} else {
		tmp = 1.0 + (((t_1 * t_1) - (re * re)) / (t_1 - re));
	}
	return tmp;
}
def code(re, im):
	t_0 = -0.5 * (im * im)
	t_1 = re * t_0
	tmp = 0
	if re <= 5.6e+51:
		tmp = math.cos(im)
	elif re <= 2.3e+144:
		tmp = 1.0 + (re * (1.0 + t_0))
	else:
		tmp = 1.0 + (((t_1 * t_1) - (re * re)) / (t_1 - re))
	return tmp
function code(re, im)
	t_0 = Float64(-0.5 * Float64(im * im))
	t_1 = Float64(re * t_0)
	tmp = 0.0
	if (re <= 5.6e+51)
		tmp = cos(im);
	elseif (re <= 2.3e+144)
		tmp = Float64(1.0 + Float64(re * Float64(1.0 + t_0)));
	else
		tmp = Float64(1.0 + Float64(Float64(Float64(t_1 * t_1) - Float64(re * re)) / Float64(t_1 - re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = -0.5 * (im * im);
	t_1 = re * t_0;
	tmp = 0.0;
	if (re <= 5.6e+51)
		tmp = cos(im);
	elseif (re <= 2.3e+144)
		tmp = 1.0 + (re * (1.0 + t_0));
	else
		tmp = 1.0 + (((t_1 * t_1) - (re * re)) / (t_1 - re));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(re * t$95$0), $MachinePrecision]}, If[LessEqual[re, 5.6e+51], N[Cos[im], $MachinePrecision], If[LessEqual[re, 2.3e+144], N[(1.0 + N[(re * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(im \cdot im\right)\\
t_1 := re \cdot t_0\\
\mathbf{if}\;re \leq 5.6 \cdot 10^{+51}:\\
\;\;\;\;\cos im\\

\mathbf{elif}\;re \leq 2.3 \cdot 10^{+144}:\\
\;\;\;\;1 + re \cdot \left(1 + t_0\right)\\

\mathbf{else}:\\
\;\;\;\;1 + \frac{t_1 \cdot t_1 - re \cdot re}{t_1 - re}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if re < 5.60000000000000009e51

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im} \]

    if 5.60000000000000009e51 < re < 2.3000000000000001e144

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity4.1%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in4.1%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified4.1%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 26.7%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(1 + re\right) \cdot {im}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutative26.7%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(re + 1\right)} \cdot {im}^{2}\right)\right) \]
      2. *-commutative26.7%

        \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{\left({im}^{2} \cdot \left(re + 1\right)\right)}\right) \]
      3. unpow226.7%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(re + 1\right)\right)\right) \]
    7. Simplified26.7%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(re + 1\right)\right)\right)} \]
    8. Taylor expanded in re around inf 26.7%

      \[\leadsto 1 + \color{blue}{\left(1 + -0.5 \cdot {im}^{2}\right) \cdot re} \]
    9. Step-by-step derivation
      1. *-commutative26.7%

        \[\leadsto 1 + \color{blue}{re \cdot \left(1 + -0.5 \cdot {im}^{2}\right)} \]
      2. +-commutative26.7%

        \[\leadsto 1 + re \cdot \color{blue}{\left(-0.5 \cdot {im}^{2} + 1\right)} \]
      3. unpow226.7%

        \[\leadsto 1 + re \cdot \left(-0.5 \cdot \color{blue}{\left(im \cdot im\right)} + 1\right) \]
    10. Simplified26.7%

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

    if 2.3000000000000001e144 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity6.4%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in6.4%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified6.4%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 21.7%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(1 + re\right) \cdot {im}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutative21.7%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(re + 1\right)} \cdot {im}^{2}\right)\right) \]
      2. *-commutative21.7%

        \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{\left({im}^{2} \cdot \left(re + 1\right)\right)}\right) \]
      3. unpow221.7%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(re + 1\right)\right)\right) \]
    7. Simplified21.7%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(re + 1\right)\right)\right)} \]
    8. Taylor expanded in re around inf 21.7%

      \[\leadsto 1 + \color{blue}{\left(1 + -0.5 \cdot {im}^{2}\right) \cdot re} \]
    9. Step-by-step derivation
      1. *-commutative21.7%

        \[\leadsto 1 + \color{blue}{re \cdot \left(1 + -0.5 \cdot {im}^{2}\right)} \]
      2. +-commutative21.7%

        \[\leadsto 1 + re \cdot \color{blue}{\left(-0.5 \cdot {im}^{2} + 1\right)} \]
      3. unpow221.7%

        \[\leadsto 1 + re \cdot \left(-0.5 \cdot \color{blue}{\left(im \cdot im\right)} + 1\right) \]
    10. Simplified21.7%

      \[\leadsto 1 + \color{blue}{re \cdot \left(-0.5 \cdot \left(im \cdot im\right) + 1\right)} \]
    11. Step-by-step derivation
      1. distribute-lft-in21.7%

        \[\leadsto 1 + \color{blue}{\left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) + re \cdot 1\right)} \]
      2. *-rgt-identity21.7%

        \[\leadsto 1 + \left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) + \color{blue}{re}\right) \]
      3. flip-+46.6%

        \[\leadsto 1 + \color{blue}{\frac{\left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) - re \cdot re}{re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) - re}} \]
    12. Applied egg-rr46.6%

      \[\leadsto 1 + \color{blue}{\frac{\left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) - re \cdot re}{re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) - re}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification57.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 5.6 \cdot 10^{+51}:\\ \;\;\;\;\cos im\\ \mathbf{elif}\;re \leq 2.3 \cdot 10^{+144}:\\ \;\;\;\;1 + re \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{\left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) - re \cdot re}{re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) - re}\\ \end{array} \]

Alternative 7: 34.4% accurate, 6.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\\ \mathbf{if}\;im \leq 3.9 \cdot 10^{+40}:\\ \;\;\;\;1 + \frac{t_0 \cdot t_0 - re \cdot re}{t_0 - re}\\ \mathbf{else}:\\ \;\;\;\;1 + -0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* re (* -0.5 (* im im)))))
   (if (<= im 3.9e+40)
     (+ 1.0 (/ (- (* t_0 t_0) (* re re)) (- t_0 re)))
     (+ 1.0 (* -0.5 (* im (* re im)))))))
double code(double re, double im) {
	double t_0 = re * (-0.5 * (im * im));
	double tmp;
	if (im <= 3.9e+40) {
		tmp = 1.0 + (((t_0 * t_0) - (re * re)) / (t_0 - re));
	} else {
		tmp = 1.0 + (-0.5 * (im * (re * im)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: tmp
    t_0 = re * ((-0.5d0) * (im * im))
    if (im <= 3.9d+40) then
        tmp = 1.0d0 + (((t_0 * t_0) - (re * re)) / (t_0 - re))
    else
        tmp = 1.0d0 + ((-0.5d0) * (im * (re * im)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = re * (-0.5 * (im * im));
	double tmp;
	if (im <= 3.9e+40) {
		tmp = 1.0 + (((t_0 * t_0) - (re * re)) / (t_0 - re));
	} else {
		tmp = 1.0 + (-0.5 * (im * (re * im)));
	}
	return tmp;
}
def code(re, im):
	t_0 = re * (-0.5 * (im * im))
	tmp = 0
	if im <= 3.9e+40:
		tmp = 1.0 + (((t_0 * t_0) - (re * re)) / (t_0 - re))
	else:
		tmp = 1.0 + (-0.5 * (im * (re * im)))
	return tmp
function code(re, im)
	t_0 = Float64(re * Float64(-0.5 * Float64(im * im)))
	tmp = 0.0
	if (im <= 3.9e+40)
		tmp = Float64(1.0 + Float64(Float64(Float64(t_0 * t_0) - Float64(re * re)) / Float64(t_0 - re)));
	else
		tmp = Float64(1.0 + Float64(-0.5 * Float64(im * Float64(re * im))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = re * (-0.5 * (im * im));
	tmp = 0.0;
	if (im <= 3.9e+40)
		tmp = 1.0 + (((t_0 * t_0) - (re * re)) / (t_0 - re));
	else
		tmp = 1.0 + (-0.5 * (im * (re * im)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 3.9e+40], N[(1.0 + N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\\
\mathbf{if}\;im \leq 3.9 \cdot 10^{+40}:\\
\;\;\;\;1 + \frac{t_0 \cdot t_0 - re \cdot re}{t_0 - re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 3.9000000000000001e40

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity53.2%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in53.1%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified53.1%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 31.8%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(1 + re\right) \cdot {im}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutative31.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(re + 1\right)} \cdot {im}^{2}\right)\right) \]
      2. *-commutative31.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{\left({im}^{2} \cdot \left(re + 1\right)\right)}\right) \]
      3. unpow231.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(re + 1\right)\right)\right) \]
    7. Simplified31.8%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(re + 1\right)\right)\right)} \]
    8. Taylor expanded in re around inf 33.2%

      \[\leadsto 1 + \color{blue}{\left(1 + -0.5 \cdot {im}^{2}\right) \cdot re} \]
    9. Step-by-step derivation
      1. *-commutative33.2%

        \[\leadsto 1 + \color{blue}{re \cdot \left(1 + -0.5 \cdot {im}^{2}\right)} \]
      2. +-commutative33.2%

        \[\leadsto 1 + re \cdot \color{blue}{\left(-0.5 \cdot {im}^{2} + 1\right)} \]
      3. unpow233.2%

        \[\leadsto 1 + re \cdot \left(-0.5 \cdot \color{blue}{\left(im \cdot im\right)} + 1\right) \]
    10. Simplified33.2%

      \[\leadsto 1 + \color{blue}{re \cdot \left(-0.5 \cdot \left(im \cdot im\right) + 1\right)} \]
    11. Step-by-step derivation
      1. distribute-lft-in33.2%

        \[\leadsto 1 + \color{blue}{\left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) + re \cdot 1\right)} \]
      2. *-rgt-identity33.2%

        \[\leadsto 1 + \left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) + \color{blue}{re}\right) \]
      3. flip-+35.9%

        \[\leadsto 1 + \color{blue}{\frac{\left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) - re \cdot re}{re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) - re}} \]
    12. Applied egg-rr35.9%

      \[\leadsto 1 + \color{blue}{\frac{\left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) - re \cdot re}{re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) - re}} \]

    if 3.9000000000000001e40 < im

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity46.9%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in46.9%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified46.9%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 7.4%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(1 + re\right) \cdot {im}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutative7.4%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(re + 1\right)} \cdot {im}^{2}\right)\right) \]
      2. *-commutative7.4%

        \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{\left({im}^{2} \cdot \left(re + 1\right)\right)}\right) \]
      3. unpow27.4%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(re + 1\right)\right)\right) \]
    7. Simplified7.4%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(re + 1\right)\right)\right)} \]
    8. Taylor expanded in im around inf 7.4%

      \[\leadsto 1 + \color{blue}{-0.5 \cdot \left(\left(1 + re\right) \cdot {im}^{2}\right)} \]
    9. Step-by-step derivation
      1. unpow27.4%

        \[\leadsto 1 + -0.5 \cdot \left(\left(1 + re\right) \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
      2. +-commutative7.4%

        \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\left(re + 1\right)} \cdot \left(im \cdot im\right)\right) \]
      3. distribute-rgt1-in6.8%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot im + re \cdot \left(im \cdot im\right)\right)} \]
      4. associate-*r*6.9%

        \[\leadsto 1 + -0.5 \cdot \left(im \cdot im + \color{blue}{\left(re \cdot im\right) \cdot im}\right) \]
      5. distribute-rgt-in7.4%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot \left(im + re \cdot im\right)\right)} \]
      6. *-commutative7.4%

        \[\leadsto 1 + -0.5 \cdot \left(im \cdot \left(im + \color{blue}{im \cdot re}\right)\right) \]
    10. Simplified7.4%

      \[\leadsto 1 + \color{blue}{-0.5 \cdot \left(im \cdot \left(im + im \cdot re\right)\right)} \]
    11. Taylor expanded in re around inf 7.7%

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(re \cdot {im}^{2}\right)} \]
    12. Step-by-step derivation
      1. unpow27.7%

        \[\leadsto 1 + -0.5 \cdot \left(re \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
      2. associate-*r*7.8%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot im\right)} \]
      3. *-commutative7.8%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot \left(re \cdot im\right)\right)} \]
    13. Simplified7.8%

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot \left(re \cdot im\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification28.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.9 \cdot 10^{+40}:\\ \;\;\;\;1 + \frac{\left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\right) - re \cdot re}{re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right) - re}\\ \mathbf{else}:\\ \;\;\;\;1 + -0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\ \end{array} \]

Alternative 8: 33.5% accurate, 15.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 480:\\ \;\;\;\;re + 1\\ \mathbf{else}:\\ \;\;\;\;1 + re \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 480.0) (+ re 1.0) (+ 1.0 (* re (+ 1.0 (* -0.5 (* im im)))))))
double code(double re, double im) {
	double tmp;
	if (re <= 480.0) {
		tmp = re + 1.0;
	} else {
		tmp = 1.0 + (re * (1.0 + (-0.5 * (im * im))));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 480.0d0) then
        tmp = re + 1.0d0
    else
        tmp = 1.0d0 + (re * (1.0d0 + ((-0.5d0) * (im * im))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 480.0) {
		tmp = re + 1.0;
	} else {
		tmp = 1.0 + (re * (1.0 + (-0.5 * (im * im))));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 480.0:
		tmp = re + 1.0
	else:
		tmp = 1.0 + (re * (1.0 + (-0.5 * (im * im))))
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 480.0)
		tmp = Float64(re + 1.0);
	else
		tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(-0.5 * Float64(im * im)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 480.0)
		tmp = re + 1.0;
	else
		tmp = 1.0 + (re * (1.0 + (-0.5 * (im * im))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 480.0], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 480:\\
\;\;\;\;re + 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 480

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity65.0%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in65.0%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified65.0%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 30.7%

      \[\leadsto \color{blue}{1 + re} \]
    6. Step-by-step derivation
      1. +-commutative30.7%

        \[\leadsto \color{blue}{re + 1} \]
    7. Simplified30.7%

      \[\leadsto \color{blue}{re + 1} \]

    if 480 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity5.1%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in5.1%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified5.1%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 21.8%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(1 + re\right) \cdot {im}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutative21.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(re + 1\right)} \cdot {im}^{2}\right)\right) \]
      2. *-commutative21.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{\left({im}^{2} \cdot \left(re + 1\right)\right)}\right) \]
      3. unpow221.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(re + 1\right)\right)\right) \]
    7. Simplified21.8%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(re + 1\right)\right)\right)} \]
    8. Taylor expanded in re around inf 21.8%

      \[\leadsto 1 + \color{blue}{\left(1 + -0.5 \cdot {im}^{2}\right) \cdot re} \]
    9. Step-by-step derivation
      1. *-commutative21.8%

        \[\leadsto 1 + \color{blue}{re \cdot \left(1 + -0.5 \cdot {im}^{2}\right)} \]
      2. +-commutative21.8%

        \[\leadsto 1 + re \cdot \color{blue}{\left(-0.5 \cdot {im}^{2} + 1\right)} \]
      3. unpow221.8%

        \[\leadsto 1 + re \cdot \left(-0.5 \cdot \color{blue}{\left(im \cdot im\right)} + 1\right) \]
    10. Simplified21.8%

      \[\leadsto 1 + \color{blue}{re \cdot \left(-0.5 \cdot \left(im \cdot im\right) + 1\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification28.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 480:\\ \;\;\;\;re + 1\\ \mathbf{else}:\\ \;\;\;\;1 + re \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 9: 33.1% accurate, 18.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 650:\\ \;\;\;\;re + 1\\ \mathbf{else}:\\ \;\;\;\;1 + -0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 650.0) (+ re 1.0) (+ 1.0 (* -0.5 (* im (* re im))))))
double code(double re, double im) {
	double tmp;
	if (re <= 650.0) {
		tmp = re + 1.0;
	} else {
		tmp = 1.0 + (-0.5 * (im * (re * im)));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 650.0d0) then
        tmp = re + 1.0d0
    else
        tmp = 1.0d0 + ((-0.5d0) * (im * (re * im)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 650.0) {
		tmp = re + 1.0;
	} else {
		tmp = 1.0 + (-0.5 * (im * (re * im)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 650.0:
		tmp = re + 1.0
	else:
		tmp = 1.0 + (-0.5 * (im * (re * im)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 650.0)
		tmp = Float64(re + 1.0);
	else
		tmp = Float64(1.0 + Float64(-0.5 * Float64(im * Float64(re * im))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 650.0)
		tmp = re + 1.0;
	else
		tmp = 1.0 + (-0.5 * (im * (re * im)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 650.0], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 650:\\
\;\;\;\;re + 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 650

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity65.0%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in65.0%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified65.0%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 30.7%

      \[\leadsto \color{blue}{1 + re} \]
    6. Step-by-step derivation
      1. +-commutative30.7%

        \[\leadsto \color{blue}{re + 1} \]
    7. Simplified30.7%

      \[\leadsto \color{blue}{re + 1} \]

    if 650 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity5.1%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in5.1%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified5.1%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 21.8%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(1 + re\right) \cdot {im}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutative21.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(re + 1\right)} \cdot {im}^{2}\right)\right) \]
      2. *-commutative21.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{\left({im}^{2} \cdot \left(re + 1\right)\right)}\right) \]
      3. unpow221.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(re + 1\right)\right)\right) \]
    7. Simplified21.8%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(re + 1\right)\right)\right)} \]
    8. Taylor expanded in im around inf 20.2%

      \[\leadsto 1 + \color{blue}{-0.5 \cdot \left(\left(1 + re\right) \cdot {im}^{2}\right)} \]
    9. Step-by-step derivation
      1. unpow220.2%

        \[\leadsto 1 + -0.5 \cdot \left(\left(1 + re\right) \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
      2. +-commutative20.2%

        \[\leadsto 1 + -0.5 \cdot \left(\color{blue}{\left(re + 1\right)} \cdot \left(im \cdot im\right)\right) \]
      3. distribute-rgt1-in20.2%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot im + re \cdot \left(im \cdot im\right)\right)} \]
      4. associate-*r*20.2%

        \[\leadsto 1 + -0.5 \cdot \left(im \cdot im + \color{blue}{\left(re \cdot im\right) \cdot im}\right) \]
      5. distribute-rgt-in20.2%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot \left(im + re \cdot im\right)\right)} \]
      6. *-commutative20.2%

        \[\leadsto 1 + -0.5 \cdot \left(im \cdot \left(im + \color{blue}{im \cdot re}\right)\right) \]
    10. Simplified20.2%

      \[\leadsto 1 + \color{blue}{-0.5 \cdot \left(im \cdot \left(im + im \cdot re\right)\right)} \]
    11. Taylor expanded in re around inf 20.2%

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(re \cdot {im}^{2}\right)} \]
    12. Step-by-step derivation
      1. unpow220.2%

        \[\leadsto 1 + -0.5 \cdot \left(re \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
      2. associate-*r*20.2%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(\left(re \cdot im\right) \cdot im\right)} \]
      3. *-commutative20.2%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot \left(re \cdot im\right)\right)} \]
    13. Simplified20.2%

      \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot \left(re \cdot im\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification28.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 650:\\ \;\;\;\;re + 1\\ \mathbf{else}:\\ \;\;\;\;1 + -0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\ \end{array} \]

Alternative 10: 31.6% accurate, 22.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 140:\\ \;\;\;\;re + 1\\ \mathbf{else}:\\ \;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 140.0) (+ re 1.0) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
	double tmp;
	if (re <= 140.0) {
		tmp = re + 1.0;
	} else {
		tmp = 1.0 + (-0.5 * (im * im));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= 140.0d0) then
        tmp = re + 1.0d0
    else
        tmp = 1.0d0 + ((-0.5d0) * (im * im))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= 140.0) {
		tmp = re + 1.0;
	} else {
		tmp = 1.0 + (-0.5 * (im * im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 140.0:
		tmp = re + 1.0
	else:
		tmp = 1.0 + (-0.5 * (im * im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 140.0)
		tmp = Float64(re + 1.0);
	else
		tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 140.0)
		tmp = re + 1.0;
	else
		tmp = 1.0 + (-0.5 * (im * im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 140.0], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 140:\\
\;\;\;\;re + 1\\

\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 140

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity65.0%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in65.0%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified65.0%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 30.7%

      \[\leadsto \color{blue}{1 + re} \]
    6. Step-by-step derivation
      1. +-commutative30.7%

        \[\leadsto \color{blue}{re + 1} \]
    7. Simplified30.7%

      \[\leadsto \color{blue}{re + 1} \]

    if 140 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
    3. Step-by-step derivation
      1. *-rgt-identity5.1%

        \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
      2. distribute-lft-in5.1%

        \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    4. Simplified5.1%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
    5. Taylor expanded in im around 0 21.8%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(1 + re\right) \cdot {im}^{2}\right)\right)} \]
    6. Step-by-step derivation
      1. +-commutative21.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(re + 1\right)} \cdot {im}^{2}\right)\right) \]
      2. *-commutative21.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{\left({im}^{2} \cdot \left(re + 1\right)\right)}\right) \]
      3. unpow221.8%

        \[\leadsto 1 + \left(re + -0.5 \cdot \left(\color{blue}{\left(im \cdot im\right)} \cdot \left(re + 1\right)\right)\right) \]
    7. Simplified21.8%

      \[\leadsto \color{blue}{1 + \left(re + -0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(re + 1\right)\right)\right)} \]
    8. Taylor expanded in re around 0 13.9%

      \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{{im}^{2}}\right) \]
    9. Step-by-step derivation
      1. unpow213.9%

        \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    10. Simplified13.9%

      \[\leadsto 1 + \left(re + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    11. Taylor expanded in re around 0 12.6%

      \[\leadsto 1 + \color{blue}{-0.5 \cdot {im}^{2}} \]
    12. Step-by-step derivation
      1. unpow212.6%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
    13. Simplified12.6%

      \[\leadsto 1 + \color{blue}{-0.5 \cdot \left(im \cdot im\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification26.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 140:\\ \;\;\;\;re + 1\\ \mathbf{else}:\\ \;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\ \end{array} \]

Alternative 11: 28.8% accurate, 67.7× speedup?

\[\begin{array}{l} \\ re + 1 \end{array} \]
(FPCore (re im) :precision binary64 (+ re 1.0))
double code(double re, double im) {
	return re + 1.0;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = re + 1.0d0
end function
public static double code(double re, double im) {
	return re + 1.0;
}
def code(re, im):
	return re + 1.0
function code(re, im)
	return Float64(re + 1.0)
end
function tmp = code(re, im)
	tmp = re + 1.0;
end
code[re_, im_] := N[(re + 1.0), $MachinePrecision]
\begin{array}{l}

\\
re + 1
\end{array}
Derivation
  1. Initial program 100.0%

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

    \[\leadsto \color{blue}{\cos im \cdot re + \cos im} \]
  3. Step-by-step derivation
    1. *-rgt-identity51.5%

      \[\leadsto \cos im \cdot re + \color{blue}{\cos im \cdot 1} \]
    2. distribute-lft-in51.5%

      \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
  4. Simplified51.5%

    \[\leadsto \color{blue}{\cos im \cdot \left(re + 1\right)} \]
  5. Taylor expanded in im around 0 24.7%

    \[\leadsto \color{blue}{1 + re} \]
  6. Step-by-step derivation
    1. +-commutative24.7%

      \[\leadsto \color{blue}{re + 1} \]
  7. Simplified24.7%

    \[\leadsto \color{blue}{re + 1} \]
  8. Final simplification24.7%

    \[\leadsto re + 1 \]

Reproduce

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