math.exp on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 8.4s
Alternatives: 20
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 20 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: 92.5% accurate, 0.7× speedup?

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

\mathbf{elif}\;e^{re} \leq 1:\\
\;\;\;\;\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.0 or 1 < (exp.f64 re)

    1. Initial program 100.0%

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

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

    if 0.0 < (exp.f64 re) < 1

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity99.9%

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

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

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

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

Alternative 3: 92.4% accurate, 0.7× speedup?

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

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

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

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


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

    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.999999999999999001 < (exp.f64 re) < 1

    1. Initial program 100.0%

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

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

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

Alternative 4: 96.2% accurate, 1.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -0.0033 or 2.00000000000000007e-10 < re < 1.35000000000000003e154

    1. Initial program 100.0%

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

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

    if -0.0033 < re < 2.00000000000000007e-10 or 1.35000000000000003e154 < 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 + \cos im\right) + 0.5 \cdot \left(\cos im \cdot {re}^{2}\right)} \]
      2. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 72.8% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;re \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\cos im\\

\mathbf{elif}\;re \leq 1.5 \cdot 10^{+154}:\\
\;\;\;\;\frac{1 - t_0 \cdot t_0}{1 - t_0}\\

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right) + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. distribute-lft-in27.9%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)} \]
    11. Step-by-step derivation
      1. expm1-log1p-u28.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\right)\right)} \]
      2. expm1-udef32.3%

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

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

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

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

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

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

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

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

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

    if -450 < re < 2.00000000000000007e-10

    1. Initial program 100.0%

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

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

    if 2.00000000000000007e-10 < re < 1.50000000000000013e154

    1. Initial program 100.0%

      \[e^{re} \cdot \cos im \]
    2. Taylor expanded in re around 0 8.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. +-commutative8.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \cdot \left(\left(1 + re\right) + 0.5 \cdot \left(re \cdot re\right)\right) \]
    6. Step-by-step derivation
      1. associate-+l+7.1%

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

        \[\leadsto 1 \cdot \color{blue}{\frac{1 \cdot 1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(re + 0.5 \cdot \left(re \cdot re\right)\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)}} \]
      3. metadata-eval42.0%

        \[\leadsto 1 \cdot \frac{\color{blue}{1} - \left(re + 0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(re + 0.5 \cdot \left(re \cdot re\right)\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      4. *-commutative42.0%

        \[\leadsto 1 \cdot \frac{1 - \left(re + \color{blue}{\left(re \cdot re\right) \cdot 0.5}\right) \cdot \left(re + 0.5 \cdot \left(re \cdot re\right)\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      5. associate-*l*42.0%

        \[\leadsto 1 \cdot \frac{1 - \left(re + \color{blue}{re \cdot \left(re \cdot 0.5\right)}\right) \cdot \left(re + 0.5 \cdot \left(re \cdot re\right)\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      6. *-commutative42.0%

        \[\leadsto 1 \cdot \frac{1 - \left(re + re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(re + \color{blue}{\left(re \cdot re\right) \cdot 0.5}\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      7. associate-*l*42.0%

        \[\leadsto 1 \cdot \frac{1 - \left(re + re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(re + \color{blue}{re \cdot \left(re \cdot 0.5\right)}\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      8. *-commutative42.0%

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

        \[\leadsto 1 \cdot \frac{1 - \left(re + re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(re + re \cdot \left(re \cdot 0.5\right)\right)}{1 - \left(re + \color{blue}{re \cdot \left(re \cdot 0.5\right)}\right)} \]
    7. Applied egg-rr42.0%

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

    if 1.50000000000000013e154 < 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 + \cos im\right) + 0.5 \cdot \left(\cos im \cdot {re}^{2}\right)} \]
      2. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified81.5%

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

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

Alternative 6: 51.3% accurate, 6.5× speedup?

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

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

\mathbf{elif}\;re \leq 1.5 \cdot 10^{+154}:\\
\;\;\;\;\frac{1 - t_0 \cdot t_0}{1 - t_0}\\

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right) + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. distribute-lft-in27.9%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)} \]
    11. Step-by-step derivation
      1. expm1-log1p-u28.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\right)\right)} \]
      2. expm1-udef32.3%

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

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

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

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

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

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

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

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

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

    if -420 < re < 1.50000000000000013e154

    1. Initial program 100.0%

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

      \[\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. +-commutative76.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \cdot \left(\left(1 + re\right) + 0.5 \cdot \left(re \cdot re\right)\right) \]
    6. Step-by-step derivation
      1. associate-+l+43.1%

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

        \[\leadsto 1 \cdot \color{blue}{\frac{1 \cdot 1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right) \cdot \left(re + 0.5 \cdot \left(re \cdot re\right)\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)}} \]
      3. metadata-eval51.9%

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

        \[\leadsto 1 \cdot \frac{1 - \left(re + \color{blue}{\left(re \cdot re\right) \cdot 0.5}\right) \cdot \left(re + 0.5 \cdot \left(re \cdot re\right)\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      5. associate-*l*51.9%

        \[\leadsto 1 \cdot \frac{1 - \left(re + \color{blue}{re \cdot \left(re \cdot 0.5\right)}\right) \cdot \left(re + 0.5 \cdot \left(re \cdot re\right)\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      6. *-commutative51.9%

        \[\leadsto 1 \cdot \frac{1 - \left(re + re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(re + \color{blue}{\left(re \cdot re\right) \cdot 0.5}\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      7. associate-*l*51.9%

        \[\leadsto 1 \cdot \frac{1 - \left(re + re \cdot \left(re \cdot 0.5\right)\right) \cdot \left(re + \color{blue}{re \cdot \left(re \cdot 0.5\right)}\right)}{1 - \left(re + 0.5 \cdot \left(re \cdot re\right)\right)} \]
      8. *-commutative51.9%

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

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

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

    if 1.50000000000000013e154 < 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 + \cos im\right) + 0.5 \cdot \left(\cos im \cdot {re}^{2}\right)} \]
      2. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified81.5%

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

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

Alternative 7: 48.0% accurate, 9.6× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right) + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. distribute-lft-in27.9%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)} \]
    11. Step-by-step derivation
      1. expm1-log1p-u28.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\right)\right)} \]
      2. expm1-udef32.3%

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

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

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

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

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

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

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

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

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

    if -410 < re < 1.15e24

    1. Initial program 100.0%

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

      \[\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. +-commutative97.7%

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

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

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

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

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

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

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

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

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

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

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

    if 1.15e24 < re < 5.50000000000000035e142

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right) + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. distribute-lft-in16.6%

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

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

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

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

        \[\leadsto -0.5 \cdot \left(\color{blue}{\frac{1 \cdot 1 - re \cdot re}{1 - re}} \cdot \left(im \cdot im\right)\right) \]
      3. associate-*l/19.5%

        \[\leadsto -0.5 \cdot \color{blue}{\frac{\left(1 \cdot 1 - re \cdot re\right) \cdot \left(im \cdot im\right)}{1 - re}} \]
      4. metadata-eval19.5%

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

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

    if 5.50000000000000035e142 < re

    1. Initial program 100.0%

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

      \[\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. +-commutative88.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified72.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -410:\\ \;\;\;\;\left(1 + \left(im \cdot im\right) \cdot \left(-0.5 + re \cdot -0.5\right)\right) + -1\\ \mathbf{elif}\;re \leq 1.15 \cdot 10^{+24}:\\ \;\;\;\;0.5 \cdot \left(re \cdot re\right) + \left(re + 1\right)\\ \mathbf{elif}\;re \leq 5.5 \cdot 10^{+142}:\\ \;\;\;\;-0.5 \cdot \frac{\left(im \cdot im\right) \cdot \left(1 - re \cdot re\right)}{1 - re}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot re\right)\\ \end{array} \]

Alternative 8: 48.7% accurate, 9.6× speedup?

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

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

\mathbf{elif}\;re \leq 1.45 \cdot 10^{-34}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right) + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. distribute-lft-in27.9%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)} \]
    11. Step-by-step derivation
      1. expm1-log1p-u28.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\right)\right)} \]
      2. expm1-udef32.3%

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

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

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

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

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

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

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

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

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

    if -420 < re < 1.4500000000000001e-34

    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 + \cos im\right) + 0.5 \cdot \left(\cos im \cdot {re}^{2}\right)} \]
      2. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

    if 1.4500000000000001e-34 < re

    1. Initial program 100.0%

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

      \[\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. +-commutative48.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 45.3% accurate, 10.6× speedup?

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

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

\mathbf{elif}\;re \leq 1.45 \cdot 10^{-34}:\\
\;\;\;\;t_0 + \left(re + 1\right)\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

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

    if -520 < re < 1.4500000000000001e-34

    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 + \cos im\right) + 0.5 \cdot \left(\cos im \cdot {re}^{2}\right)} \]
      2. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

    if 1.4500000000000001e-34 < re < 1.54999999999999995e143

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity18.0%

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

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

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

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

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

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

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

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

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

    if 1.54999999999999995e143 < re

    1. Initial program 100.0%

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

      \[\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. +-commutative88.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified72.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -520:\\ \;\;\;\;\left(im \cdot im\right) \cdot -0.5\\ \mathbf{elif}\;re \leq 1.45 \cdot 10^{-34}:\\ \;\;\;\;0.5 \cdot \left(re \cdot re\right) + \left(re + 1\right)\\ \mathbf{elif}\;re \leq 1.55 \cdot 10^{+143}:\\ \;\;\;\;\left(re + 1\right) + -0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(re + 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot re\right)\\ \end{array} \]

Alternative 10: 47.9% accurate, 10.6× speedup?

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

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

\mathbf{elif}\;re \leq 4.4 \cdot 10^{-35}:\\
\;\;\;\;t_0 + \left(re + 1\right)\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right) + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. distribute-lft-in27.9%

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

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

      \[\leadsto \color{blue}{-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)} \]
    11. Step-by-step derivation
      1. expm1-log1p-u28.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(-0.5 \cdot \left(\left(re + 1\right) \cdot \left(im \cdot im\right)\right)\right)\right)} \]
      2. expm1-udef32.3%

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

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

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

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

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

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

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

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

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

    if -480 < re < 4.39999999999999987e-35

    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 + \cos im\right) + 0.5 \cdot \left(\cos im \cdot {re}^{2}\right)} \]
      2. +-commutative100.0%

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

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

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

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

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

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

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

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

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

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

    if 4.39999999999999987e-35 < re < 1.5e143

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity18.0%

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

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

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

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

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

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

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

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

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

    if 1.5e143 < re

    1. Initial program 100.0%

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

      \[\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. +-commutative88.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified72.2%

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

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

Alternative 11: 45.4% accurate, 13.4× speedup?

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

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

\mathbf{elif}\;re \leq 520:\\
\;\;\;\;re + 1\\

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

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

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

    if -150 < re < 520

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity99.2%

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

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

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

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

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

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

    if 520 < re < 1.54999999999999995e143

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity3.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.54999999999999995e143 < re

    1. Initial program 100.0%

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

      \[\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. +-commutative88.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified72.2%

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

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

Alternative 12: 45.2% accurate, 13.4× speedup?

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

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

\mathbf{elif}\;re \leq 2.1 \cdot 10^{+23}:\\
\;\;\;\;t_1 + \left(re + 1\right)\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\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.9%

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

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

    if -580 < re < 2.1000000000000001e23

    1. Initial program 100.0%

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

      \[\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. +-commutative97.7%

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

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

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

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

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

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

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

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

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

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

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

    if 2.1000000000000001e23 < re < 5.80000000000000027e142

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity3.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.80000000000000027e142 < re

    1. Initial program 100.0%

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

      \[\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. +-commutative88.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified72.2%

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

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

Alternative 13: 45.0% accurate, 15.4× speedup?

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

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

\mathbf{elif}\;re \leq 1.6 \cdot 10^{+23}:\\
\;\;\;\;re + 1\\

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

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

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

    if -330 < re < 1.6e23

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity97.6%

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

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

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

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

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

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

    if 1.6e23 < re < 1.54999999999999995e143

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right) + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. distribute-lft-in16.6%

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

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

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

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

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

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

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

    if 1.54999999999999995e143 < re

    1. Initial program 100.0%

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

      \[\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. +-commutative88.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified72.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -330:\\ \;\;\;\;\left(im \cdot im\right) \cdot -0.5\\ \mathbf{elif}\;re \leq 1.6 \cdot 10^{+23}:\\ \;\;\;\;re + 1\\ \mathbf{elif}\;re \leq 1.55 \cdot 10^{+143}:\\ \;\;\;\;-0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot re\right)\\ \end{array} \]

Alternative 14: 44.9% accurate, 15.4× speedup?

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

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

\mathbf{elif}\;re \leq 1.6 \cdot 10^{+23}:\\
\;\;\;\;re + 1\\

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

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

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

    if -34 < re < 1.6e23

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity97.6%

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

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

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

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

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

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

    if 1.6e23 < re < 9.0000000000000003e140

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity3.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.0000000000000003e140 < re

    1. Initial program 100.0%

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

      \[\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. +-commutative88.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified72.2%

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

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

Alternative 15: 44.9% accurate, 15.4× speedup?

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

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

\mathbf{elif}\;re \leq 2.7 \cdot 10^{+23}:\\
\;\;\;\;re + 1\\

\mathbf{elif}\;re \leq 1.55 \cdot 10^{+143}:\\
\;\;\;\;1 + t_0\\

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

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

    if -260 < re < 2.6999999999999999e23

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity97.6%

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

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

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

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

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

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

    if 2.6999999999999999e23 < re < 1.54999999999999995e143

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity3.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.54999999999999995e143 < re

    1. Initial program 100.0%

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

      \[\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. +-commutative88.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \left(0.5 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
    8. Simplified72.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -260:\\ \;\;\;\;\left(im \cdot im\right) \cdot -0.5\\ \mathbf{elif}\;re \leq 2.7 \cdot 10^{+23}:\\ \;\;\;\;re + 1\\ \mathbf{elif}\;re \leq 1.55 \cdot 10^{+143}:\\ \;\;\;\;1 + \left(im \cdot im\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(re \cdot re\right)\\ \end{array} \]

Alternative 16: 38.6% accurate, 18.2× speedup?

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

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

\mathbf{elif}\;re \leq 3.4 \cdot 10^{+23}:\\
\;\;\;\;re + 1\\

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified78.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 78.9%

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

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

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

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

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

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

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

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

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

    if -380 < re < 3.39999999999999992e23

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity97.6%

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

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

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

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

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

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

    if 3.39999999999999992e23 < re

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -0.5 \cdot \left(re \cdot \left(im \cdot im\right)\right) + -0.5 \cdot \color{blue}{\left(im \cdot im\right)} \]
      3. distribute-lft-in16.7%

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

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

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

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

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

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

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

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

Alternative 17: 37.1% accurate, 22.2× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < -165 or 1.2999999999999999e24 < re

    1. Initial program 100.0%

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

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

        \[\leadsto e^{re} \cdot \left(1 + -0.5 \cdot \color{blue}{\left(im \cdot im\right)}\right) \]
    4. Simplified79.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 50.0%

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

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

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

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

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

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

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

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

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

    if -165 < re < 1.2999999999999999e24

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
      2. *-rgt-identity97.6%

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

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

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

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

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

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

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

Alternative 18: 29.1% 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 48.4%

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

      \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
    2. *-rgt-identity48.4%

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

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

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

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

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

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

    \[\leadsto re + 1 \]

Alternative 19: 3.5% accurate, 203.0× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\cos im + \cos im \cdot re} \]
    2. *-rgt-identity48.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{re} \]
  12. Final simplification3.4%

    \[\leadsto re \]

Alternative 20: 28.6% 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 58.4%

    \[\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. +-commutative58.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 1 \cdot \color{blue}{1} \]
  7. Final simplification27.2%

    \[\leadsto 1 \]

Reproduce

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