math.exp on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 22.5s
Alternatives: 27
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 27 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

    \[e^{re} \cdot \cos im \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 93.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{re} \leq 0:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;e^{re} \leq 1.005:\\ \;\;\;\;\frac{\cos im}{1 - re}\\ \mathbf{else}:\\ \;\;\;\;e^{re}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (exp re) 0.0)
   (exp re)
   (if (<= (exp re) 1.005) (/ (cos im) (- 1.0 re)) (exp re))))
double code(double re, double im) {
	double tmp;
	if (exp(re) <= 0.0) {
		tmp = exp(re);
	} else if (exp(re) <= 1.005) {
		tmp = cos(im) / (1.0 - re);
	} 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.005d0) then
        tmp = cos(im) / (1.0d0 - re)
    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.005) {
		tmp = Math.cos(im) / (1.0 - re);
	} 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.005:
		tmp = math.cos(im) / (1.0 - re)
	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.005)
		tmp = Float64(cos(im) / Float64(1.0 - re));
	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.005)
		tmp = cos(im) / (1.0 - re);
	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.005], N[(N[Cos[im], $MachinePrecision] / N[(1.0 - re), $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.005:\\
\;\;\;\;\frac{\cos im}{1 - re}\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6484.7%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified84.7%

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

    if 0.0 < (exp.f64 re) < 1.0049999999999999

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6498.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified98.3%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \cos im \cdot \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)} \]
      2. flip3-+N/A

        \[\leadsto \cos im \cdot \frac{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}{\color{blue}{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}} \]
      3. clear-numN/A

        \[\leadsto \cos im \cdot \frac{1}{\color{blue}{\frac{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}}} \]
      4. un-div-invN/A

        \[\leadsto \frac{\cos im}{\color{blue}{\frac{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos im, \color{blue}{\left(\frac{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}\right)}\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \left(\frac{\color{blue}{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}\right)\right) \]
    7. Applied egg-rr98.2%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \color{blue}{\left(1 + -1 \cdot re\right)}\right) \]
    9. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \left(1 + \left(\mathsf{neg}\left(re\right)\right)\right)\right) \]
      2. unsub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \left(1 - \color{blue}{re}\right)\right) \]
      3. --lowering--.f6496.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{\_.f64}\left(1, \color{blue}{re}\right)\right) \]
    10. Simplified96.8%

      \[\leadsto \frac{\cos im}{\color{blue}{1 - re}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 93.3% accurate, 0.6× speedup?

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

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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6484.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified84.0%

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

    if 3.99999999999999984e-23 < (exp.f64 re) < 1.0049999999999999

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f6497.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified97.4%

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

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

Alternative 4: 92.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;e^{re} \leq 0:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;e^{re} \leq 1.000002:\\ \;\;\;\;\cos im\\ \mathbf{else}:\\ \;\;\;\;e^{re}\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= (exp re) 0.0) (exp re) (if (<= (exp re) 1.000002) (cos im) (exp re))))
double code(double re, double im) {
	double tmp;
	if (exp(re) <= 0.0) {
		tmp = exp(re);
	} else if (exp(re) <= 1.000002) {
		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.0d0) then
        tmp = exp(re)
    else if (exp(re) <= 1.000002d0) 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.0) {
		tmp = Math.exp(re);
	} else if (Math.exp(re) <= 1.000002) {
		tmp = Math.cos(im);
	} 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.000002:
		tmp = math.cos(im)
	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.000002)
		tmp = cos(im);
	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.000002)
		tmp = cos(im);
	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.000002], N[Cos[im], $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.000002:\\
\;\;\;\;\cos im\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6484.2%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified84.2%

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

    if 0.0 < (exp.f64 re) < 1.00000200000000006

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im} \]
    4. Step-by-step derivation
      1. cos-lowering-cos.f6494.9%

        \[\leadsto \mathsf{cos.f64}\left(im\right) \]
    5. Simplified94.9%

      \[\leadsto \color{blue}{\cos im} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 97.6% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;re \leq 0.0055:\\
\;\;\;\;\frac{\cos im}{1 + re \cdot \left(-1 + re \cdot \left(0.5 + re \cdot -0.16666666666666666\right)\right)}\\

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

    if -54 < re < 0.0054999999999999997

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6498.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified98.3%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \cos im \cdot \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)} \]
      2. flip3-+N/A

        \[\leadsto \cos im \cdot \frac{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}{\color{blue}{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}} \]
      3. clear-numN/A

        \[\leadsto \cos im \cdot \frac{1}{\color{blue}{\frac{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}}} \]
      4. un-div-invN/A

        \[\leadsto \frac{\cos im}{\color{blue}{\frac{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos im, \color{blue}{\left(\frac{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}\right)}\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \left(\frac{\color{blue}{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}\right)\right) \]
    7. Applied egg-rr98.2%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \color{blue}{\left(1 + re \cdot \left(re \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot re\right) - 1\right)\right)}\right) \]
    9. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(re \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot re\right) - 1\right)\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot re\right) - 1\right)}\right)\right)\right) \]
      3. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot re\right) + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)\right)\right) \]
      4. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot re\right) + -1\right)\right)\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(-1 + \color{blue}{re \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(-1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot re\right)\right)}\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{-1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{-1}{6} \cdot re\right)}\right)\right)\right)\right)\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{-1}{6}}\right)\right)\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f6498.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(-1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{-1}{6}}\right)\right)\right)\right)\right)\right)\right) \]
    10. Simplified98.3%

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

    if 0.0054999999999999997 < re < 1.01999999999999991e103

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6488.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified88.9%

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

    if 1.01999999999999991e103 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -54:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;re \leq 0.0055:\\ \;\;\;\;\frac{\cos im}{1 + re \cdot \left(-1 + re \cdot \left(0.5 + re \cdot -0.16666666666666666\right)\right)}\\ \mathbf{elif}\;re \leq 1.02 \cdot 10^{+103}:\\ \;\;\;\;e^{re} \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 97.6% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;re \leq 0.0055:\\
\;\;\;\;t\_0\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6498.4%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified98.4%

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

    if -0.049000000000000002 < re < 0.0054999999999999997 or 1.01999999999999991e103 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6499.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified99.2%

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

    if 0.0054999999999999997 < re < 1.01999999999999991e103

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6488.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified88.9%

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

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

Alternative 7: 96.6% accurate, 1.6× speedup?

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

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

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

    if -54 < re < 0.0054999999999999997

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6498.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified98.3%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(1 \cdot re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      2. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. associate-+r+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(1 + re\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(re + 1\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(re + 1\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(1 + re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(re \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      12. *-lowering-*.f6498.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    7. Applied egg-rr98.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \color{blue}{\left(\frac{1}{2} \cdot {re}^{2}\right)}\right), \mathsf{cos.f64}\left(im\right)\right) \]
    9. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(\frac{1}{2} \cdot \left(re \cdot re\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(\left(\frac{1}{2} \cdot re\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(re \cdot \left(\frac{1}{2} \cdot re\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \left(\frac{1}{2} \cdot re\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \left(re \cdot \frac{1}{2}\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-lowering-*.f6497.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    10. Simplified97.8%

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

    if 0.0054999999999999997 < re < 1.8999999999999999e154

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6490.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified90.0%

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

    if 1.8999999999999999e154 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -54:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;re \leq 0.0055:\\ \;\;\;\;\cos im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\ \mathbf{elif}\;re \leq 1.9 \cdot 10^{+154}:\\ \;\;\;\;e^{re} \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 96.6% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;re \leq 0.0054:\\
\;\;\;\;t\_0\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

    if -54 < re < 0.0054000000000000003 or 1.8999999999999999e154 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. *-lowering-*.f6498.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified98.1%

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

    if 0.0054000000000000003 < re < 1.8999999999999999e154

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6490.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified90.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -54:\\ \;\;\;\;e^{re}\\ \mathbf{elif}\;re \leq 0.0054:\\ \;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \mathbf{elif}\;re \leq 1.9 \cdot 10^{+154}:\\ \;\;\;\;e^{re} \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 71.3% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

\mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\
\;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\

\mathbf{elif}\;re \leq -52:\\
\;\;\;\;\left(\left(re + 1\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if re < -1.35000000000000003e154

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f641.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified1.9%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f641.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified1.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6428.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified28.6%

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

    if -1.35000000000000003e154 < re < -2.0000000000000001e96

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f642.4%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified2.4%

      \[\leadsto \color{blue}{re + 1} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 1 + \color{blue}{re} \]
      2. flip-+N/A

        \[\leadsto \frac{1 \cdot 1 - re \cdot re}{\color{blue}{1 - re}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - re \cdot re}{1 - re} \]
      4. flip3--N/A

        \[\leadsto \frac{1 - re \cdot re}{\frac{{1}^{3} - {re}^{3}}{\color{blue}{1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)}}} \]
      5. associate-/r/N/A

        \[\leadsto \frac{1 - re \cdot re}{{1}^{3} - {re}^{3}} \cdot \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1 - re \cdot re}{{1}^{3} - {re}^{3}}\right), \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(1 - re \cdot re\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1 \cdot 1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \left(re \cdot re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1} \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left(1 - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left({re}^{3}\right)\right)\right), \left(1 \cdot \color{blue}{1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      12. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left(re \cdot \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 + \left(\color{blue}{re \cdot re} + 1 \cdot re\right)\right)\right) \]
      16. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot re + 1 \cdot re\right)}\right)\right) \]
      17. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\left(re + 1\right)}\right)\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \color{blue}{re}\right)\right)\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re\right)}\right)\right)\right) \]
      20. +-lowering-+.f6486.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{re}\right)\right)\right)\right) \]
    10. Applied egg-rr86.1%

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

    if -2.0000000000000001e96 < re < -52

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified2.2%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(1 \cdot re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      2. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. associate-+r+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(1 + re\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(re + 1\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(re + 1\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(1 + re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(re \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      12. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    7. Applied egg-rr2.2%

      \[\leadsto \color{blue}{\left(\left(1 + re\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    8. Step-by-step derivation
      1. /-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{\cos im}{\color{blue}{1}}\right)\right) \]
      2. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{1}{\color{blue}{\frac{1}{\cos im}}}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{1}{\cos im}\right)}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \color{blue}{\cos im}\right)\right)\right) \]
      5. cos-lowering-cos.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(im\right)\right)\right)\right) \]
    9. Applied egg-rr2.2%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{2}} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \color{blue}{\left(\frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \left({im}^{2} \cdot \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f6451.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    12. Simplified51.8%

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

    if -52 < re < 1.39999999999999994e-6

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im} \]
    4. Step-by-step derivation
      1. cos-lowering-cos.f6495.6%

        \[\leadsto \mathsf{cos.f64}\left(im\right) \]
    5. Simplified95.6%

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

    if 1.39999999999999994e-6 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6483.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified83.1%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      5. *-lowering-*.f6456.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    8. Simplified56.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\ \mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\ \;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\ \mathbf{elif}\;re \leq -52:\\ \;\;\;\;\left(\left(re + 1\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\ \mathbf{elif}\;re \leq 1.4 \cdot 10^{-6}:\\ \;\;\;\;\cos im\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(im \cdot im\right)\right) \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 93.0% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;re \leq 0.0029:\\
\;\;\;\;\frac{\cos im}{1 - re}\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

    if -54 < re < 0.0029

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6498.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified98.3%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \cos im \cdot \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)} \]
      2. flip3-+N/A

        \[\leadsto \cos im \cdot \frac{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}{\color{blue}{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}} \]
      3. clear-numN/A

        \[\leadsto \cos im \cdot \frac{1}{\color{blue}{\frac{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}}} \]
      4. un-div-invN/A

        \[\leadsto \frac{\cos im}{\color{blue}{\frac{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos im, \color{blue}{\left(\frac{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}\right)}\right) \]
      6. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \left(\frac{\color{blue}{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}}{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}\right)\right) \]
    7. Applied egg-rr98.2%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \color{blue}{\left(1 + -1 \cdot re\right)}\right) \]
    9. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \left(1 + \left(\mathsf{neg}\left(re\right)\right)\right)\right) \]
      2. unsub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \left(1 - \color{blue}{re}\right)\right) \]
      3. --lowering--.f6496.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(im\right), \mathsf{\_.f64}\left(1, \color{blue}{re}\right)\right) \]
    10. Simplified96.8%

      \[\leadsto \frac{\cos im}{\color{blue}{1 - re}} \]

    if 0.0029 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6484.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified84.2%

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

Alternative 11: 50.4% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(re + 1\right) \cdot \left(re + 1\right)\\ t_1 := re \cdot \left(re \cdot re\right)\\ t_2 := 0.5 + re \cdot 0.16666666666666666\\ t_3 := t\_2 \cdot \left(re \cdot re\right)\\ \mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\ \mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\ \;\;\;\;\frac{1 - re \cdot re}{1 - t\_1} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\ \mathbf{elif}\;re \leq -52:\\ \;\;\;\;\left(\left(re + 1\right) + re \cdot \left(re \cdot t\_2\right)\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\ \mathbf{elif}\;re \leq 3.6 \cdot 10^{+47}:\\ \;\;\;\;\left(\left(re + 1\right) \cdot t\_0 + \left(\left(re \cdot re\right) \cdot \left(re \cdot t\_1\right)\right) \cdot \left(t\_2 \cdot \left(t\_2 \cdot t\_2\right)\right)\right) \cdot \frac{1}{t\_0 + t\_3 \cdot \left(t\_3 + \left(-1 - re\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(im \cdot im\right)\right) \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (+ re 1.0) (+ re 1.0)))
        (t_1 (* re (* re re)))
        (t_2 (+ 0.5 (* re 0.16666666666666666)))
        (t_3 (* t_2 (* re re))))
   (if (<= re -1.35e+154)
     (* (+ re 1.0) (* im (* im -0.5)))
     (if (<= re -2e+96)
       (* (/ (- 1.0 (* re re)) (- 1.0 t_1)) (+ 1.0 (* re (+ re 1.0))))
       (if (<= re -52.0)
         (*
          (+ (+ re 1.0) (* re (* re t_2)))
          (/
           1.0
           (+
            1.0
            (*
             im
             (*
              im
              (+
               0.5
               (*
                (* im im)
                (+
                 0.20833333333333334
                 (* (* im im) 0.08472222222222223)))))))))
         (if (<= re 3.6e+47)
           (*
            (+
             (* (+ re 1.0) t_0)
             (* (* (* re re) (* re t_1)) (* t_2 (* t_2 t_2))))
            (/ 1.0 (+ t_0 (* t_3 (+ t_3 (- -1.0 re))))))
           (*
            (+ 1.0 (* -0.5 (* im im)))
            (+ 1.0 (* re (+ 1.0 (* re 0.5)))))))))))
double code(double re, double im) {
	double t_0 = (re + 1.0) * (re + 1.0);
	double t_1 = re * (re * re);
	double t_2 = 0.5 + (re * 0.16666666666666666);
	double t_3 = t_2 * (re * re);
	double tmp;
	if (re <= -1.35e+154) {
		tmp = (re + 1.0) * (im * (im * -0.5));
	} else if (re <= -2e+96) {
		tmp = ((1.0 - (re * re)) / (1.0 - t_1)) * (1.0 + (re * (re + 1.0)));
	} else if (re <= -52.0) {
		tmp = ((re + 1.0) + (re * (re * t_2))) * (1.0 / (1.0 + (im * (im * (0.5 + ((im * im) * (0.20833333333333334 + ((im * im) * 0.08472222222222223))))))));
	} else if (re <= 3.6e+47) {
		tmp = (((re + 1.0) * t_0) + (((re * re) * (re * t_1)) * (t_2 * (t_2 * t_2)))) * (1.0 / (t_0 + (t_3 * (t_3 + (-1.0 - re)))));
	} else {
		tmp = (1.0 + (-0.5 * (im * im))) * (1.0 + (re * (1.0 + (re * 0.5))));
	}
	return tmp;
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = (re + 1.0d0) * (re + 1.0d0)
    t_1 = re * (re * re)
    t_2 = 0.5d0 + (re * 0.16666666666666666d0)
    t_3 = t_2 * (re * re)
    if (re <= (-1.35d+154)) then
        tmp = (re + 1.0d0) * (im * (im * (-0.5d0)))
    else if (re <= (-2d+96)) then
        tmp = ((1.0d0 - (re * re)) / (1.0d0 - t_1)) * (1.0d0 + (re * (re + 1.0d0)))
    else if (re <= (-52.0d0)) then
        tmp = ((re + 1.0d0) + (re * (re * t_2))) * (1.0d0 / (1.0d0 + (im * (im * (0.5d0 + ((im * im) * (0.20833333333333334d0 + ((im * im) * 0.08472222222222223d0))))))))
    else if (re <= 3.6d+47) then
        tmp = (((re + 1.0d0) * t_0) + (((re * re) * (re * t_1)) * (t_2 * (t_2 * t_2)))) * (1.0d0 / (t_0 + (t_3 * (t_3 + ((-1.0d0) - re)))))
    else
        tmp = (1.0d0 + ((-0.5d0) * (im * im))) * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (re + 1.0) * (re + 1.0);
	double t_1 = re * (re * re);
	double t_2 = 0.5 + (re * 0.16666666666666666);
	double t_3 = t_2 * (re * re);
	double tmp;
	if (re <= -1.35e+154) {
		tmp = (re + 1.0) * (im * (im * -0.5));
	} else if (re <= -2e+96) {
		tmp = ((1.0 - (re * re)) / (1.0 - t_1)) * (1.0 + (re * (re + 1.0)));
	} else if (re <= -52.0) {
		tmp = ((re + 1.0) + (re * (re * t_2))) * (1.0 / (1.0 + (im * (im * (0.5 + ((im * im) * (0.20833333333333334 + ((im * im) * 0.08472222222222223))))))));
	} else if (re <= 3.6e+47) {
		tmp = (((re + 1.0) * t_0) + (((re * re) * (re * t_1)) * (t_2 * (t_2 * t_2)))) * (1.0 / (t_0 + (t_3 * (t_3 + (-1.0 - re)))));
	} else {
		tmp = (1.0 + (-0.5 * (im * im))) * (1.0 + (re * (1.0 + (re * 0.5))));
	}
	return tmp;
}
def code(re, im):
	t_0 = (re + 1.0) * (re + 1.0)
	t_1 = re * (re * re)
	t_2 = 0.5 + (re * 0.16666666666666666)
	t_3 = t_2 * (re * re)
	tmp = 0
	if re <= -1.35e+154:
		tmp = (re + 1.0) * (im * (im * -0.5))
	elif re <= -2e+96:
		tmp = ((1.0 - (re * re)) / (1.0 - t_1)) * (1.0 + (re * (re + 1.0)))
	elif re <= -52.0:
		tmp = ((re + 1.0) + (re * (re * t_2))) * (1.0 / (1.0 + (im * (im * (0.5 + ((im * im) * (0.20833333333333334 + ((im * im) * 0.08472222222222223))))))))
	elif re <= 3.6e+47:
		tmp = (((re + 1.0) * t_0) + (((re * re) * (re * t_1)) * (t_2 * (t_2 * t_2)))) * (1.0 / (t_0 + (t_3 * (t_3 + (-1.0 - re)))))
	else:
		tmp = (1.0 + (-0.5 * (im * im))) * (1.0 + (re * (1.0 + (re * 0.5))))
	return tmp
function code(re, im)
	t_0 = Float64(Float64(re + 1.0) * Float64(re + 1.0))
	t_1 = Float64(re * Float64(re * re))
	t_2 = Float64(0.5 + Float64(re * 0.16666666666666666))
	t_3 = Float64(t_2 * Float64(re * re))
	tmp = 0.0
	if (re <= -1.35e+154)
		tmp = Float64(Float64(re + 1.0) * Float64(im * Float64(im * -0.5)));
	elseif (re <= -2e+96)
		tmp = Float64(Float64(Float64(1.0 - Float64(re * re)) / Float64(1.0 - t_1)) * Float64(1.0 + Float64(re * Float64(re + 1.0))));
	elseif (re <= -52.0)
		tmp = Float64(Float64(Float64(re + 1.0) + Float64(re * Float64(re * t_2))) * Float64(1.0 / Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * Float64(0.20833333333333334 + Float64(Float64(im * im) * 0.08472222222222223)))))))));
	elseif (re <= 3.6e+47)
		tmp = Float64(Float64(Float64(Float64(re + 1.0) * t_0) + Float64(Float64(Float64(re * re) * Float64(re * t_1)) * Float64(t_2 * Float64(t_2 * t_2)))) * Float64(1.0 / Float64(t_0 + Float64(t_3 * Float64(t_3 + Float64(-1.0 - re))))));
	else
		tmp = Float64(Float64(1.0 + Float64(-0.5 * Float64(im * im))) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (re + 1.0) * (re + 1.0);
	t_1 = re * (re * re);
	t_2 = 0.5 + (re * 0.16666666666666666);
	t_3 = t_2 * (re * re);
	tmp = 0.0;
	if (re <= -1.35e+154)
		tmp = (re + 1.0) * (im * (im * -0.5));
	elseif (re <= -2e+96)
		tmp = ((1.0 - (re * re)) / (1.0 - t_1)) * (1.0 + (re * (re + 1.0)));
	elseif (re <= -52.0)
		tmp = ((re + 1.0) + (re * (re * t_2))) * (1.0 / (1.0 + (im * (im * (0.5 + ((im * im) * (0.20833333333333334 + ((im * im) * 0.08472222222222223))))))));
	elseif (re <= 3.6e+47)
		tmp = (((re + 1.0) * t_0) + (((re * re) * (re * t_1)) * (t_2 * (t_2 * t_2)))) * (1.0 / (t_0 + (t_3 * (t_3 + (-1.0 - re)))));
	else
		tmp = (1.0 + (-0.5 * (im * im))) * (1.0 + (re * (1.0 + (re * 0.5))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(re + 1.0), $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(re * N[(re * re), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(re * re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -1.35e+154], N[(N[(re + 1.0), $MachinePrecision] * N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, -2e+96], N[(N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(re * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, -52.0], N[(N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * N[(0.20833333333333334 + N[(N[(im * im), $MachinePrecision] * 0.08472222222222223), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.6e+47], N[(N[(N[(N[(re + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[(N[(re * re), $MachinePrecision] * N[(re * t$95$1), $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(t$95$0 + N[(t$95$3 * N[(t$95$3 + N[(-1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(re + 1\right) \cdot \left(re + 1\right)\\
t_1 := re \cdot \left(re \cdot re\right)\\
t_2 := 0.5 + re \cdot 0.16666666666666666\\
t_3 := t\_2 \cdot \left(re \cdot re\right)\\
\mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

\mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\
\;\;\;\;\frac{1 - re \cdot re}{1 - t\_1} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\

\mathbf{elif}\;re \leq -52:\\
\;\;\;\;\left(\left(re + 1\right) + re \cdot \left(re \cdot t\_2\right)\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\

\mathbf{elif}\;re \leq 3.6 \cdot 10^{+47}:\\
\;\;\;\;\left(\left(re + 1\right) \cdot t\_0 + \left(\left(re \cdot re\right) \cdot \left(re \cdot t\_1\right)\right) \cdot \left(t\_2 \cdot \left(t\_2 \cdot t\_2\right)\right)\right) \cdot \frac{1}{t\_0 + t\_3 \cdot \left(t\_3 + \left(-1 - re\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if re < -1.35000000000000003e154

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f641.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified1.9%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f641.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified1.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6428.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified28.6%

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

    if -1.35000000000000003e154 < re < -2.0000000000000001e96

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f642.4%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified2.4%

      \[\leadsto \color{blue}{re + 1} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 1 + \color{blue}{re} \]
      2. flip-+N/A

        \[\leadsto \frac{1 \cdot 1 - re \cdot re}{\color{blue}{1 - re}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - re \cdot re}{1 - re} \]
      4. flip3--N/A

        \[\leadsto \frac{1 - re \cdot re}{\frac{{1}^{3} - {re}^{3}}{\color{blue}{1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)}}} \]
      5. associate-/r/N/A

        \[\leadsto \frac{1 - re \cdot re}{{1}^{3} - {re}^{3}} \cdot \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1 - re \cdot re}{{1}^{3} - {re}^{3}}\right), \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(1 - re \cdot re\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1 \cdot 1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \left(re \cdot re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1} \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left(1 - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left({re}^{3}\right)\right)\right), \left(1 \cdot \color{blue}{1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      12. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left(re \cdot \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 + \left(\color{blue}{re \cdot re} + 1 \cdot re\right)\right)\right) \]
      16. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot re + 1 \cdot re\right)}\right)\right) \]
      17. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\left(re + 1\right)}\right)\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \color{blue}{re}\right)\right)\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re\right)}\right)\right)\right) \]
      20. +-lowering-+.f6486.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{re}\right)\right)\right)\right) \]
    10. Applied egg-rr86.1%

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

    if -2.0000000000000001e96 < re < -52

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified2.2%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(1 \cdot re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      2. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. associate-+r+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(1 + re\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(re + 1\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(re + 1\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(1 + re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(re \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      12. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    7. Applied egg-rr2.2%

      \[\leadsto \color{blue}{\left(\left(1 + re\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    8. Step-by-step derivation
      1. /-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{\cos im}{\color{blue}{1}}\right)\right) \]
      2. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{1}{\color{blue}{\frac{1}{\cos im}}}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{1}{\cos im}\right)}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \color{blue}{\cos im}\right)\right)\right) \]
      5. cos-lowering-cos.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(im\right)\right)\right)\right) \]
    9. Applied egg-rr2.2%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{2}} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \color{blue}{\left(\frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \left({im}^{2} \cdot \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f6451.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    12. Simplified51.8%

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

    if -52 < re < 3.60000000000000008e47

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6493.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified93.6%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6445.4%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified45.4%

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)} \]
    9. Applied egg-rr47.3%

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

    if 3.60000000000000008e47 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6483.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified83.3%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      5. *-lowering-*.f6463.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    8. Simplified63.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\ \mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\ \;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\ \mathbf{elif}\;re \leq -52:\\ \;\;\;\;\left(\left(re + 1\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\ \mathbf{elif}\;re \leq 3.6 \cdot 10^{+47}:\\ \;\;\;\;\left(\left(re + 1\right) \cdot \left(\left(re + 1\right) \cdot \left(re + 1\right)\right) + \left(\left(re \cdot re\right) \cdot \left(re \cdot \left(re \cdot \left(re \cdot re\right)\right)\right)\right) \cdot \left(\left(0.5 + re \cdot 0.16666666666666666\right) \cdot \left(\left(0.5 + re \cdot 0.16666666666666666\right) \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\right) \cdot \frac{1}{\left(re + 1\right) \cdot \left(re + 1\right) + \left(\left(0.5 + re \cdot 0.16666666666666666\right) \cdot \left(re \cdot re\right)\right) \cdot \left(\left(0.5 + re \cdot 0.16666666666666666\right) \cdot \left(re \cdot re\right) + \left(-1 - re\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(im \cdot im\right)\right) \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 50.5% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
t_0 := re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\\
t_1 := re \cdot \left(1 + t\_0\right)\\
\mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

\mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\
\;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\

\mathbf{elif}\;re \leq -52:\\
\;\;\;\;\left(\left(re + 1\right) + re \cdot t\_0\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\

\mathbf{elif}\;re \leq 4.2 \cdot 10^{+51}:\\
\;\;\;\;\frac{1 + t\_1 \cdot \left(t\_1 \cdot t\_1\right)}{1 + t\_1 \cdot \left(-1 + t\_1\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if re < -1.35000000000000003e154

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f641.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified1.9%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f641.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified1.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6428.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified28.6%

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

    if -1.35000000000000003e154 < re < -2.0000000000000001e96

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f642.4%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified2.4%

      \[\leadsto \color{blue}{re + 1} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 1 + \color{blue}{re} \]
      2. flip-+N/A

        \[\leadsto \frac{1 \cdot 1 - re \cdot re}{\color{blue}{1 - re}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - re \cdot re}{1 - re} \]
      4. flip3--N/A

        \[\leadsto \frac{1 - re \cdot re}{\frac{{1}^{3} - {re}^{3}}{\color{blue}{1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)}}} \]
      5. associate-/r/N/A

        \[\leadsto \frac{1 - re \cdot re}{{1}^{3} - {re}^{3}} \cdot \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1 - re \cdot re}{{1}^{3} - {re}^{3}}\right), \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(1 - re \cdot re\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1 \cdot 1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \left(re \cdot re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1} \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left(1 - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left({re}^{3}\right)\right)\right), \left(1 \cdot \color{blue}{1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      12. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left(re \cdot \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 + \left(\color{blue}{re \cdot re} + 1 \cdot re\right)\right)\right) \]
      16. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot re + 1 \cdot re\right)}\right)\right) \]
      17. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\left(re + 1\right)}\right)\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \color{blue}{re}\right)\right)\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re\right)}\right)\right)\right) \]
      20. +-lowering-+.f6486.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{re}\right)\right)\right)\right) \]
    10. Applied egg-rr86.1%

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

    if -2.0000000000000001e96 < re < -52

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified2.2%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(1 \cdot re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      2. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. associate-+r+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(1 + re\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(re + 1\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(re + 1\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(1 + re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(re \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      12. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    7. Applied egg-rr2.2%

      \[\leadsto \color{blue}{\left(\left(1 + re\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    8. Step-by-step derivation
      1. /-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{\cos im}{\color{blue}{1}}\right)\right) \]
      2. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{1}{\color{blue}{\frac{1}{\cos im}}}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{1}{\cos im}\right)}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \color{blue}{\cos im}\right)\right)\right) \]
      5. cos-lowering-cos.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(im\right)\right)\right)\right) \]
    9. Applied egg-rr2.2%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{2}} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \color{blue}{\left(\frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \left({im}^{2} \cdot \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f6451.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    12. Simplified51.8%

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

    if -52 < re < 4.2000000000000002e51

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6492.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified92.4%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6444.8%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified44.8%

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)} \]
    9. Step-by-step derivation
      1. flip3-+N/A

        \[\leadsto \frac{{1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}}{\color{blue}{1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left({1}^{3} + {\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}^{3}\right), \color{blue}{\left(1 \cdot 1 + \left(\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) - 1 \cdot \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)\right)}\right) \]
    10. Applied egg-rr47.4%

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

    if 4.2000000000000002e51 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6484.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified84.8%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      5. *-lowering-*.f6464.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    8. Simplified64.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\ \mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\ \;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\ \mathbf{elif}\;re \leq -52:\\ \;\;\;\;\left(\left(re + 1\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\ \mathbf{elif}\;re \leq 4.2 \cdot 10^{+51}:\\ \;\;\;\;\frac{1 + \left(re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \left(\left(re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \left(re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\right)}{1 + \left(re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \left(-1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(im \cdot im\right)\right) \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 50.7% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 + re \cdot 0.16666666666666666\\
t_1 := re \cdot t\_0\\
\mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

\mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\
\;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\

\mathbf{elif}\;re \leq -52:\\
\;\;\;\;\left(\left(re + 1\right) + re \cdot t\_1\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\

\mathbf{elif}\;re \leq 1.25 \cdot 10^{+68}:\\
\;\;\;\;1 + \frac{re \cdot \left(1 + t\_1 \cdot \left(re \cdot \left(t\_0 \cdot t\_1\right)\right)\right)}{1 + t\_1 \cdot \left(-1 + t\_1\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if re < -1.35000000000000003e154

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f641.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified1.9%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f641.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified1.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6428.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified28.6%

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

    if -1.35000000000000003e154 < re < -2.0000000000000001e96

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f642.4%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified2.4%

      \[\leadsto \color{blue}{re + 1} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 1 + \color{blue}{re} \]
      2. flip-+N/A

        \[\leadsto \frac{1 \cdot 1 - re \cdot re}{\color{blue}{1 - re}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - re \cdot re}{1 - re} \]
      4. flip3--N/A

        \[\leadsto \frac{1 - re \cdot re}{\frac{{1}^{3} - {re}^{3}}{\color{blue}{1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)}}} \]
      5. associate-/r/N/A

        \[\leadsto \frac{1 - re \cdot re}{{1}^{3} - {re}^{3}} \cdot \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1 - re \cdot re}{{1}^{3} - {re}^{3}}\right), \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(1 - re \cdot re\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1 \cdot 1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \left(re \cdot re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1} \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left(1 - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left({re}^{3}\right)\right)\right), \left(1 \cdot \color{blue}{1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      12. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left(re \cdot \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 + \left(\color{blue}{re \cdot re} + 1 \cdot re\right)\right)\right) \]
      16. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot re + 1 \cdot re\right)}\right)\right) \]
      17. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\left(re + 1\right)}\right)\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \color{blue}{re}\right)\right)\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re\right)}\right)\right)\right) \]
      20. +-lowering-+.f6486.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{re}\right)\right)\right)\right) \]
    10. Applied egg-rr86.1%

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

    if -2.0000000000000001e96 < re < -52

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified2.2%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(1 \cdot re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      2. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. associate-+r+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(1 + re\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(re + 1\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(re + 1\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(1 + re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(re \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      12. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    7. Applied egg-rr2.2%

      \[\leadsto \color{blue}{\left(\left(1 + re\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    8. Step-by-step derivation
      1. /-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{\cos im}{\color{blue}{1}}\right)\right) \]
      2. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{1}{\color{blue}{\frac{1}{\cos im}}}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{1}{\cos im}\right)}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \color{blue}{\cos im}\right)\right)\right) \]
      5. cos-lowering-cos.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(im\right)\right)\right)\right) \]
    9. Applied egg-rr2.2%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{2}} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \color{blue}{\left(\frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \left({im}^{2} \cdot \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f6451.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    12. Simplified51.8%

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

    if -52 < re < 1.2500000000000001e68

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6491.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified91.8%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6444.5%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified44.5%

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \color{blue}{re}\right)\right) \]
      2. flip3-+N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{{1}^{3} + {\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)}^{3}}{1 \cdot 1 + \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) - 1 \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)} \cdot re\right)\right) \]
      3. associate-*l/N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{\left({1}^{3} + {\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)}^{3}\right) \cdot re}{\color{blue}{1 \cdot 1 + \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) - 1 \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)}}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\left({1}^{3} + {\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)}^{3}\right) \cdot re\right), \color{blue}{\left(1 \cdot 1 + \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) - 1 \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right)}\right)\right) \]
    10. Applied egg-rr46.4%

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

    if 1.2500000000000001e68 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6484.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified84.4%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      5. *-lowering-*.f6465.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    8. Simplified65.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\ \mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\ \;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\ \mathbf{elif}\;re \leq -52:\\ \;\;\;\;\left(\left(re + 1\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\ \mathbf{elif}\;re \leq 1.25 \cdot 10^{+68}:\\ \;\;\;\;1 + \frac{re \cdot \left(1 + \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right) \cdot \left(re \cdot \left(\left(0.5 + re \cdot 0.16666666666666666\right) \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\right)\right)}{1 + \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right) \cdot \left(-1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(im \cdot im\right)\right) \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 53.8% accurate, 4.0× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 + re \cdot 0.16666666666666666\\
t_1 := re \cdot t\_0\\
\mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

\mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\
\;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\

\mathbf{elif}\;re \leq -52:\\
\;\;\;\;\left(\left(re + 1\right) + re \cdot t\_1\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\

\mathbf{elif}\;re \leq 2.6 \cdot 10^{+154}:\\
\;\;\;\;1 + \frac{re \cdot \left(1 - re \cdot \left(t\_0 \cdot t\_1\right)\right)}{1 - t\_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if re < -1.35000000000000003e154

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f641.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified1.9%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f641.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified1.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6428.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified28.6%

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

    if -1.35000000000000003e154 < re < -2.0000000000000001e96

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f642.4%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified2.4%

      \[\leadsto \color{blue}{re + 1} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 1 + \color{blue}{re} \]
      2. flip-+N/A

        \[\leadsto \frac{1 \cdot 1 - re \cdot re}{\color{blue}{1 - re}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - re \cdot re}{1 - re} \]
      4. flip3--N/A

        \[\leadsto \frac{1 - re \cdot re}{\frac{{1}^{3} - {re}^{3}}{\color{blue}{1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)}}} \]
      5. associate-/r/N/A

        \[\leadsto \frac{1 - re \cdot re}{{1}^{3} - {re}^{3}} \cdot \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1 - re \cdot re}{{1}^{3} - {re}^{3}}\right), \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(1 - re \cdot re\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1 \cdot 1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \left(re \cdot re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1} \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left(1 - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left({re}^{3}\right)\right)\right), \left(1 \cdot \color{blue}{1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      12. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left(re \cdot \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 + \left(\color{blue}{re \cdot re} + 1 \cdot re\right)\right)\right) \]
      16. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot re + 1 \cdot re\right)}\right)\right) \]
      17. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\left(re + 1\right)}\right)\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \color{blue}{re}\right)\right)\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re\right)}\right)\right)\right) \]
      20. +-lowering-+.f6486.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{re}\right)\right)\right)\right) \]
    10. Applied egg-rr86.1%

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

    if -2.0000000000000001e96 < re < -52

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified2.2%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(1 \cdot re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      2. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. associate-+r+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(1 + re\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(re + 1\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(re + 1\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(1 + re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(re \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      12. *-lowering-*.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    7. Applied egg-rr2.2%

      \[\leadsto \color{blue}{\left(\left(1 + re\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    8. Step-by-step derivation
      1. /-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{\cos im}{\color{blue}{1}}\right)\right) \]
      2. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{1}{\color{blue}{\frac{1}{\cos im}}}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{1}{\cos im}\right)}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \color{blue}{\cos im}\right)\right)\right) \]
      5. cos-lowering-cos.f642.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(im\right)\right)\right)\right) \]
    9. Applied egg-rr2.2%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{2}} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right)\right)\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({im}^{2} \cdot \left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{5}{24} + \frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{5}{24}} + \frac{61}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \color{blue}{\left(\frac{61}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \left({im}^{2} \cdot \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{61}{720}}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
      14. *-lowering-*.f6451.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{5}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{61}{720}\right)\right)\right)\right)\right)\right)\right)\right)\right) \]
    12. Simplified51.8%

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

    if -52 < re < 2.59999999999999989e154

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6489.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified89.4%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6443.8%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified43.8%

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \color{blue}{re}\right)\right) \]
      2. flip-+N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{1 \cdot 1 - \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)}{1 - re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)} \cdot re\right)\right) \]
      3. associate-*l/N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{\left(1 \cdot 1 - \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot re}{\color{blue}{1 - re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)}}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\left(1 \cdot 1 - \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot re\right), \color{blue}{\left(1 - re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)}\right)\right) \]
    10. Applied egg-rr46.0%

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

    if 2.59999999999999989e154 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6480.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified80.8%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      5. *-lowering-*.f6480.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    8. Simplified80.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\ \mathbf{elif}\;re \leq -2 \cdot 10^{+96}:\\ \;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\ \mathbf{elif}\;re \leq -52:\\ \;\;\;\;\left(\left(re + 1\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \frac{1}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.20833333333333334 + \left(im \cdot im\right) \cdot 0.08472222222222223\right)\right)\right)}\\ \mathbf{elif}\;re \leq 2.6 \cdot 10^{+154}:\\ \;\;\;\;1 + \frac{re \cdot \left(1 - re \cdot \left(\left(0.5 + re \cdot 0.16666666666666666\right) \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\right)}{1 - re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(im \cdot im\right)\right) \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 53.4% accurate, 4.0× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 + re \cdot 0.16666666666666666\\
t_1 := re \cdot t\_0\\
\mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

\mathbf{elif}\;re \leq -6 \cdot 10^{+94}:\\
\;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\

\mathbf{elif}\;re \leq -52:\\
\;\;\;\;\left(\left(re + 1\right) + re \cdot t\_1\right) \cdot \frac{1}{1 + \left(im \cdot im\right) \cdot \left(0.5 + im \cdot \left(im \cdot 0.20833333333333334\right)\right)}\\

\mathbf{elif}\;re \leq 2.6 \cdot 10^{+154}:\\
\;\;\;\;1 + \frac{re \cdot \left(1 - re \cdot \left(t\_0 \cdot t\_1\right)\right)}{1 - t\_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if re < -1.35000000000000003e154

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f641.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified1.9%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f641.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified1.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6428.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified28.6%

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

    if -1.35000000000000003e154 < re < -6.0000000000000001e94

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f64100.0%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f642.4%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified2.4%

      \[\leadsto \color{blue}{re + 1} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 1 + \color{blue}{re} \]
      2. flip-+N/A

        \[\leadsto \frac{1 \cdot 1 - re \cdot re}{\color{blue}{1 - re}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - re \cdot re}{1 - re} \]
      4. flip3--N/A

        \[\leadsto \frac{1 - re \cdot re}{\frac{{1}^{3} - {re}^{3}}{\color{blue}{1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)}}} \]
      5. associate-/r/N/A

        \[\leadsto \frac{1 - re \cdot re}{{1}^{3} - {re}^{3}} \cdot \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1 - re \cdot re}{{1}^{3} - {re}^{3}}\right), \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(1 - re \cdot re\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1 \cdot 1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \left(re \cdot re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1} \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left(1 - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left({re}^{3}\right)\right)\right), \left(1 \cdot \color{blue}{1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      12. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left(re \cdot \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 + \left(\color{blue}{re \cdot re} + 1 \cdot re\right)\right)\right) \]
      16. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot re + 1 \cdot re\right)}\right)\right) \]
      17. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\left(re + 1\right)}\right)\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \color{blue}{re}\right)\right)\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re\right)}\right)\right)\right) \]
      20. +-lowering-+.f6475.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{re}\right)\right)\right)\right) \]
    10. Applied egg-rr75.6%

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

    if -6.0000000000000001e94 < re < -52

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified2.3%

      \[\leadsto \color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    6. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(1 \cdot re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      2. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\left(1 + \left(re + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. associate-+r+N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(1 + re\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(re + 1\right) + \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(re + 1\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(1 + re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(\left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot re\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \left(re \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      12. *-lowering-*.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    7. Applied egg-rr2.3%

      \[\leadsto \color{blue}{\left(\left(1 + re\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)} \cdot \cos im \]
    8. Step-by-step derivation
      1. /-rgt-identityN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{\cos im}{\color{blue}{1}}\right)\right) \]
      2. clear-numN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \left(\frac{1}{\color{blue}{\frac{1}{\cos im}}}\right)\right) \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{1}{\cos im}\right)}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \color{blue}{\cos im}\right)\right)\right) \]
      5. cos-lowering-cos.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{cos.f64}\left(im\right)\right)\right)\right) \]
    9. Applied egg-rr2.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + \frac{5}{24} \cdot {im}^{2}\right)\right)}\right)\right) \]
    11. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} + \frac{5}{24} \cdot {im}^{2}\right)\right)}\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{1}{2} + \frac{5}{24} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{1}{2}} + \frac{5}{24} \cdot {im}^{2}\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{1}{2}} + \frac{5}{24} \cdot {im}^{2}\right)\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{5}{24} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \color{blue}{\frac{5}{24}}\right)\right)\right)\right)\right)\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(im \cdot im\right) \cdot \frac{5}{24}\right)\right)\right)\right)\right)\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \left(im \cdot \color{blue}{\left(im \cdot \frac{5}{24}\right)}\right)\right)\right)\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{5}{24}\right)}\right)\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f6442.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(1, re\right), \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right), \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{5}{24}}\right)\right)\right)\right)\right)\right)\right) \]
    12. Simplified42.0%

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

    if -52 < re < 2.59999999999999989e154

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6489.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified89.4%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6443.8%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified43.8%

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)} \]
    9. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\left(1 + re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \color{blue}{re}\right)\right) \]
      2. flip-+N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{1 \cdot 1 - \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)}{1 - re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)} \cdot re\right)\right) \]
      3. associate-*l/N/A

        \[\leadsto \mathsf{+.f64}\left(1, \left(\frac{\left(1 \cdot 1 - \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot re}{\color{blue}{1 - re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)}}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{/.f64}\left(\left(\left(1 \cdot 1 - \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right) \cdot \left(re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)\right) \cdot re\right), \color{blue}{\left(1 - re \cdot \left(\frac{1}{2} + re \cdot \frac{1}{6}\right)\right)}\right)\right) \]
    10. Applied egg-rr46.0%

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

    if 2.59999999999999989e154 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6480.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified80.8%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      5. *-lowering-*.f6480.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    8. Simplified80.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\ \mathbf{elif}\;re \leq -6 \cdot 10^{+94}:\\ \;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\ \mathbf{elif}\;re \leq -52:\\ \;\;\;\;\left(\left(re + 1\right) + re \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right) \cdot \frac{1}{1 + \left(im \cdot im\right) \cdot \left(0.5 + im \cdot \left(im \cdot 0.20833333333333334\right)\right)}\\ \mathbf{elif}\;re \leq 2.6 \cdot 10^{+154}:\\ \;\;\;\;1 + \frac{re \cdot \left(1 - re \cdot \left(\left(0.5 + re \cdot 0.16666666666666666\right) \cdot \left(re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\right)}{1 - re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(im \cdot im\right)\right) \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 46.9% accurate, 6.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

\mathbf{elif}\;re \leq 7.3 \cdot 10^{-7}:\\
\;\;\;\;\frac{1 - re \cdot re}{1 - re \cdot \left(re \cdot re\right)} \cdot \left(1 + re \cdot \left(re + 1\right)\right)\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f641.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified1.9%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f641.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified1.8%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6428.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified28.6%

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

    if -1.35000000000000003e154 < re < 7.3e-7

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6458.1%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified58.1%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f6438.2%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified38.2%

      \[\leadsto \color{blue}{re + 1} \]
    9. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 1 + \color{blue}{re} \]
      2. flip-+N/A

        \[\leadsto \frac{1 \cdot 1 - re \cdot re}{\color{blue}{1 - re}} \]
      3. metadata-evalN/A

        \[\leadsto \frac{1 - re \cdot re}{1 - re} \]
      4. flip3--N/A

        \[\leadsto \frac{1 - re \cdot re}{\frac{{1}^{3} - {re}^{3}}{\color{blue}{1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)}}} \]
      5. associate-/r/N/A

        \[\leadsto \frac{1 - re \cdot re}{{1}^{3} - {re}^{3}} \cdot \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1 - re \cdot re}{{1}^{3} - {re}^{3}}\right), \color{blue}{\left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(1 - re \cdot re\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1 \cdot 1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      8. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \left(re \cdot re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(\color{blue}{1} \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left({1}^{3} - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \left(1 - {re}^{3}\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left({re}^{3}\right)\right)\right), \left(1 \cdot \color{blue}{1} + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      12. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \left(re \cdot \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 \cdot 1 + \left(re \cdot re + 1 \cdot re\right)\right)\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \left(1 + \left(\color{blue}{re \cdot re} + 1 \cdot re\right)\right)\right) \]
      16. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot re + 1 \cdot re\right)}\right)\right) \]
      17. distribute-rgt-outN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\left(re + 1\right)}\right)\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \color{blue}{re}\right)\right)\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re\right)}\right)\right)\right) \]
      20. +-lowering-+.f6445.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, re\right)\right), \mathsf{\_.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{re}\right)\right)\right)\right) \]
    10. Applied egg-rr45.0%

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

    if 7.3e-7 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6483.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified83.1%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      5. *-lowering-*.f6456.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    8. Simplified56.8%

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

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

Alternative 17: 45.1% accurate, 7.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified2.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f642.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified2.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6422.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified22.4%

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

    if -6.5e20 < re < 900

    1. Initial program 99.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6496.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified96.7%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6446.9%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified46.9%

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

    if 900 < re

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re} + \frac{-1}{2} \cdot \left({im}^{2} \cdot e^{re}\right)} \]
    4. Step-by-step derivation
      1. *-lft-identityN/A

        \[\leadsto 1 \cdot e^{re} + \color{blue}{\frac{-1}{2}} \cdot \left({im}^{2} \cdot e^{re}\right) \]
      2. associate-*r*N/A

        \[\leadsto 1 \cdot e^{re} + \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{e^{re}} \]
      3. distribute-rgt-inN/A

        \[\leadsto e^{re} \cdot \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(e^{re}\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      5. exp-lowering-exp.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \left(\color{blue}{1} + \frac{-1}{2} \cdot {im}^{2}\right)\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      8. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      9. *-lowering-*.f6483.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(re\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    5. Simplified83.9%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + \frac{1}{2} \cdot re\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{2} \cdot re\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
      5. *-lowering-*.f6456.9%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \frac{1}{2}\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
    8. Simplified56.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\ \;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\ \mathbf{elif}\;re \leq 900:\\ \;\;\;\;1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + -0.5 \cdot \left(im \cdot im\right)\right) \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 45.8% accurate, 8.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(im \cdot -0.5\right)\\ \mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\ \;\;\;\;\left(re + 1\right) \cdot t\_0\\ \mathbf{elif}\;re \leq 400:\\ \;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\ \mathbf{elif}\;re \leq 1.8 \cdot 10^{+128}:\\ \;\;\;\;re \cdot \left(1 + t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;0.16666666666666666 \cdot \left(re \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* im (* im -0.5))))
   (if (<= re -6.5e+20)
     (* (+ re 1.0) t_0)
     (if (<= re 400.0)
       (+ 1.0 (* re (+ 1.0 (* re 0.5))))
       (if (<= re 1.8e+128)
         (* re (+ 1.0 t_0))
         (* 0.16666666666666666 (* re (* re re))))))))
double code(double re, double im) {
	double t_0 = im * (im * -0.5);
	double tmp;
	if (re <= -6.5e+20) {
		tmp = (re + 1.0) * t_0;
	} else if (re <= 400.0) {
		tmp = 1.0 + (re * (1.0 + (re * 0.5)));
	} else if (re <= 1.8e+128) {
		tmp = re * (1.0 + t_0);
	} else {
		tmp = 0.16666666666666666 * (re * (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 <= (-6.5d+20)) then
        tmp = (re + 1.0d0) * t_0
    else if (re <= 400.0d0) then
        tmp = 1.0d0 + (re * (1.0d0 + (re * 0.5d0)))
    else if (re <= 1.8d+128) then
        tmp = re * (1.0d0 + t_0)
    else
        tmp = 0.16666666666666666d0 * (re * (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 <= -6.5e+20) {
		tmp = (re + 1.0) * t_0;
	} else if (re <= 400.0) {
		tmp = 1.0 + (re * (1.0 + (re * 0.5)));
	} else if (re <= 1.8e+128) {
		tmp = re * (1.0 + t_0);
	} else {
		tmp = 0.16666666666666666 * (re * (re * re));
	}
	return tmp;
}
def code(re, im):
	t_0 = im * (im * -0.5)
	tmp = 0
	if re <= -6.5e+20:
		tmp = (re + 1.0) * t_0
	elif re <= 400.0:
		tmp = 1.0 + (re * (1.0 + (re * 0.5)))
	elif re <= 1.8e+128:
		tmp = re * (1.0 + t_0)
	else:
		tmp = 0.16666666666666666 * (re * (re * re))
	return tmp
function code(re, im)
	t_0 = Float64(im * Float64(im * -0.5))
	tmp = 0.0
	if (re <= -6.5e+20)
		tmp = Float64(Float64(re + 1.0) * t_0);
	elseif (re <= 400.0)
		tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))));
	elseif (re <= 1.8e+128)
		tmp = Float64(re * Float64(1.0 + t_0));
	else
		tmp = Float64(0.16666666666666666 * Float64(re * Float64(re * re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = im * (im * -0.5);
	tmp = 0.0;
	if (re <= -6.5e+20)
		tmp = (re + 1.0) * t_0;
	elseif (re <= 400.0)
		tmp = 1.0 + (re * (1.0 + (re * 0.5)));
	elseif (re <= 1.8e+128)
		tmp = re * (1.0 + t_0);
	else
		tmp = 0.16666666666666666 * (re * (re * re));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -6.5e+20], N[(N[(re + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[re, 400.0], N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.8e+128], N[(re * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[(re * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := im \cdot \left(im \cdot -0.5\right)\\
\mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;\left(re + 1\right) \cdot t\_0\\

\mathbf{elif}\;re \leq 400:\\
\;\;\;\;1 + re \cdot \left(1 + re \cdot 0.5\right)\\

\mathbf{elif}\;re \leq 1.8 \cdot 10^{+128}:\\
\;\;\;\;re \cdot \left(1 + t\_0\right)\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified2.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f642.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified2.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6422.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified22.4%

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

    if -6.5e20 < re < 400

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6448.4%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified48.4%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + \frac{1}{2} \cdot re\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + \frac{1}{2} \cdot re\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + \frac{1}{2} \cdot re\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{2} \cdot re\right)}\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
      5. *-lowering-*.f6446.8%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{2}}\right)\right)\right)\right) \]
    8. Simplified46.8%

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

    if 400 < re < 1.80000000000000014e128

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f643.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified3.7%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f6431.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified31.7%

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

      \[\leadsto \color{blue}{re \cdot \left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(re, \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right)\right) \]
      7. *-lowering-*.f6431.7%

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right) \]
    11. Simplified31.7%

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

    if 1.80000000000000014e128 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified75.0%

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

      \[\leadsto \color{blue}{\frac{1}{6} \cdot {re}^{3}} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \color{blue}{\left({re}^{3}\right)}\right) \]
      2. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot \color{blue}{\left(re \cdot re\right)}\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot {re}^{\color{blue}{2}}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \color{blue}{\left({re}^{2}\right)}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \left(re \cdot \color{blue}{re}\right)\right)\right) \]
      6. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right) \]
    11. Simplified75.0%

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

Alternative 19: 45.7% accurate, 8.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(im \cdot -0.5\right)\\ \mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\ \;\;\;\;\left(re + 1\right) \cdot t\_0\\ \mathbf{elif}\;re \leq 330:\\ \;\;\;\;re + 1\\ \mathbf{elif}\;re \leq 1.8 \cdot 10^{+128}:\\ \;\;\;\;re \cdot \left(1 + t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;0.16666666666666666 \cdot \left(re \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* im (* im -0.5))))
   (if (<= re -6.5e+20)
     (* (+ re 1.0) t_0)
     (if (<= re 330.0)
       (+ re 1.0)
       (if (<= re 1.8e+128)
         (* re (+ 1.0 t_0))
         (* 0.16666666666666666 (* re (* re re))))))))
double code(double re, double im) {
	double t_0 = im * (im * -0.5);
	double tmp;
	if (re <= -6.5e+20) {
		tmp = (re + 1.0) * t_0;
	} else if (re <= 330.0) {
		tmp = re + 1.0;
	} else if (re <= 1.8e+128) {
		tmp = re * (1.0 + t_0);
	} else {
		tmp = 0.16666666666666666 * (re * (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 <= (-6.5d+20)) then
        tmp = (re + 1.0d0) * t_0
    else if (re <= 330.0d0) then
        tmp = re + 1.0d0
    else if (re <= 1.8d+128) then
        tmp = re * (1.0d0 + t_0)
    else
        tmp = 0.16666666666666666d0 * (re * (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 <= -6.5e+20) {
		tmp = (re + 1.0) * t_0;
	} else if (re <= 330.0) {
		tmp = re + 1.0;
	} else if (re <= 1.8e+128) {
		tmp = re * (1.0 + t_0);
	} else {
		tmp = 0.16666666666666666 * (re * (re * re));
	}
	return tmp;
}
def code(re, im):
	t_0 = im * (im * -0.5)
	tmp = 0
	if re <= -6.5e+20:
		tmp = (re + 1.0) * t_0
	elif re <= 330.0:
		tmp = re + 1.0
	elif re <= 1.8e+128:
		tmp = re * (1.0 + t_0)
	else:
		tmp = 0.16666666666666666 * (re * (re * re))
	return tmp
function code(re, im)
	t_0 = Float64(im * Float64(im * -0.5))
	tmp = 0.0
	if (re <= -6.5e+20)
		tmp = Float64(Float64(re + 1.0) * t_0);
	elseif (re <= 330.0)
		tmp = Float64(re + 1.0);
	elseif (re <= 1.8e+128)
		tmp = Float64(re * Float64(1.0 + t_0));
	else
		tmp = Float64(0.16666666666666666 * Float64(re * Float64(re * re)));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = im * (im * -0.5);
	tmp = 0.0;
	if (re <= -6.5e+20)
		tmp = (re + 1.0) * t_0;
	elseif (re <= 330.0)
		tmp = re + 1.0;
	elseif (re <= 1.8e+128)
		tmp = re * (1.0 + t_0);
	else
		tmp = 0.16666666666666666 * (re * (re * re));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -6.5e+20], N[(N[(re + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[re, 330.0], N[(re + 1.0), $MachinePrecision], If[LessEqual[re, 1.8e+128], N[(re * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.16666666666666666 * N[(re * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := im \cdot \left(im \cdot -0.5\right)\\
\mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;\left(re + 1\right) \cdot t\_0\\

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

\mathbf{elif}\;re \leq 1.8 \cdot 10^{+128}:\\
\;\;\;\;re \cdot \left(1 + t\_0\right)\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified2.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f642.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified2.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6422.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified22.4%

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

    if -6.5e20 < re < 330

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6448.4%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified48.4%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f6446.5%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified46.5%

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

    if 330 < re < 1.80000000000000014e128

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f643.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified3.7%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f6431.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified31.7%

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

      \[\leadsto \color{blue}{re \cdot \left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(re, \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right)\right) \]
      7. *-lowering-*.f6431.7%

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right) \]
    11. Simplified31.7%

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

    if 1.80000000000000014e128 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified75.0%

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

      \[\leadsto \color{blue}{\frac{1}{6} \cdot {re}^{3}} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \color{blue}{\left({re}^{3}\right)}\right) \]
      2. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot \color{blue}{\left(re \cdot re\right)}\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot {re}^{\color{blue}{2}}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \color{blue}{\left({re}^{2}\right)}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \left(re \cdot \color{blue}{re}\right)\right)\right) \]
      6. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right) \]
    11. Simplified75.0%

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

Alternative 20: 43.0% accurate, 8.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;im \cdot \left(im \cdot \left(-0.5 + re \cdot -0.5\right)\right)\\

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified2.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f642.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified2.0%

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \left({im}^{2} \cdot \left(1 + re\right)\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{\left(1 + re\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left({im}^{2} \cdot \frac{-1}{2}\right) \cdot \left(\color{blue}{1} + re\right) \]
      3. associate-*r*N/A

        \[\leadsto {im}^{2} \cdot \color{blue}{\left(\frac{-1}{2} \cdot \left(1 + re\right)\right)} \]
      4. unpow2N/A

        \[\leadsto \left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2}} \cdot \left(1 + re\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2} \cdot \left(1 + re\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2} \cdot \left(1 + re\right)\right)\right)}\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2} \cdot \left(1 + re\right)\right)}\right)\right) \]
      8. distribute-lft-inN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2} \cdot 1 + \color{blue}{\frac{-1}{2} \cdot re}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2} + \color{blue}{\frac{-1}{2}} \cdot re\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{2}, \color{blue}{\left(\frac{-1}{2} \cdot re\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{2}, \left(re \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right) \]
      12. *-lowering-*.f6411.2%

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right) \]
    11. Simplified11.2%

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

    if -6.5e20 < re < 55

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6448.4%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified48.4%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f6446.5%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified46.5%

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

    if 55 < re < 1.80000000000000014e128

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f643.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified3.7%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f6431.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified31.7%

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

      \[\leadsto \color{blue}{re \cdot \left(1 + \frac{-1}{2} \cdot {im}^{2}\right)} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(re, \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right)\right) \]
      7. *-lowering-*.f6431.7%

        \[\leadsto \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right) \]
    11. Simplified31.7%

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

    if 1.80000000000000014e128 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified75.0%

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

      \[\leadsto \color{blue}{\frac{1}{6} \cdot {re}^{3}} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \color{blue}{\left({re}^{3}\right)}\right) \]
      2. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot \color{blue}{\left(re \cdot re\right)}\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot {re}^{\color{blue}{2}}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \color{blue}{\left({re}^{2}\right)}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \left(re \cdot \color{blue}{re}\right)\right)\right) \]
      6. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right) \]
    11. Simplified75.0%

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

Alternative 21: 42.7% accurate, 9.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;im \cdot \left(im \cdot \left(-0.5 + re \cdot -0.5\right)\right)\\

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified2.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f642.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified2.0%

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \left({im}^{2} \cdot \left(1 + re\right)\right)} \]
    10. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{2} \cdot {im}^{2}\right) \cdot \color{blue}{\left(1 + re\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left({im}^{2} \cdot \frac{-1}{2}\right) \cdot \left(\color{blue}{1} + re\right) \]
      3. associate-*r*N/A

        \[\leadsto {im}^{2} \cdot \color{blue}{\left(\frac{-1}{2} \cdot \left(1 + re\right)\right)} \]
      4. unpow2N/A

        \[\leadsto \left(im \cdot im\right) \cdot \left(\color{blue}{\frac{-1}{2}} \cdot \left(1 + re\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto im \cdot \color{blue}{\left(im \cdot \left(\frac{-1}{2} \cdot \left(1 + re\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{-1}{2} \cdot \left(1 + re\right)\right)\right)}\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{-1}{2} \cdot \left(1 + re\right)\right)}\right)\right) \]
      8. distribute-lft-inN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2} \cdot 1 + \color{blue}{\frac{-1}{2} \cdot re}\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{-1}{2} + \color{blue}{\frac{-1}{2}} \cdot re\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{2}, \color{blue}{\left(\frac{-1}{2} \cdot re\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{2}, \left(re \cdot \color{blue}{\frac{-1}{2}}\right)\right)\right)\right) \]
      12. *-lowering-*.f6411.2%

        \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{-1}{2}}\right)\right)\right)\right) \]
    11. Simplified11.2%

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

    if -6.5e20 < re < 900

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6448.4%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified48.4%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f6446.5%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified46.5%

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

    if 900 < re < 1.80000000000000014e128

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im} \]
    4. Step-by-step derivation
      1. cos-lowering-cos.f643.1%

        \[\leadsto \mathsf{cos.f64}\left(im\right) \]
    5. Simplified3.1%

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

      \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot {im}^{2}} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
      4. *-lowering-*.f6431.3%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
    8. Simplified31.3%

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

    if 1.80000000000000014e128 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified75.0%

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

      \[\leadsto \color{blue}{\frac{1}{6} \cdot {re}^{3}} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \color{blue}{\left({re}^{3}\right)}\right) \]
      2. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot \color{blue}{\left(re \cdot re\right)}\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot {re}^{\color{blue}{2}}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \color{blue}{\left({re}^{2}\right)}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \left(re \cdot \color{blue}{re}\right)\right)\right) \]
      6. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right) \]
    11. Simplified75.0%

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

Alternative 22: 46.4% accurate, 11.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified2.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f642.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified2.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6422.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified22.4%

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

    if -6.5e20 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6489.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified89.5%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6447.1%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified47.1%

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

Alternative 23: 39.9% accurate, 11.9× speedup?

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

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6463.6%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified63.6%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f6433.5%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified33.5%

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

    if 6600 < re < 1.80000000000000014e128

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\cos im} \]
    4. Step-by-step derivation
      1. cos-lowering-cos.f643.1%

        \[\leadsto \mathsf{cos.f64}\left(im\right) \]
    5. Simplified3.1%

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

      \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot {im}^{2}} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
      4. *-lowering-*.f6431.3%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
    8. Simplified31.3%

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

    if 1.80000000000000014e128 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified75.0%

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

      \[\leadsto \color{blue}{\frac{1}{6} \cdot {re}^{3}} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \color{blue}{\left({re}^{3}\right)}\right) \]
      2. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot \color{blue}{\left(re \cdot re\right)}\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot {re}^{\color{blue}{2}}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \color{blue}{\left({re}^{2}\right)}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \left(re \cdot \color{blue}{re}\right)\right)\right) \]
      6. *-lowering-*.f6475.0%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right) \]
    11. Simplified75.0%

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

Alternative 24: 46.2% accurate, 12.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;re \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;\left(re + 1\right) \cdot \left(im \cdot \left(im \cdot -0.5\right)\right)\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(re + 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. +-lowering-+.f642.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
    5. Simplified2.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(1 + \frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right)\right) \]
      4. *-lowering-*.f642.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right)\right) \]
    8. Simplified2.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \color{blue}{\left(\frac{-1}{2} \cdot {im}^{2}\right)}\right) \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left({im}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(\left(im \cdot im\right) \cdot \frac{-1}{2}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \left(im \cdot \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{-1}{2}\right)}\right)\right) \]
      5. *-lowering-*.f6422.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(re, 1\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{-1}{2}}\right)\right)\right) \]
    11. Simplified22.4%

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

    if -6.5e20 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6489.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified89.5%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6447.1%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified47.1%

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

      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{6} \cdot {re}^{2}\right)}\right)\right)\right) \]
    10. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\frac{1}{6} \cdot \left(re \cdot \color{blue}{re}\right)\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(\left(\frac{1}{6} \cdot re\right) \cdot \color{blue}{re}\right)\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f6446.8%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right) \]
    11. Simplified46.8%

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

Alternative 25: 40.8% accurate, 16.9× speedup?

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

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

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{e^{re}} \]
    4. Step-by-step derivation
      1. exp-lowering-exp.f6463.3%

        \[\leadsto \mathsf{exp.f64}\left(re\right) \]
    5. Simplified63.3%

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

      \[\leadsto \color{blue}{1 + re} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto re + \color{blue}{1} \]
      2. +-lowering-+.f6433.3%

        \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
    8. Simplified33.3%

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

    if 4.2e11 < re

    1. Initial program 100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}, \mathsf{cos.f64}\left(im\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{im}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{6} \cdot re\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
      7. *-lowering-*.f6472.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \frac{1}{6}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(im\right)\right) \]
    5. Simplified72.4%

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

      \[\leadsto \color{blue}{1 + re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)} \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)\right)}\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(1 + re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \color{blue}{\left(re \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot re\right)\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot re\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{6} \cdot re\right)}\right)\right)\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
      7. *-lowering-*.f6448.4%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right) \]
    8. Simplified48.4%

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

      \[\leadsto \color{blue}{\frac{1}{6} \cdot {re}^{3}} \]
    10. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \color{blue}{\left({re}^{3}\right)}\right) \]
      2. cube-multN/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot \color{blue}{\left(re \cdot re\right)}\right)\right) \]
      3. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \left(re \cdot {re}^{\color{blue}{2}}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \color{blue}{\left({re}^{2}\right)}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \left(re \cdot \color{blue}{re}\right)\right)\right) \]
      6. *-lowering-*.f6448.4%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{6}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right) \]
    11. Simplified48.4%

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

Alternative 26: 28.8% accurate, 67.7× speedup?

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

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

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

    \[\leadsto \color{blue}{e^{re}} \]
  4. Step-by-step derivation
    1. exp-lowering-exp.f6464.6%

      \[\leadsto \mathsf{exp.f64}\left(re\right) \]
  5. Simplified64.6%

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

    \[\leadsto \color{blue}{1 + re} \]
  7. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto re + \color{blue}{1} \]
    2. +-lowering-+.f6426.9%

      \[\leadsto \mathsf{+.f64}\left(re, \color{blue}{1}\right) \]
  8. Simplified26.9%

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

Alternative 27: 28.4% accurate, 203.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\cos im} \]
  4. Step-by-step derivation
    1. cos-lowering-cos.f6452.3%

      \[\leadsto \mathsf{cos.f64}\left(im\right) \]
  5. Simplified52.3%

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

    \[\leadsto \color{blue}{1} \]
  7. Step-by-step derivation
    1. Simplified26.4%

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

    Reproduce

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