math.exp on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 7.3s
Alternatives: 13
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 13 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. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 92.9% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.99999995 \lor \neg \left(e^{re} \leq 1\right):\\
\;\;\;\;e^{re}\\

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


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

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 88.0%

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

    if 0.999999949999999971 < (exp.f64 re) < 1

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im + re \cdot \cos im} \]
    4. Step-by-step derivation
      1. distribute-rgt1-in100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{re} \leq 0.99999995 \lor \neg \left(e^{re} \leq 1\right):\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(re + 1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 92.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.99999995 \lor \neg \left(e^{re} \leq 1\right):\\
\;\;\;\;e^{re}\\

\mathbf{else}:\\
\;\;\;\;\cos im\\


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

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 88.0%

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

    if 0.999999949999999971 < (exp.f64 re) < 1

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 99.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{re} \leq 0.99999995 \lor \neg \left(e^{re} \leq 1\right):\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 97.1% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.012 \lor \neg \left(re \leq 1.2 \cdot 10^{-20}\right) \land re \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;e^{re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -0.012 or 1.19999999999999996e-20 < re < 1.01999999999999991e103

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 97.5%

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

    if -0.012 < re < 1.19999999999999996e-20 or 1.01999999999999991e103 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + 0.16666666666666666 \cdot re\right)\right)\right)} \cdot \cos im \]
    4. Step-by-step derivation
      1. *-commutative100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -0.012 \lor \neg \left(re \leq 1.2 \cdot 10^{-20}\right) \land re \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 95.6% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0082 \lor \neg \left(re \leq 1.2 \cdot 10^{-20}\right) \land re \leq 9.2 \cdot 10^{+149}:\\
\;\;\;\;e^{re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -0.00820000000000000069 or 1.19999999999999996e-20 < re < 9.1999999999999993e149

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 95.2%

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

    if -0.00820000000000000069 < re < 1.19999999999999996e-20 or 9.1999999999999993e149 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 99.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -0.0082 \lor \neg \left(re \leq 1.2 \cdot 10^{-20}\right) \land re \leq 9.2 \cdot 10^{+149}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 92.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -8.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{e^{re + 1}}{e}\\ \mathbf{elif}\;re \leq 1.2 \cdot 10^{-20}:\\ \;\;\;\;\cos im \cdot \left(re + 1\right)\\ \mathbf{else}:\\ \;\;\;\;e^{re}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re -8.5e-8)
   (/ (exp (+ re 1.0)) E)
   (if (<= re 1.2e-20) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
	double tmp;
	if (re <= -8.5e-8) {
		tmp = exp((re + 1.0)) / ((double) M_E);
	} else if (re <= 1.2e-20) {
		tmp = cos(im) * (re + 1.0);
	} else {
		tmp = exp(re);
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (re <= -8.5e-8) {
		tmp = Math.exp((re + 1.0)) / Math.E;
	} else if (re <= 1.2e-20) {
		tmp = Math.cos(im) * (re + 1.0);
	} else {
		tmp = Math.exp(re);
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= -8.5e-8:
		tmp = math.exp((re + 1.0)) / math.e
	elif re <= 1.2e-20:
		tmp = math.cos(im) * (re + 1.0)
	else:
		tmp = math.exp(re)
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= -8.5e-8)
		tmp = Float64(exp(Float64(re + 1.0)) / exp(1));
	elseif (re <= 1.2e-20)
		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 <= -8.5e-8)
		tmp = exp((re + 1.0)) / 2.71828182845904523536;
	elseif (re <= 1.2e-20)
		tmp = cos(im) * (re + 1.0);
	else
		tmp = exp(re);
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, -8.5e-8], N[(N[Exp[N[(re + 1.0), $MachinePrecision]], $MachinePrecision] / E), $MachinePrecision], If[LessEqual[re, 1.2e-20], 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 -8.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{e^{re + 1}}{e}\\

\mathbf{elif}\;re \leq 1.2 \cdot 10^{-20}:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if re < -8.49999999999999935e-8

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. expm1-log1p-u5.0%

        \[\leadsto e^{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re\right)\right)}} \cdot \cos im \]
      2. expm1-undefine5.0%

        \[\leadsto e^{\color{blue}{e^{\mathsf{log1p}\left(re\right)} - 1}} \cdot \cos im \]
      3. exp-diff5.0%

        \[\leadsto \color{blue}{\frac{e^{e^{\mathsf{log1p}\left(re\right)}}}{e^{1}}} \cdot \cos im \]
      4. log1p-undefine5.0%

        \[\leadsto \frac{e^{e^{\color{blue}{\log \left(1 + re\right)}}}}{e^{1}} \cdot \cos im \]
      5. rem-exp-log100.0%

        \[\leadsto \frac{e^{\color{blue}{1 + re}}}{e^{1}} \cdot \cos im \]
      6. exp-1-e100.0%

        \[\leadsto \frac{e^{1 + re}}{\color{blue}{e}} \cdot \cos im \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{e^{1 + re}}{e}} \cdot \cos im \]
    5. Taylor expanded in im around 0 99.8%

      \[\leadsto \color{blue}{\frac{e^{1 + re}}{e}} \]

    if -8.49999999999999935e-8 < re < 1.19999999999999996e-20

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im + re \cdot \cos im} \]
    4. Step-by-step derivation
      1. distribute-rgt1-in100.0%

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

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

    if 1.19999999999999996e-20 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 77.6%

      \[\leadsto \color{blue}{e^{re}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -8.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{e^{re + 1}}{e}\\ \mathbf{elif}\;re \leq 1.2 \cdot 10^{-20}:\\ \;\;\;\;\cos im \cdot \left(re + 1\right)\\ \mathbf{else}:\\ \;\;\;\;e^{re}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 62.6% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.2 \cdot 10^{-20}:\\
\;\;\;\;\cos im\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 1.19999999999999996e-20

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 69.6%

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

    if 1.19999999999999996e-20 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 77.6%

      \[\leadsto \color{blue}{e^{re}} \]
    4. Taylor expanded in re around 0 54.0%

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(0.5 + 0.16666666666666666 \cdot re\right)\right)} \]
    5. Step-by-step derivation
      1. *-commutative73.5%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 41.3% accurate, 15.6× speedup?

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

\\
1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[e^{re} \cdot \cos im \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 68.4%

    \[\leadsto \color{blue}{e^{re}} \]
  4. Taylor expanded in re around 0 40.2%

    \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(0.5 + 0.16666666666666666 \cdot re\right)\right)} \]
  5. Step-by-step derivation
    1. *-commutative71.1%

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

    \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)} \]
  7. Add Preprocessing

Alternative 9: 30.8% accurate, 16.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.15 \cdot 10^{+105}:\\
\;\;\;\;\frac{e \cdot \left(re + 1\right)}{e}\\

\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 < 2.1500000000000001e105

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. expm1-log1p-u73.0%

        \[\leadsto e^{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(re\right)\right)}} \cdot \cos im \]
      2. expm1-undefine73.0%

        \[\leadsto e^{\color{blue}{e^{\mathsf{log1p}\left(re\right)} - 1}} \cdot \cos im \]
      3. exp-diff73.0%

        \[\leadsto \color{blue}{\frac{e^{e^{\mathsf{log1p}\left(re\right)}}}{e^{1}}} \cdot \cos im \]
      4. log1p-undefine73.0%

        \[\leadsto \frac{e^{e^{\color{blue}{\log \left(1 + re\right)}}}}{e^{1}} \cdot \cos im \]
      5. rem-exp-log100.0%

        \[\leadsto \frac{e^{\color{blue}{1 + re}}}{e^{1}} \cdot \cos im \]
      6. exp-1-e100.0%

        \[\leadsto \frac{e^{1 + re}}{\color{blue}{e}} \cdot \cos im \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{e^{1 + re}}{e}} \cdot \cos im \]
    5. Taylor expanded in im around 0 67.8%

      \[\leadsto \color{blue}{\frac{e^{1 + re}}{e}} \]
    6. Taylor expanded in re around 0 32.9%

      \[\leadsto \frac{\color{blue}{e^{1} + re \cdot e^{1}}}{e} \]
    7. Step-by-step derivation
      1. exp-1-e32.9%

        \[\leadsto \frac{\color{blue}{e} + re \cdot e^{1}}{e} \]
      2. exp-1-e32.9%

        \[\leadsto \frac{e + re \cdot \color{blue}{e}}{e} \]
      3. distribute-rgt1-in32.9%

        \[\leadsto \frac{\color{blue}{\left(re + 1\right) \cdot e}}{e} \]
      4. +-commutative32.9%

        \[\leadsto \frac{\color{blue}{\left(1 + re\right)} \cdot e}{e} \]
    8. Simplified32.9%

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

    if 2.1500000000000001e105 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 3.1%

      \[\leadsto \color{blue}{\cos im} \]
    4. Taylor expanded in im around 0 15.8%

      \[\leadsto \color{blue}{1 + -0.5 \cdot {im}^{2}} \]
    5. Step-by-step derivation
      1. unpow215.8%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
    6. Applied egg-rr15.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 2.15 \cdot 10^{+105}:\\ \;\;\;\;\frac{e \cdot \left(re + 1\right)}{e}\\ \mathbf{else}:\\ \;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 30.8% accurate, 16.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 8.2 \cdot 10^{+105}:\\ \;\;\;\;re + 1\\ \mathbf{else}:\\ \;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 8.2e+105) (+ re 1.0) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
	double tmp;
	if (re <= 8.2e+105) {
		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 <= 8.2d+105) 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 <= 8.2e+105) {
		tmp = re + 1.0;
	} else {
		tmp = 1.0 + (-0.5 * (im * im));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 8.2e+105:
		tmp = re + 1.0
	else:
		tmp = 1.0 + (-0.5 * (im * im))
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 8.2e+105)
		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 <= 8.2e+105)
		tmp = re + 1.0;
	else
		tmp = 1.0 + (-0.5 * (im * im));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 8.2e+105], 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 8.2 \cdot 10^{+105}:\\
\;\;\;\;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 < 8.2000000000000005e105

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 67.9%

      \[\leadsto \color{blue}{e^{re}} \]
    4. Taylor expanded in re around 0 32.9%

      \[\leadsto \color{blue}{1 + re} \]
    5. Step-by-step derivation
      1. +-commutative32.9%

        \[\leadsto \color{blue}{re + 1} \]
    6. Simplified32.9%

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

    if 8.2000000000000005e105 < re

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 3.1%

      \[\leadsto \color{blue}{\cos im} \]
    4. Taylor expanded in im around 0 15.8%

      \[\leadsto \color{blue}{1 + -0.5 \cdot {im}^{2}} \]
    5. Step-by-step derivation
      1. unpow215.8%

        \[\leadsto 1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
    6. Applied egg-rr15.8%

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

Alternative 11: 38.5% accurate, 22.6× speedup?

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

\\
1 + re \cdot \left(1 + re \cdot 0.5\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[e^{re} \cdot \cos im \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 68.4%

    \[\leadsto \color{blue}{e^{re}} \]
  4. Taylor expanded in re around 0 39.0%

    \[\leadsto \color{blue}{1 + re \cdot \left(1 + 0.5 \cdot re\right)} \]
  5. Step-by-step derivation
    1. *-commutative68.8%

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

    \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot 0.5\right)} \]
  7. Add Preprocessing

Alternative 12: 29.2% 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. Add Preprocessing
  3. Taylor expanded in im around 0 68.4%

    \[\leadsto \color{blue}{e^{re}} \]
  4. Taylor expanded in re around 0 28.0%

    \[\leadsto \color{blue}{1 + re} \]
  5. Step-by-step derivation
    1. +-commutative28.0%

      \[\leadsto \color{blue}{re + 1} \]
  6. Simplified28.0%

    \[\leadsto \color{blue}{re + 1} \]
  7. Add Preprocessing

Alternative 13: 28.7% accurate, 203.0× speedup?

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

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

    \[e^{re} \cdot \cos im \]
  2. Add Preprocessing
  3. Taylor expanded in im around 0 68.4%

    \[\leadsto \color{blue}{e^{re}} \]
  4. Taylor expanded in re around 0 27.3%

    \[\leadsto \color{blue}{1} \]
  5. Add Preprocessing

Reproduce

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