math.exp on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 8.4s
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. Final simplification100.0%

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

Alternative 2: 93.3% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

    if 0.999998000000000054 < (exp.f64 re) < 1.5

    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-out100.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 simplification92.4%

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

Alternative 3: 71.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{re} \leq 1:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;e^{re} \leq 1.5:\\ \;\;\;\;\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) 1.5) (cos im) (exp re))))
double code(double re, double im) {
	double tmp;
	if (exp(re) <= 1.0) {
		tmp = exp(re);
	} else if (exp(re) <= 1.5) {
		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) <= 1.5d0) 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) <= 1.5) {
		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) <= 1.5:
		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) <= 1.5)
		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) <= 1.5)
		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], 1.5], 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 1.5:\\
\;\;\;\;\cos im\\

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


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

    1. Initial program 100.0%

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

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

    if 1 < (exp.f64 re) < 1.5

    1. Initial program 100.0%

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

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

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

Alternative 4: 95.9% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.225 \lor \neg \left(re \leq 2.2 \cdot 10^{-18}\right) \land re \leq 2.05 \cdot 10^{+151}:\\
\;\;\;\;e^{re}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -0.225000000000000006 or 2.1999999999999998e-18 < re < 2.0499999999999999e151

    1. Initial program 100.0%

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

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

    if -0.225000000000000006 < re < 2.1999999999999998e-18 or 2.0499999999999999e151 < re

    1. Initial program 100.0%

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

      \[\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. *-commutative98.2%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -0.225 \lor \neg \left(re \leq 2.2 \cdot 10^{-18}\right) \land re \leq 2.05 \cdot 10^{+151}:\\ \;\;\;\;e^{re}\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(re + \left(1 + 0.5 \cdot \left(re \cdot re\right)\right)\right)\\ \end{array} \]

Alternative 5: 93.0% accurate, 1.8× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

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

    if -3.59999999999999984e-6 < re < 2.1999999999999998e-18

    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-out100.0%

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

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

    if 2.1999999999999998e-18 < re

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified72.9%

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

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

Alternative 6: 66.5% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -580:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\

\mathbf{elif}\;re \leq 5 \cdot 10^{+28}:\\
\;\;\;\;\cos im\\

\mathbf{elif}\;re \leq 2.1 \cdot 10^{+153}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot e^{re}\right) \cdot \left(im \cdot im\right)} \]
      3. *-commutative78.1%

        \[\leadsto \color{blue}{\left(e^{re} \cdot -0.5\right)} \cdot \left(im \cdot im\right) \]
      4. associate-*l*78.1%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot {im}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative21.6%

        \[\leadsto \color{blue}{{im}^{2} \cdot -0.5} \]
      2. unpow221.6%

        \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot -0.5 \]
      3. associate-*r*21.6%

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

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

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

    if -580 < re < 4.99999999999999957e28

    1. Initial program 100.0%

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

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

    if 4.99999999999999957e28 < re < 2.10000000000000017e153

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 2.10000000000000017e153 < re

    1. Initial program 100.0%

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

      \[\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. *-commutative100.0%

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

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

        \[\leadsto \cos im \cdot \left({re}^{2} \cdot 0.5\right) + \left(\cos im \cdot re + \color{blue}{\cos im \cdot 1}\right) \]
      4. distribute-lft-out100.0%

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

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

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

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

        \[\leadsto \cos im \cdot \left(re + \left(1 + \color{blue}{0.5 \cdot {re}^{2}}\right)\right) \]
      9. unpow2100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -580:\\ \;\;\;\;im \cdot \left(im \cdot -0.5\right)\\ \mathbf{elif}\;re \leq 5 \cdot 10^{+28}:\\ \;\;\;\;\cos im\\ \mathbf{elif}\;re \leq 2.1 \cdot 10^{+153}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re + \left(1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \end{array} \]

Alternative 7: 44.6% accurate, 11.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -550:\\ \;\;\;\;im \cdot \left(im \cdot -0.5\right)\\ \mathbf{elif}\;re \leq 8.5 \cdot 10^{+56} \lor \neg \left(re \leq 1.15 \cdot 10^{+153}\right):\\ \;\;\;\;re + \left(1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re -550.0)
   (* im (* im -0.5))
   (if (or (<= re 8.5e+56) (not (<= re 1.15e+153)))
     (+ re (+ 1.0 (* 0.5 (* re re))))
     (* (+ re 1.0) (+ 1.0 (* -0.5 (* im im)))))))
double code(double re, double im) {
	double tmp;
	if (re <= -550.0) {
		tmp = im * (im * -0.5);
	} else if ((re <= 8.5e+56) || !(re <= 1.15e+153)) {
		tmp = re + (1.0 + (0.5 * (re * re)));
	} else {
		tmp = (re + 1.0) * (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 <= (-550.0d0)) then
        tmp = im * (im * (-0.5d0))
    else if ((re <= 8.5d+56) .or. (.not. (re <= 1.15d+153))) then
        tmp = re + (1.0d0 + (0.5d0 * (re * re)))
    else
        tmp = (re + 1.0d0) * (1.0d0 + ((-0.5d0) * (im * im)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= -550.0) {
		tmp = im * (im * -0.5);
	} else if ((re <= 8.5e+56) || !(re <= 1.15e+153)) {
		tmp = re + (1.0 + (0.5 * (re * re)));
	} else {
		tmp = (re + 1.0) * (1.0 + (-0.5 * (im * im)));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= -550.0:
		tmp = im * (im * -0.5)
	elif (re <= 8.5e+56) or not (re <= 1.15e+153):
		tmp = re + (1.0 + (0.5 * (re * re)))
	else:
		tmp = (re + 1.0) * (1.0 + (-0.5 * (im * im)))
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= -550.0)
		tmp = Float64(im * Float64(im * -0.5));
	elseif ((re <= 8.5e+56) || !(re <= 1.15e+153))
		tmp = Float64(re + Float64(1.0 + Float64(0.5 * Float64(re * re))));
	else
		tmp = Float64(Float64(re + 1.0) * Float64(1.0 + Float64(-0.5 * Float64(im * im))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= -550.0)
		tmp = im * (im * -0.5);
	elseif ((re <= 8.5e+56) || ~((re <= 1.15e+153)))
		tmp = re + (1.0 + (0.5 * (re * re)));
	else
		tmp = (re + 1.0) * (1.0 + (-0.5 * (im * im)));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, -550.0], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, 8.5e+56], N[Not[LessEqual[re, 1.15e+153]], $MachinePrecision]], N[(re + N[(1.0 + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(re + 1.0), $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -550:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\

\mathbf{elif}\;re \leq 8.5 \cdot 10^{+56} \lor \neg \left(re \leq 1.15 \cdot 10^{+153}\right):\\
\;\;\;\;re + \left(1 + 0.5 \cdot \left(re \cdot re\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot e^{re}\right) \cdot \left(im \cdot im\right)} \]
      3. *-commutative78.1%

        \[\leadsto \color{blue}{\left(e^{re} \cdot -0.5\right)} \cdot \left(im \cdot im\right) \]
      4. associate-*l*78.1%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot {im}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative21.6%

        \[\leadsto \color{blue}{{im}^{2} \cdot -0.5} \]
      2. unpow221.6%

        \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot -0.5 \]
      3. associate-*r*21.6%

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

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

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

    if -550 < re < 8.4999999999999998e56 or 1.1500000000000001e153 < re

    1. Initial program 100.0%

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

      \[\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. *-commutative92.3%

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

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

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

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

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

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

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

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

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

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

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

    if 8.4999999999999998e56 < re < 1.1500000000000001e153

    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-out4.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 29.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -550:\\ \;\;\;\;im \cdot \left(im \cdot -0.5\right)\\ \mathbf{elif}\;re \leq 8.5 \cdot 10^{+56} \lor \neg \left(re \leq 1.15 \cdot 10^{+153}\right):\\ \;\;\;\;re + \left(1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\ \end{array} \]

Alternative 8: 44.9% accurate, 13.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -580:\\ \;\;\;\;im \cdot \left(im \cdot -0.5\right)\\ \mathbf{elif}\;re \leq 1.45 \cdot 10^{+57} \lor \neg \left(re \leq 3 \cdot 10^{+152}\right):\\ \;\;\;\;re + \left(1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot im\right) \cdot -0.25\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re -580.0)
   (* im (* im -0.5))
   (if (or (<= re 1.45e+57) (not (<= re 3e+152)))
     (+ re (+ 1.0 (* 0.5 (* re re))))
     (* re (* re (* (* im im) -0.25))))))
double code(double re, double im) {
	double tmp;
	if (re <= -580.0) {
		tmp = im * (im * -0.5);
	} else if ((re <= 1.45e+57) || !(re <= 3e+152)) {
		tmp = re + (1.0 + (0.5 * (re * re)));
	} else {
		tmp = re * (re * ((im * im) * -0.25));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: tmp
    if (re <= (-580.0d0)) then
        tmp = im * (im * (-0.5d0))
    else if ((re <= 1.45d+57) .or. (.not. (re <= 3d+152))) then
        tmp = re + (1.0d0 + (0.5d0 * (re * re)))
    else
        tmp = re * (re * ((im * im) * (-0.25d0)))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if (re <= -580.0) {
		tmp = im * (im * -0.5);
	} else if ((re <= 1.45e+57) || !(re <= 3e+152)) {
		tmp = re + (1.0 + (0.5 * (re * re)));
	} else {
		tmp = re * (re * ((im * im) * -0.25));
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= -580.0:
		tmp = im * (im * -0.5)
	elif (re <= 1.45e+57) or not (re <= 3e+152):
		tmp = re + (1.0 + (0.5 * (re * re)))
	else:
		tmp = re * (re * ((im * im) * -0.25))
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= -580.0)
		tmp = Float64(im * Float64(im * -0.5));
	elseif ((re <= 1.45e+57) || !(re <= 3e+152))
		tmp = Float64(re + Float64(1.0 + Float64(0.5 * Float64(re * re))));
	else
		tmp = Float64(re * Float64(re * Float64(Float64(im * im) * -0.25)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= -580.0)
		tmp = im * (im * -0.5);
	elseif ((re <= 1.45e+57) || ~((re <= 3e+152)))
		tmp = re + (1.0 + (0.5 * (re * re)));
	else
		tmp = re * (re * ((im * im) * -0.25));
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, -580.0], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[re, 1.45e+57], N[Not[LessEqual[re, 3e+152]], $MachinePrecision]], N[(re + N[(1.0 + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(re * N[(re * N[(N[(im * im), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -580:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\

\mathbf{elif}\;re \leq 1.45 \cdot 10^{+57} \lor \neg \left(re \leq 3 \cdot 10^{+152}\right):\\
\;\;\;\;re + \left(1 + 0.5 \cdot \left(re \cdot re\right)\right)\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot im\right) \cdot -0.25\right)\right)\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot e^{re}\right) \cdot \left(im \cdot im\right)} \]
      3. *-commutative78.1%

        \[\leadsto \color{blue}{\left(e^{re} \cdot -0.5\right)} \cdot \left(im \cdot im\right) \]
      4. associate-*l*78.1%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot {im}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative21.6%

        \[\leadsto \color{blue}{{im}^{2} \cdot -0.5} \]
      2. unpow221.6%

        \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot -0.5 \]
      3. associate-*r*21.6%

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

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

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

    if -580 < re < 1.4500000000000001e57 or 2.99999999999999991e152 < re

    1. Initial program 100.0%

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

      \[\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. *-commutative92.3%

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

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

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

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

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

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

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

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

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

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

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

    if 1.4500000000000001e57 < re < 2.99999999999999991e152

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(e^{re} \cdot -0.5\right)} \cdot \left(im \cdot im\right) \]
      4. associate-*l*31.8%

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

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

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

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

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

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

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

        \[\leadsto \left(-0.25 \cdot \left({re}^{2} \cdot {im}^{2}\right) + \color{blue}{im \cdot \left(im \cdot -0.5\right)}\right) + -0.5 \cdot \left(re \cdot {im}^{2}\right) \]
      6. associate-+l+28.1%

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

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

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

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

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

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

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

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

        \[\leadsto {im}^{2} \cdot \left(-0.25 \cdot {re}^{2}\right) + {im}^{2} \cdot \left(\color{blue}{-0.5 \cdot 1} + -0.5 \cdot re\right) \]
      15. distribute-lft-in28.1%

        \[\leadsto {im}^{2} \cdot \left(-0.25 \cdot {re}^{2}\right) + {im}^{2} \cdot \color{blue}{\left(-0.5 \cdot \left(1 + re\right)\right)} \]
      16. distribute-lft-out28.1%

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

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

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

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

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

        \[\leadsto -0.25 \cdot \left(\left(re \cdot re\right) \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
      3. associate-*r*28.1%

        \[\leadsto \color{blue}{\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(im \cdot im\right)} \]
      4. *-commutative28.1%

        \[\leadsto \color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot \left(im \cdot im\right) \]
      5. associate-*r*28.1%

        \[\leadsto \color{blue}{\left(re \cdot \left(re \cdot -0.25\right)\right)} \cdot \left(im \cdot im\right) \]
      6. associate-*r*28.1%

        \[\leadsto \color{blue}{re \cdot \left(\left(re \cdot -0.25\right) \cdot \left(im \cdot im\right)\right)} \]
      7. associate-*l*28.1%

        \[\leadsto re \cdot \color{blue}{\left(re \cdot \left(-0.25 \cdot \left(im \cdot im\right)\right)\right)} \]
    13. Simplified28.1%

      \[\leadsto \color{blue}{re \cdot \left(re \cdot \left(-0.25 \cdot \left(im \cdot im\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification43.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -580:\\ \;\;\;\;im \cdot \left(im \cdot -0.5\right)\\ \mathbf{elif}\;re \leq 1.45 \cdot 10^{+57} \lor \neg \left(re \leq 3 \cdot 10^{+152}\right):\\ \;\;\;\;re + \left(1 + 0.5 \cdot \left(re \cdot re\right)\right)\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot im\right) \cdot -0.25\right)\right)\\ \end{array} \]

Alternative 9: 38.7% accurate, 15.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.222:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\

\mathbf{elif}\;re \leq 8.5 \cdot 10^{+56}:\\
\;\;\;\;re + 1\\

\mathbf{else}:\\
\;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot im\right) \cdot -0.25\right)\right)\\


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified75.9%

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot e^{re}\right) \cdot \left(im \cdot im\right)} \]
      3. *-commutative75.9%

        \[\leadsto \color{blue}{\left(e^{re} \cdot -0.5\right)} \cdot \left(im \cdot im\right) \]
      4. associate-*l*75.9%

        \[\leadsto \color{blue}{e^{re} \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)} \]
    7. Simplified75.9%

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

      \[\leadsto \color{blue}{-0.5 \cdot {im}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative21.1%

        \[\leadsto \color{blue}{{im}^{2} \cdot -0.5} \]
      2. unpow221.1%

        \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot -0.5 \]
      3. associate-*r*21.1%

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

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

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

    if -0.222000000000000003 < re < 8.4999999999999998e56

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 8.4999999999999998e56 < re

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified74.5%

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot e^{re}\right) \cdot \left(im \cdot im\right)} \]
      3. *-commutative29.8%

        \[\leadsto \color{blue}{\left(e^{re} \cdot -0.5\right)} \cdot \left(im \cdot im\right) \]
      4. associate-*l*29.8%

        \[\leadsto \color{blue}{e^{re} \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)} \]
    7. Simplified29.8%

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

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

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

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

        \[\leadsto \left(-0.25 \cdot \left({re}^{2} \cdot {im}^{2}\right) + \color{blue}{{im}^{2} \cdot -0.5}\right) + -0.5 \cdot \left(re \cdot {im}^{2}\right) \]
      4. unpow228.0%

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

        \[\leadsto \left(-0.25 \cdot \left({re}^{2} \cdot {im}^{2}\right) + \color{blue}{im \cdot \left(im \cdot -0.5\right)}\right) + -0.5 \cdot \left(re \cdot {im}^{2}\right) \]
      6. associate-+l+28.0%

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

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

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

        \[\leadsto {im}^{2} \cdot \left(-0.25 \cdot {re}^{2}\right) + \left(\color{blue}{\left(im \cdot im\right) \cdot -0.5} + -0.5 \cdot \left(re \cdot {im}^{2}\right)\right) \]
      10. unpow228.0%

        \[\leadsto {im}^{2} \cdot \left(-0.25 \cdot {re}^{2}\right) + \left(\color{blue}{{im}^{2}} \cdot -0.5 + -0.5 \cdot \left(re \cdot {im}^{2}\right)\right) \]
      11. *-commutative28.0%

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

        \[\leadsto {im}^{2} \cdot \left(-0.25 \cdot {re}^{2}\right) + \left(-0.5 \cdot {im}^{2} + \color{blue}{\left(-0.5 \cdot re\right) \cdot {im}^{2}}\right) \]
      13. distribute-rgt-out28.0%

        \[\leadsto {im}^{2} \cdot \left(-0.25 \cdot {re}^{2}\right) + \color{blue}{{im}^{2} \cdot \left(-0.5 + -0.5 \cdot re\right)} \]
      14. metadata-eval28.0%

        \[\leadsto {im}^{2} \cdot \left(-0.25 \cdot {re}^{2}\right) + {im}^{2} \cdot \left(\color{blue}{-0.5 \cdot 1} + -0.5 \cdot re\right) \]
      15. distribute-lft-in28.0%

        \[\leadsto {im}^{2} \cdot \left(-0.25 \cdot {re}^{2}\right) + {im}^{2} \cdot \color{blue}{\left(-0.5 \cdot \left(1 + re\right)\right)} \]
      16. distribute-lft-out28.0%

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

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

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

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

        \[\leadsto -0.25 \cdot \left(\color{blue}{\left(re \cdot re\right)} \cdot {im}^{2}\right) \]
      2. unpow228.0%

        \[\leadsto -0.25 \cdot \left(\left(re \cdot re\right) \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
      3. associate-*r*28.0%

        \[\leadsto \color{blue}{\left(-0.25 \cdot \left(re \cdot re\right)\right) \cdot \left(im \cdot im\right)} \]
      4. *-commutative28.0%

        \[\leadsto \color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot \left(im \cdot im\right) \]
      5. associate-*r*28.0%

        \[\leadsto \color{blue}{\left(re \cdot \left(re \cdot -0.25\right)\right)} \cdot \left(im \cdot im\right) \]
      6. associate-*r*28.2%

        \[\leadsto \color{blue}{re \cdot \left(\left(re \cdot -0.25\right) \cdot \left(im \cdot im\right)\right)} \]
      7. associate-*l*28.2%

        \[\leadsto re \cdot \color{blue}{\left(re \cdot \left(-0.25 \cdot \left(im \cdot im\right)\right)\right)} \]
    13. Simplified28.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -0.222:\\ \;\;\;\;im \cdot \left(im \cdot -0.5\right)\\ \mathbf{elif}\;re \leq 8.5 \cdot 10^{+56}:\\ \;\;\;\;re + 1\\ \mathbf{else}:\\ \;\;\;\;re \cdot \left(re \cdot \left(\left(im \cdot im\right) \cdot -0.25\right)\right)\\ \end{array} \]

Alternative 10: 37.9% accurate, 18.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.222:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\

\mathbf{elif}\;re \leq 8.5 \cdot 10^{+56}:\\
\;\;\;\;re + 1\\

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified75.9%

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot e^{re}\right) \cdot \left(im \cdot im\right)} \]
      3. *-commutative75.9%

        \[\leadsto \color{blue}{\left(e^{re} \cdot -0.5\right)} \cdot \left(im \cdot im\right) \]
      4. associate-*l*75.9%

        \[\leadsto \color{blue}{e^{re} \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)} \]
    7. Simplified75.9%

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

      \[\leadsto \color{blue}{-0.5 \cdot {im}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative21.1%

        \[\leadsto \color{blue}{{im}^{2} \cdot -0.5} \]
      2. unpow221.1%

        \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot -0.5 \]
      3. associate-*r*21.1%

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

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

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

    if -0.222000000000000003 < re < 8.4999999999999998e56

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if 8.4999999999999998e56 < re

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(re \cdot -0.5\right)} \cdot \left(im \cdot im\right) \]
      4. associate-*l*26.3%

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

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

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

Alternative 11: 36.7% accurate, 22.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -0.222 \lor \neg \left(re \leq 8.6 \cdot 10^{+57}\right):\\ \;\;\;\;im \cdot \left(im \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;re + 1\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (or (<= re -0.222) (not (<= re 8.6e+57))) (* im (* im -0.5)) (+ re 1.0)))
double code(double re, double im) {
	double tmp;
	if ((re <= -0.222) || !(re <= 8.6e+57)) {
		tmp = im * (im * -0.5);
	} else {
		tmp = 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 ((re <= (-0.222d0)) .or. (.not. (re <= 8.6d+57))) then
        tmp = im * (im * (-0.5d0))
    else
        tmp = re + 1.0d0
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double tmp;
	if ((re <= -0.222) || !(re <= 8.6e+57)) {
		tmp = im * (im * -0.5);
	} else {
		tmp = re + 1.0;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if (re <= -0.222) or not (re <= 8.6e+57):
		tmp = im * (im * -0.5)
	else:
		tmp = re + 1.0
	return tmp
function code(re, im)
	tmp = 0.0
	if ((re <= -0.222) || !(re <= 8.6e+57))
		tmp = Float64(im * Float64(im * -0.5));
	else
		tmp = Float64(re + 1.0);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if ((re <= -0.222) || ~((re <= 8.6e+57)))
		tmp = im * (im * -0.5);
	else
		tmp = re + 1.0;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[Or[LessEqual[re, -0.222], N[Not[LessEqual[re, 8.6e+57]], $MachinePrecision]], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.222 \lor \neg \left(re \leq 8.6 \cdot 10^{+57}\right):\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\

\mathbf{else}:\\
\;\;\;\;re + 1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -0.222000000000000003 or 8.60000000000000066e57 < re

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-0.5 \cdot e^{re}\right) \cdot \left(im \cdot im\right)} \]
      3. *-commutative56.7%

        \[\leadsto \color{blue}{\left(e^{re} \cdot -0.5\right)} \cdot \left(im \cdot im\right) \]
      4. associate-*l*56.7%

        \[\leadsto \color{blue}{e^{re} \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)} \]
    7. Simplified56.7%

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

      \[\leadsto \color{blue}{-0.5 \cdot {im}^{2}} \]
    9. Step-by-step derivation
      1. *-commutative19.1%

        \[\leadsto \color{blue}{{im}^{2} \cdot -0.5} \]
      2. unpow219.1%

        \[\leadsto \color{blue}{\left(im \cdot im\right)} \cdot -0.5 \]
      3. associate-*r*19.1%

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

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

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

    if -0.222000000000000003 < re < 8.60000000000000066e57

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{re + 1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -0.222 \lor \neg \left(re \leq 8.6 \cdot 10^{+57}\right):\\ \;\;\;\;im \cdot \left(im \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;re + 1\\ \end{array} \]

Alternative 12: 28.9% 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 52.6%

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

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

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

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

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

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

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

    \[\leadsto re + 1 \]

Alternative 13: 28.5% 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. Taylor expanded in re around 0 52.0%

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

    \[\leadsto \color{blue}{1} \]
  4. Final simplification29.4%

    \[\leadsto 1 \]

Reproduce

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