math.cos on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 12.4s
Alternatives: 18
Speedup: 1.0×

Specification

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

\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\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 18 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} \\ \left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \end{array} \]
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
	return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
	return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im):
	return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im)
	return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im)))
end
function tmp = code(re, im)
	tmp = (0.5 * cos(re)) * (exp(-im) + exp(im));
end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 96.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq 0.99995:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot \left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right) + 1\right)\right)\right)\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 94.1%

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

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

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

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{\left(im \cdot im\right)} \cdot 0.002777777777777778\right)\right)\right) \]
      5. associate-*l*94.1%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{im \cdot \left(im \cdot 0.002777777777777778\right)}\right)\right)\right) \]
    5. Simplified94.1%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*l*94.1%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot \left(im \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right) + 1\right)}\right)\right) \]
      3. associate-*l*94.1%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot \left(im \cdot \left(im \cdot \left(im \cdot \color{blue}{\left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)}\right) + 1\right)\right)\right) \]
    7. Applied egg-rr94.1%

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

    if 0.999950000000000006 < (cos.f64 re)

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 99.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cos re \leq 0.99995:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot \left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right) + 1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 95.0% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
\mathbf{if}\;im \leq 6.5:\\
\;\;\;\;t\_0 \cdot \left(2 + im \cdot \left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right) + 1\right)\right)\right)\\

\mathbf{elif}\;im \leq 2.4 \cdot 10^{+51}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\right)\\


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 97.8%

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

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

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

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{\left(im \cdot im\right)} \cdot 0.002777777777777778\right)\right)\right) \]
      5. associate-*l*97.8%

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{im \cdot \left(im \cdot 0.002777777777777778\right)}\right)\right)\right) \]
    5. Simplified97.8%

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*l*97.8%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot \left(im \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right) + 1\right)}\right)\right) \]
      3. associate-*l*97.8%

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

        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot \left(im \cdot \left(im \cdot \left(im \cdot \color{blue}{\left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)}\right) + 1\right)\right)\right) \]
    7. Applied egg-rr97.8%

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

    if 6.5 < im < 2.3999999999999999e51

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

        \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      6. associate-*r*66.7%

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(1 + e^{im}\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in77.0%

        \[\leadsto \color{blue}{0.5 \cdot 1 + 0.5 \cdot e^{im}} \]
      2. metadata-eval77.0%

        \[\leadsto \color{blue}{0.5} + 0.5 \cdot e^{im} \]
    9. Simplified77.0%

      \[\leadsto \color{blue}{0.5 + 0.5 \cdot e^{im}} \]

    if 2.3999999999999999e51 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)\right)} \]
    6. Taylor expanded in im around inf 100.0%

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

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

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

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

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

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

Alternative 4: 93.1% accurate, 2.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.4:\\
\;\;\;\;\cos re \cdot \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)\right)\right)\\

\mathbf{elif}\;im \leq 2.4 \cdot 10^{+51}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.4000000000000004 < im < 2.3999999999999999e51

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

        \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      6. associate-*r*66.7%

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(1 + e^{im}\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in77.0%

        \[\leadsto \color{blue}{0.5 \cdot 1 + 0.5 \cdot e^{im}} \]
      2. metadata-eval77.0%

        \[\leadsto \color{blue}{0.5} + 0.5 \cdot e^{im} \]
    9. Simplified77.0%

      \[\leadsto \color{blue}{0.5 + 0.5 \cdot e^{im}} \]

    if 2.3999999999999999e51 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)\right)} \]
    6. Taylor expanded in im around inf 100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.4:\\ \;\;\;\;\cos re \cdot \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+51}:\\ \;\;\;\;0.5 + 0.5 \cdot e^{im}\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 92.7% accurate, 2.5× speedup?

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

\\
\begin{array}{l}
t_0 := im \cdot \left(im \cdot 0.041666666666666664\right)\\
\mathbf{if}\;im \leq 3.6:\\
\;\;\;\;\cos re \cdot \left(1 + im \cdot \left(im \cdot \left(0.5 + t\_0\right)\right)\right)\\

\mathbf{elif}\;im \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.60000000000000009 < im < 2.6000000000000002e77

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

        \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      6. associate-*r*68.8%

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(1 + e^{im}\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in76.5%

        \[\leadsto \color{blue}{0.5 \cdot 1 + 0.5 \cdot e^{im}} \]
      2. metadata-eval76.5%

        \[\leadsto \color{blue}{0.5} + 0.5 \cdot e^{im} \]
    9. Simplified76.5%

      \[\leadsto \color{blue}{0.5 + 0.5 \cdot e^{im}} \]

    if 2.6000000000000002e77 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(im \cdot \color{blue}{\left(0.041666666666666664 \cdot {im}^{3}\right)} + 1\right) \]
    7. Step-by-step derivation
      1. cube-unmult100.0%

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

        \[\leadsto \cos re \cdot \left(im \cdot \color{blue}{\left(\left(im \cdot \left(im \cdot im\right)\right) \cdot 0.041666666666666664\right)} + 1\right) \]
      3. associate-*r*100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.6:\\ \;\;\;\;\cos re \cdot \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+77}:\\ \;\;\;\;0.5 + 0.5 \cdot e^{im}\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(1 + im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.041666666666666664\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 86.7% accurate, 2.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.8:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot im\right)\\

\mathbf{elif}\;im \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 86.1%

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

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

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

    if 3.7999999999999998 < im < 2.6000000000000002e77

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

        \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      6. associate-*r*68.8%

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(1 + e^{im}\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in76.5%

        \[\leadsto \color{blue}{0.5 \cdot 1 + 0.5 \cdot e^{im}} \]
      2. metadata-eval76.5%

        \[\leadsto \color{blue}{0.5} + 0.5 \cdot e^{im} \]
    9. Simplified76.5%

      \[\leadsto \color{blue}{0.5 + 0.5 \cdot e^{im}} \]

    if 2.6000000000000002e77 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos re \cdot \left(im \cdot \color{blue}{\left(0.041666666666666664 \cdot {im}^{3}\right)} + 1\right) \]
    7. Step-by-step derivation
      1. cube-unmult100.0%

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

        \[\leadsto \cos re \cdot \left(im \cdot \color{blue}{\left(\left(im \cdot \left(im \cdot im\right)\right) \cdot 0.041666666666666664\right)} + 1\right) \]
      3. associate-*r*100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.8:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 2.6 \cdot 10^{+77}:\\ \;\;\;\;0.5 + 0.5 \cdot e^{im}\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(1 + im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.041666666666666664\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 85.1% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.2 \lor \neg \left(im \leq 3.7 \cdot 10^{+151}\right):\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(2 + im \cdot im\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 4.20000000000000018 or 3.6999999999999997e151 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 88.0%

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

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

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

    if 4.20000000000000018 < im < 3.6999999999999997e151

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

        \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      6. associate-*r*66.7%

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(1 + e^{im}\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in78.6%

        \[\leadsto \color{blue}{0.5 \cdot 1 + 0.5 \cdot e^{im}} \]
      2. metadata-eval78.6%

        \[\leadsto \color{blue}{0.5} + 0.5 \cdot e^{im} \]
    9. Simplified78.6%

      \[\leadsto \color{blue}{0.5 + 0.5 \cdot e^{im}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.0%

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

Alternative 8: 69.3% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.82:\\
\;\;\;\;\cos re\\

\mathbf{elif}\;im \leq 1.95 \cdot 10^{+151}:\\
\;\;\;\;0.5 + 0.5 \cdot e^{im}\\

\mathbf{elif}\;im \leq 1.6 \cdot 10^{+227}:\\
\;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\

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


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

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 60.9%

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

    if 1.82000000000000006 < im < 1.94999999999999988e151

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

        \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      6. associate-*r*66.7%

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \left(1 + e^{im}\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in78.6%

        \[\leadsto \color{blue}{0.5 \cdot 1 + 0.5 \cdot e^{im}} \]
      2. metadata-eval78.6%

        \[\leadsto \color{blue}{0.5} + 0.5 \cdot e^{im} \]
    9. Simplified78.6%

      \[\leadsto \color{blue}{0.5 + 0.5 \cdot e^{im}} \]

    if 1.94999999999999988e151 < im < 1.59999999999999994e227

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 0.0%

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

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

        \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      3. exp-neg90.5%

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

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

        \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      6. associate-*r*90.5%

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

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

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

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

        \[\leadsto \left(2 + \color{blue}{im \cdot im}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
    8. Simplified90.5%

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

    if 1.59999999999999994e227 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 + \left(im \cdot im\right) \cdot \left(\color{blue}{im \cdot \left(im \cdot 0.041666666666666664\right)} + 0.5\right) \]
      6. associate-*r*82.4%

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

        \[\leadsto 1 + im \cdot \left(im \cdot \color{blue}{\left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)}\right) \]
      8. associate-*r*82.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.82:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 1.95 \cdot 10^{+151}:\\ \;\;\;\;0.5 + 0.5 \cdot e^{im}\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 68.4% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(im \cdot im\right) \cdot \left(im \cdot im\right)\\ t_1 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\ t_2 := im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\\ \mathbf{if}\;im \leq 64000000:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 3 \cdot 10^{+51}:\\ \;\;\;\;t\_1 \cdot \left(2 + \frac{t\_0 \cdot \left(1 - \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(t\_2 \cdot t\_2\right)\right)\right)}{\left(im \cdot im\right) \cdot \left(1 - \left(im \cdot im\right) \cdot t\_2\right)}\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot t\_0\right)\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* (* im im) (* im im)))
        (t_1 (+ 0.5 (* re (* re -0.25))))
        (t_2 (+ (* im (* im 0.002777777777777778)) 0.08333333333333333)))
   (if (<= im 64000000.0)
     (cos re)
     (if (<= im 3e+51)
       (*
        t_1
        (+
         2.0
         (/
          (* t_0 (- 1.0 (* (* im im) (* (* im im) (* t_2 t_2)))))
          (* (* im im) (- 1.0 (* (* im im) t_2))))))
       (if (<= im 3.7e+151)
         (* 0.5 (+ 2.0 (* 0.002777777777777778 (* (* im im) t_0))))
         (if (<= im 1.8e+227)
           (* (+ 2.0 (* im im)) t_1)
           (+
            1.0
            (* im (* im (+ 0.5 (* (* im im) 0.041666666666666664)))))))))))
double code(double re, double im) {
	double t_0 = (im * im) * (im * im);
	double t_1 = 0.5 + (re * (re * -0.25));
	double t_2 = (im * (im * 0.002777777777777778)) + 0.08333333333333333;
	double tmp;
	if (im <= 64000000.0) {
		tmp = cos(re);
	} else if (im <= 3e+51) {
		tmp = t_1 * (2.0 + ((t_0 * (1.0 - ((im * im) * ((im * im) * (t_2 * t_2))))) / ((im * im) * (1.0 - ((im * im) * t_2)))));
	} else if (im <= 3.7e+151) {
		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * t_0)));
	} else if (im <= 1.8e+227) {
		tmp = (2.0 + (im * im)) * t_1;
	} else {
		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
	}
	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) :: tmp
    t_0 = (im * im) * (im * im)
    t_1 = 0.5d0 + (re * (re * (-0.25d0)))
    t_2 = (im * (im * 0.002777777777777778d0)) + 0.08333333333333333d0
    if (im <= 64000000.0d0) then
        tmp = cos(re)
    else if (im <= 3d+51) then
        tmp = t_1 * (2.0d0 + ((t_0 * (1.0d0 - ((im * im) * ((im * im) * (t_2 * t_2))))) / ((im * im) * (1.0d0 - ((im * im) * t_2)))))
    else if (im <= 3.7d+151) then
        tmp = 0.5d0 * (2.0d0 + (0.002777777777777778d0 * ((im * im) * t_0)))
    else if (im <= 1.8d+227) then
        tmp = (2.0d0 + (im * im)) * t_1
    else
        tmp = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
    end if
    code = tmp
end function
public static double code(double re, double im) {
	double t_0 = (im * im) * (im * im);
	double t_1 = 0.5 + (re * (re * -0.25));
	double t_2 = (im * (im * 0.002777777777777778)) + 0.08333333333333333;
	double tmp;
	if (im <= 64000000.0) {
		tmp = Math.cos(re);
	} else if (im <= 3e+51) {
		tmp = t_1 * (2.0 + ((t_0 * (1.0 - ((im * im) * ((im * im) * (t_2 * t_2))))) / ((im * im) * (1.0 - ((im * im) * t_2)))));
	} else if (im <= 3.7e+151) {
		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * t_0)));
	} else if (im <= 1.8e+227) {
		tmp = (2.0 + (im * im)) * t_1;
	} else {
		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
	}
	return tmp;
}
def code(re, im):
	t_0 = (im * im) * (im * im)
	t_1 = 0.5 + (re * (re * -0.25))
	t_2 = (im * (im * 0.002777777777777778)) + 0.08333333333333333
	tmp = 0
	if im <= 64000000.0:
		tmp = math.cos(re)
	elif im <= 3e+51:
		tmp = t_1 * (2.0 + ((t_0 * (1.0 - ((im * im) * ((im * im) * (t_2 * t_2))))) / ((im * im) * (1.0 - ((im * im) * t_2)))))
	elif im <= 3.7e+151:
		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * t_0)))
	elif im <= 1.8e+227:
		tmp = (2.0 + (im * im)) * t_1
	else:
		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))))
	return tmp
function code(re, im)
	t_0 = Float64(Float64(im * im) * Float64(im * im))
	t_1 = Float64(0.5 + Float64(re * Float64(re * -0.25)))
	t_2 = Float64(Float64(im * Float64(im * 0.002777777777777778)) + 0.08333333333333333)
	tmp = 0.0
	if (im <= 64000000.0)
		tmp = cos(re);
	elseif (im <= 3e+51)
		tmp = Float64(t_1 * Float64(2.0 + Float64(Float64(t_0 * Float64(1.0 - Float64(Float64(im * im) * Float64(Float64(im * im) * Float64(t_2 * t_2))))) / Float64(Float64(im * im) * Float64(1.0 - Float64(Float64(im * im) * t_2))))));
	elseif (im <= 3.7e+151)
		tmp = Float64(0.5 * Float64(2.0 + Float64(0.002777777777777778 * Float64(Float64(im * im) * t_0))));
	elseif (im <= 1.8e+227)
		tmp = Float64(Float64(2.0 + Float64(im * im)) * t_1);
	else
		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664)))));
	end
	return tmp
end
function tmp_2 = code(re, im)
	t_0 = (im * im) * (im * im);
	t_1 = 0.5 + (re * (re * -0.25));
	t_2 = (im * (im * 0.002777777777777778)) + 0.08333333333333333;
	tmp = 0.0;
	if (im <= 64000000.0)
		tmp = cos(re);
	elseif (im <= 3e+51)
		tmp = t_1 * (2.0 + ((t_0 * (1.0 - ((im * im) * ((im * im) * (t_2 * t_2))))) / ((im * im) * (1.0 - ((im * im) * t_2)))));
	elseif (im <= 3.7e+151)
		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * t_0)));
	elseif (im <= 1.8e+227)
		tmp = (2.0 + (im * im)) * t_1;
	else
		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
	end
	tmp_2 = tmp;
end
code[re_, im_] := Block[{t$95$0 = N[(N[(im * im), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(im * N[(im * 0.002777777777777778), $MachinePrecision]), $MachinePrecision] + 0.08333333333333333), $MachinePrecision]}, If[LessEqual[im, 64000000.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 3e+51], N[(t$95$1 * N[(2.0 + N[(N[(t$95$0 * N[(1.0 - N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(im * im), $MachinePrecision] * N[(1.0 - N[(N[(im * im), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.7e+151], N[(0.5 * N[(2.0 + N[(0.002777777777777778 * N[(N[(im * im), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.8e+227], N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(im \cdot im\right) \cdot \left(im \cdot im\right)\\
t_1 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\
t_2 := im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\\
\mathbf{if}\;im \leq 64000000:\\
\;\;\;\;\cos re\\

\mathbf{elif}\;im \leq 3 \cdot 10^{+51}:\\
\;\;\;\;t\_1 \cdot \left(2 + \frac{t\_0 \cdot \left(1 - \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(t\_2 \cdot t\_2\right)\right)\right)}{\left(im \cdot im\right) \cdot \left(1 - \left(im \cdot im\right) \cdot t\_2\right)}\right)\\

\mathbf{elif}\;im \leq 3.7 \cdot 10^{+151}:\\
\;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot t\_0\right)\right)\\

\mathbf{elif}\;im \leq 1.8 \cdot 10^{+227}:\\
\;\;\;\;\left(2 + im \cdot im\right) \cdot t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if im < 6.4e7

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in im around 0 60.0%

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

    if 6.4e7 < im < 3e51

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0 0.0%

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

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

        \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
      3. exp-neg88.9%

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

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

        \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
      6. associate-*r*88.9%

        \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + \color{blue}{\left(-0.25 \cdot re\right) \cdot re}\right) \]
      7. *-commutative88.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(2 + \color{blue}{\left(1 \cdot \left(im \cdot im\right) + \left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)\right)}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
      2. *-un-lft-identity26.1%

        \[\leadsto \left(2 + \left(\color{blue}{im \cdot im} + \left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
      3. flip-+67.5%

        \[\leadsto \left(2 + \color{blue}{\frac{\left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(\left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)\right)}{im \cdot im - \left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)}}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
    10. Applied egg-rr67.5%

      \[\leadsto \left(2 + \color{blue}{\frac{\left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(\left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot im\right)\right) \cdot \left(\left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot im\right)\right)}{im \cdot im - \left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot im\right)}}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
    11. Step-by-step derivation
      1. Simplified67.5%

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

      if 3e51 < im < 3.6999999999999997e151

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

          \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
        6. associate-*r*66.7%

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

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

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

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

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

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

          \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + 0.002777777777777778 \cdot \color{blue}{\left(im \cdot im\right)}\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        4. *-commutative66.7%

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

          \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{im \cdot \left(im \cdot 0.002777777777777778\right)}\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
      8. Simplified66.7%

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

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

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

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

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

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \]
      11. Simplified66.7%

        \[\leadsto \left(2 + \color{blue}{0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
      12. Taylor expanded in re around 0 80.0%

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

          \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot {im}^{\color{blue}{\left(2 \cdot 3\right)}}\right) \]
        2. pow-sqr80.0%

          \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left({im}^{3} \cdot {im}^{3}\right)}\right) \]
        3. cube-prod80.0%

          \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{{\left(im \cdot im\right)}^{3}}\right) \]
        4. cube-mult80.0%

          \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \]
      14. Simplified80.0%

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

      if 3.6999999999999997e151 < im < 1.79999999999999996e227

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0 0.0%

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

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

          \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
        3. exp-neg90.5%

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

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

          \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
        6. associate-*r*90.5%

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

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

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

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

          \[\leadsto \left(2 + \color{blue}{im \cdot im}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
      8. Simplified90.5%

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

      if 1.79999999999999996e227 < im

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto 1 + \left(im \cdot im\right) \cdot \left(\color{blue}{im \cdot \left(im \cdot 0.041666666666666664\right)} + 0.5\right) \]
        6. associate-*r*82.4%

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

          \[\leadsto 1 + im \cdot \left(im \cdot \color{blue}{\left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)}\right) \]
        8. associate-*r*82.4%

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

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

        \[\leadsto \color{blue}{1 + im \cdot \left(im \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right)} \]
    12. Recombined 5 regimes into one program.
    13. Final simplification65.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 64000000:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 3 \cdot 10^{+51}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(2 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(1 - \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)\right)\right)}{\left(im \cdot im\right) \cdot \left(1 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)}\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \]
    14. Add Preprocessing

    Alternative 10: 59.2% accurate, 4.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\\ t_1 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\ t_2 := 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ t_3 := \left(im \cdot im\right) \cdot \left(im \cdot im\right)\\ \mathbf{if}\;im \leq 4800000000:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+51}:\\ \;\;\;\;t\_1 \cdot \left(2 + \frac{t\_3 \cdot \left(1 - \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(t\_0 \cdot t\_0\right)\right)\right)}{\left(im \cdot im\right) \cdot \left(1 - \left(im \cdot im\right) \cdot t\_0\right)}\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot t\_3\right)\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
    (FPCore (re im)
     :precision binary64
     (let* ((t_0 (+ (* im (* im 0.002777777777777778)) 0.08333333333333333))
            (t_1 (+ 0.5 (* re (* re -0.25))))
            (t_2 (+ 1.0 (* im (* im (+ 0.5 (* (* im im) 0.041666666666666664))))))
            (t_3 (* (* im im) (* im im))))
       (if (<= im 4800000000.0)
         t_2
         (if (<= im 2.4e+51)
           (*
            t_1
            (+
             2.0
             (/
              (* t_3 (- 1.0 (* (* im im) (* (* im im) (* t_0 t_0)))))
              (* (* im im) (- 1.0 (* (* im im) t_0))))))
           (if (<= im 3.7e+151)
             (* 0.5 (+ 2.0 (* 0.002777777777777778 (* (* im im) t_3))))
             (if (<= im 1.8e+227) (* (+ 2.0 (* im im)) t_1) t_2))))))
    double code(double re, double im) {
    	double t_0 = (im * (im * 0.002777777777777778)) + 0.08333333333333333;
    	double t_1 = 0.5 + (re * (re * -0.25));
    	double t_2 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
    	double t_3 = (im * im) * (im * im);
    	double tmp;
    	if (im <= 4800000000.0) {
    		tmp = t_2;
    	} else if (im <= 2.4e+51) {
    		tmp = t_1 * (2.0 + ((t_3 * (1.0 - ((im * im) * ((im * im) * (t_0 * t_0))))) / ((im * im) * (1.0 - ((im * im) * t_0)))));
    	} else if (im <= 3.7e+151) {
    		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * t_3)));
    	} else if (im <= 1.8e+227) {
    		tmp = (2.0 + (im * im)) * t_1;
    	} else {
    		tmp = t_2;
    	}
    	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 = (im * (im * 0.002777777777777778d0)) + 0.08333333333333333d0
        t_1 = 0.5d0 + (re * (re * (-0.25d0)))
        t_2 = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
        t_3 = (im * im) * (im * im)
        if (im <= 4800000000.0d0) then
            tmp = t_2
        else if (im <= 2.4d+51) then
            tmp = t_1 * (2.0d0 + ((t_3 * (1.0d0 - ((im * im) * ((im * im) * (t_0 * t_0))))) / ((im * im) * (1.0d0 - ((im * im) * t_0)))))
        else if (im <= 3.7d+151) then
            tmp = 0.5d0 * (2.0d0 + (0.002777777777777778d0 * ((im * im) * t_3)))
        else if (im <= 1.8d+227) then
            tmp = (2.0d0 + (im * im)) * t_1
        else
            tmp = t_2
        end if
        code = tmp
    end function
    
    public static double code(double re, double im) {
    	double t_0 = (im * (im * 0.002777777777777778)) + 0.08333333333333333;
    	double t_1 = 0.5 + (re * (re * -0.25));
    	double t_2 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
    	double t_3 = (im * im) * (im * im);
    	double tmp;
    	if (im <= 4800000000.0) {
    		tmp = t_2;
    	} else if (im <= 2.4e+51) {
    		tmp = t_1 * (2.0 + ((t_3 * (1.0 - ((im * im) * ((im * im) * (t_0 * t_0))))) / ((im * im) * (1.0 - ((im * im) * t_0)))));
    	} else if (im <= 3.7e+151) {
    		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * t_3)));
    	} else if (im <= 1.8e+227) {
    		tmp = (2.0 + (im * im)) * t_1;
    	} else {
    		tmp = t_2;
    	}
    	return tmp;
    }
    
    def code(re, im):
    	t_0 = (im * (im * 0.002777777777777778)) + 0.08333333333333333
    	t_1 = 0.5 + (re * (re * -0.25))
    	t_2 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))))
    	t_3 = (im * im) * (im * im)
    	tmp = 0
    	if im <= 4800000000.0:
    		tmp = t_2
    	elif im <= 2.4e+51:
    		tmp = t_1 * (2.0 + ((t_3 * (1.0 - ((im * im) * ((im * im) * (t_0 * t_0))))) / ((im * im) * (1.0 - ((im * im) * t_0)))))
    	elif im <= 3.7e+151:
    		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * t_3)))
    	elif im <= 1.8e+227:
    		tmp = (2.0 + (im * im)) * t_1
    	else:
    		tmp = t_2
    	return tmp
    
    function code(re, im)
    	t_0 = Float64(Float64(im * Float64(im * 0.002777777777777778)) + 0.08333333333333333)
    	t_1 = Float64(0.5 + Float64(re * Float64(re * -0.25)))
    	t_2 = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664)))))
    	t_3 = Float64(Float64(im * im) * Float64(im * im))
    	tmp = 0.0
    	if (im <= 4800000000.0)
    		tmp = t_2;
    	elseif (im <= 2.4e+51)
    		tmp = Float64(t_1 * Float64(2.0 + Float64(Float64(t_3 * Float64(1.0 - Float64(Float64(im * im) * Float64(Float64(im * im) * Float64(t_0 * t_0))))) / Float64(Float64(im * im) * Float64(1.0 - Float64(Float64(im * im) * t_0))))));
    	elseif (im <= 3.7e+151)
    		tmp = Float64(0.5 * Float64(2.0 + Float64(0.002777777777777778 * Float64(Float64(im * im) * t_3))));
    	elseif (im <= 1.8e+227)
    		tmp = Float64(Float64(2.0 + Float64(im * im)) * t_1);
    	else
    		tmp = t_2;
    	end
    	return tmp
    end
    
    function tmp_2 = code(re, im)
    	t_0 = (im * (im * 0.002777777777777778)) + 0.08333333333333333;
    	t_1 = 0.5 + (re * (re * -0.25));
    	t_2 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
    	t_3 = (im * im) * (im * im);
    	tmp = 0.0;
    	if (im <= 4800000000.0)
    		tmp = t_2;
    	elseif (im <= 2.4e+51)
    		tmp = t_1 * (2.0 + ((t_3 * (1.0 - ((im * im) * ((im * im) * (t_0 * t_0))))) / ((im * im) * (1.0 - ((im * im) * t_0)))));
    	elseif (im <= 3.7e+151)
    		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * t_3)));
    	elseif (im <= 1.8e+227)
    		tmp = (2.0 + (im * im)) * t_1;
    	else
    		tmp = t_2;
    	end
    	tmp_2 = tmp;
    end
    
    code[re_, im_] := Block[{t$95$0 = N[(N[(im * N[(im * 0.002777777777777778), $MachinePrecision]), $MachinePrecision] + 0.08333333333333333), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(im * im), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 4800000000.0], t$95$2, If[LessEqual[im, 2.4e+51], N[(t$95$1 * N[(2.0 + N[(N[(t$95$3 * N[(1.0 - N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(im * im), $MachinePrecision] * N[(1.0 - N[(N[(im * im), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.7e+151], N[(0.5 * N[(2.0 + N[(0.002777777777777778 * N[(N[(im * im), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.8e+227], N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], t$95$2]]]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\\
    t_1 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\
    t_2 := 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
    t_3 := \left(im \cdot im\right) \cdot \left(im \cdot im\right)\\
    \mathbf{if}\;im \leq 4800000000:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;im \leq 2.4 \cdot 10^{+51}:\\
    \;\;\;\;t\_1 \cdot \left(2 + \frac{t\_3 \cdot \left(1 - \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(t\_0 \cdot t\_0\right)\right)\right)}{\left(im \cdot im\right) \cdot \left(1 - \left(im \cdot im\right) \cdot t\_0\right)}\right)\\
    
    \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151}:\\
    \;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot t\_3\right)\right)\\
    
    \mathbf{elif}\;im \leq 1.8 \cdot 10^{+227}:\\
    \;\;\;\;\left(2 + im \cdot im\right) \cdot t\_1\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_2\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if im < 4.8e9 or 1.79999999999999996e227 < im

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in im around 0 94.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \cos re \cdot \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\left(im \cdot im\right) \cdot 0.041666666666666664} + 0.5\right) + 1\right) \]
      7. Applied egg-rr94.7%

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

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

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

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

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

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

          \[\leadsto 1 + \left(im \cdot im\right) \cdot \left(\color{blue}{im \cdot \left(im \cdot 0.041666666666666664\right)} + 0.5\right) \]
        6. associate-*r*60.2%

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

          \[\leadsto 1 + im \cdot \left(im \cdot \color{blue}{\left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)}\right) \]
        8. associate-*r*60.2%

          \[\leadsto 1 + im \cdot \left(im \cdot \left(0.5 + \color{blue}{\left(im \cdot im\right) \cdot 0.041666666666666664}\right)\right) \]
        9. *-commutative60.2%

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

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

      if 4.8e9 < im < 2.3999999999999999e51

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0 0.0%

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

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

          \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
        3. exp-neg88.9%

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

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

          \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
        6. associate-*r*88.9%

          \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + \color{blue}{\left(-0.25 \cdot re\right) \cdot re}\right) \]
        7. *-commutative88.9%

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(2 + \color{blue}{\left(1 \cdot \left(im \cdot im\right) + \left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)\right)}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        2. *-un-lft-identity26.1%

          \[\leadsto \left(2 + \left(\color{blue}{im \cdot im} + \left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        3. flip-+67.5%

          \[\leadsto \left(2 + \color{blue}{\frac{\left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(\left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)\right)}{im \cdot im - \left(\left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(im \cdot im\right)}}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
      10. Applied egg-rr67.5%

        \[\leadsto \left(2 + \color{blue}{\frac{\left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(\left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot im\right)\right) \cdot \left(\left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot im\right)\right)}{im \cdot im - \left(im \cdot \left(im \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot im\right)}}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
      11. Step-by-step derivation
        1. Simplified67.5%

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

        if 2.3999999999999999e51 < im < 3.6999999999999997e151

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*66.7%

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

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

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

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

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

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

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + 0.002777777777777778 \cdot \color{blue}{\left(im \cdot im\right)}\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          4. *-commutative66.7%

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

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{im \cdot \left(im \cdot 0.002777777777777778\right)}\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        8. Simplified66.7%

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

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

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

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

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

            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \]
        11. Simplified66.7%

          \[\leadsto \left(2 + \color{blue}{0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        12. Taylor expanded in re around 0 80.0%

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

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot {im}^{\color{blue}{\left(2 \cdot 3\right)}}\right) \]
          2. pow-sqr80.0%

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left({im}^{3} \cdot {im}^{3}\right)}\right) \]
          3. cube-prod80.0%

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{{\left(im \cdot im\right)}^{3}}\right) \]
          4. cube-mult80.0%

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \]
        14. Simplified80.0%

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

        if 3.6999999999999997e151 < im < 1.79999999999999996e227

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

            \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
          3. exp-neg90.5%

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*90.5%

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

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

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

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

            \[\leadsto \left(2 + \color{blue}{im \cdot im}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        8. Simplified90.5%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4800000000:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+51}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(2 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(1 - \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)\right)\right)}{\left(im \cdot im\right) \cdot \left(1 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right) + 0.08333333333333333\right)\right)}\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.8 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \]
      14. Add Preprocessing

      Alternative 11: 58.5% accurate, 5.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\ t_1 := 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ t_2 := \left(im \cdot im\right) \cdot \left(im \cdot im\right)\\ \mathbf{if}\;im \leq 112000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+77}:\\ \;\;\;\;t\_0 \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{t\_2 \cdot \left(0.006944444444444444 - t\_2 \cdot 7.71604938271605 \cdot 10^{-6}\right)}{\left(im \cdot im\right) \cdot \left(0.08333333333333333 - im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151} \lor \neg \left(im \leq 1.75 \cdot 10^{+227}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot t\_0\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (let* ((t_0 (+ 0.5 (* re (* re -0.25))))
              (t_1 (+ 1.0 (* im (* im (+ 0.5 (* (* im im) 0.041666666666666664))))))
              (t_2 (* (* im im) (* im im))))
         (if (<= im 112000000.0)
           t_1
           (if (<= im 5e+77)
             (*
              t_0
              (+
               2.0
               (*
                (* im im)
                (+
                 1.0
                 (/
                  (* t_2 (- 0.006944444444444444 (* t_2 7.71604938271605e-6)))
                  (*
                   (* im im)
                   (- 0.08333333333333333 (* im (* im 0.002777777777777778)))))))))
             (if (or (<= im 3.7e+151) (not (<= im 1.75e+227)))
               t_1
               (* (+ 2.0 (* im im)) t_0))))))
      double code(double re, double im) {
      	double t_0 = 0.5 + (re * (re * -0.25));
      	double t_1 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	double t_2 = (im * im) * (im * im);
      	double tmp;
      	if (im <= 112000000.0) {
      		tmp = t_1;
      	} else if (im <= 5e+77) {
      		tmp = t_0 * (2.0 + ((im * im) * (1.0 + ((t_2 * (0.006944444444444444 - (t_2 * 7.71604938271605e-6))) / ((im * im) * (0.08333333333333333 - (im * (im * 0.002777777777777778))))))));
      	} else if ((im <= 3.7e+151) || !(im <= 1.75e+227)) {
      		tmp = t_1;
      	} else {
      		tmp = (2.0 + (im * im)) * 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) :: t_1
          real(8) :: t_2
          real(8) :: tmp
          t_0 = 0.5d0 + (re * (re * (-0.25d0)))
          t_1 = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
          t_2 = (im * im) * (im * im)
          if (im <= 112000000.0d0) then
              tmp = t_1
          else if (im <= 5d+77) then
              tmp = t_0 * (2.0d0 + ((im * im) * (1.0d0 + ((t_2 * (0.006944444444444444d0 - (t_2 * 7.71604938271605d-6))) / ((im * im) * (0.08333333333333333d0 - (im * (im * 0.002777777777777778d0))))))))
          else if ((im <= 3.7d+151) .or. (.not. (im <= 1.75d+227))) then
              tmp = t_1
          else
              tmp = (2.0d0 + (im * im)) * t_0
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double t_0 = 0.5 + (re * (re * -0.25));
      	double t_1 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	double t_2 = (im * im) * (im * im);
      	double tmp;
      	if (im <= 112000000.0) {
      		tmp = t_1;
      	} else if (im <= 5e+77) {
      		tmp = t_0 * (2.0 + ((im * im) * (1.0 + ((t_2 * (0.006944444444444444 - (t_2 * 7.71604938271605e-6))) / ((im * im) * (0.08333333333333333 - (im * (im * 0.002777777777777778))))))));
      	} else if ((im <= 3.7e+151) || !(im <= 1.75e+227)) {
      		tmp = t_1;
      	} else {
      		tmp = (2.0 + (im * im)) * t_0;
      	}
      	return tmp;
      }
      
      def code(re, im):
      	t_0 = 0.5 + (re * (re * -0.25))
      	t_1 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))))
      	t_2 = (im * im) * (im * im)
      	tmp = 0
      	if im <= 112000000.0:
      		tmp = t_1
      	elif im <= 5e+77:
      		tmp = t_0 * (2.0 + ((im * im) * (1.0 + ((t_2 * (0.006944444444444444 - (t_2 * 7.71604938271605e-6))) / ((im * im) * (0.08333333333333333 - (im * (im * 0.002777777777777778))))))))
      	elif (im <= 3.7e+151) or not (im <= 1.75e+227):
      		tmp = t_1
      	else:
      		tmp = (2.0 + (im * im)) * t_0
      	return tmp
      
      function code(re, im)
      	t_0 = Float64(0.5 + Float64(re * Float64(re * -0.25)))
      	t_1 = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664)))))
      	t_2 = Float64(Float64(im * im) * Float64(im * im))
      	tmp = 0.0
      	if (im <= 112000000.0)
      		tmp = t_1;
      	elseif (im <= 5e+77)
      		tmp = Float64(t_0 * Float64(2.0 + Float64(Float64(im * im) * Float64(1.0 + Float64(Float64(t_2 * Float64(0.006944444444444444 - Float64(t_2 * 7.71604938271605e-6))) / Float64(Float64(im * im) * Float64(0.08333333333333333 - Float64(im * Float64(im * 0.002777777777777778)))))))));
      	elseif ((im <= 3.7e+151) || !(im <= 1.75e+227))
      		tmp = t_1;
      	else
      		tmp = Float64(Float64(2.0 + Float64(im * im)) * t_0);
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	t_0 = 0.5 + (re * (re * -0.25));
      	t_1 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	t_2 = (im * im) * (im * im);
      	tmp = 0.0;
      	if (im <= 112000000.0)
      		tmp = t_1;
      	elseif (im <= 5e+77)
      		tmp = t_0 * (2.0 + ((im * im) * (1.0 + ((t_2 * (0.006944444444444444 - (t_2 * 7.71604938271605e-6))) / ((im * im) * (0.08333333333333333 - (im * (im * 0.002777777777777778))))))));
      	elseif ((im <= 3.7e+151) || ~((im <= 1.75e+227)))
      		tmp = t_1;
      	else
      		tmp = (2.0 + (im * im)) * t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := Block[{t$95$0 = N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(im * im), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 112000000.0], t$95$1, If[LessEqual[im, 5e+77], N[(t$95$0 * N[(2.0 + N[(N[(im * im), $MachinePrecision] * N[(1.0 + N[(N[(t$95$2 * N[(0.006944444444444444 - N[(t$95$2 * 7.71604938271605e-6), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(im * im), $MachinePrecision] * N[(0.08333333333333333 - N[(im * N[(im * 0.002777777777777778), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 3.7e+151], N[Not[LessEqual[im, 1.75e+227]], $MachinePrecision]], t$95$1, N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := 0.5 + re \cdot \left(re \cdot -0.25\right)\\
      t_1 := 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
      t_2 := \left(im \cdot im\right) \cdot \left(im \cdot im\right)\\
      \mathbf{if}\;im \leq 112000000:\\
      \;\;\;\;t\_1\\
      
      \mathbf{elif}\;im \leq 5 \cdot 10^{+77}:\\
      \;\;\;\;t\_0 \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{t\_2 \cdot \left(0.006944444444444444 - t\_2 \cdot 7.71604938271605 \cdot 10^{-6}\right)}{\left(im \cdot im\right) \cdot \left(0.08333333333333333 - im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right)\\
      
      \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151} \lor \neg \left(im \leq 1.75 \cdot 10^{+227}\right):\\
      \;\;\;\;t\_1\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(2 + im \cdot im\right) \cdot t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if im < 1.12e8 or 5.00000000000000004e77 < im < 3.6999999999999997e151 or 1.75e227 < im

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in im around 0 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto 1 + \left(im \cdot im\right) \cdot \left(\color{blue}{im \cdot \left(im \cdot 0.041666666666666664\right)} + 0.5\right) \]
          6. associate-*r*61.3%

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

            \[\leadsto 1 + im \cdot \left(im \cdot \color{blue}{\left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)}\right) \]
          8. associate-*r*61.3%

            \[\leadsto 1 + im \cdot \left(im \cdot \left(0.5 + \color{blue}{\left(im \cdot im\right) \cdot 0.041666666666666664}\right)\right) \]
          9. *-commutative61.3%

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

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

        if 1.12e8 < im < 5.00000000000000004e77

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

            \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
          3. exp-neg84.6%

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*84.6%

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + \color{blue}{\left(-0.25 \cdot re\right) \cdot re}\right) \]
          7. *-commutative84.6%

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \color{blue}{\frac{\left(\left(im \cdot im\right) \cdot 0.08333333333333333\right) \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right) - \left(\left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        10. Applied egg-rr55.2%

          \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \color{blue}{\frac{\left(\left(im \cdot im\right) \cdot 0.08333333333333333\right) \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right) - \left(\left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        11. Step-by-step derivation
          1. swap-sqr55.2%

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\color{blue}{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.08333333333333333 \cdot 0.08333333333333333\right)} - \left(\left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          2. swap-sqr55.2%

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.08333333333333333 \cdot 0.08333333333333333\right) - \color{blue}{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(\left(im \cdot \left(im \cdot 0.002777777777777778\right)\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)}}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          3. distribute-lft-out--55.2%

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\color{blue}{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.08333333333333333 \cdot 0.08333333333333333 - \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)}}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          4. metadata-eval55.2%

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(\color{blue}{0.006944444444444444} - \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          5. associate-*r*55.2%

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.006944444444444444 - \color{blue}{\left(\left(im \cdot im\right) \cdot 0.002777777777777778\right)} \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          6. associate-*r*55.2%

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.006944444444444444 - \left(\left(im \cdot im\right) \cdot 0.002777777777777778\right) \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot 0.002777777777777778\right)}\right)}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          7. swap-sqr55.2%

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.006944444444444444 - \color{blue}{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.002777777777777778 \cdot 0.002777777777777778\right)}\right)}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          8. metadata-eval55.2%

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.006944444444444444 - \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \color{blue}{7.71604938271605 \cdot 10^{-6}}\right)}{\left(im \cdot im\right) \cdot 0.08333333333333333 - \left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          9. distribute-lft-out--55.2%

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.006944444444444444 - \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot 7.71604938271605 \cdot 10^{-6}\right)}{\color{blue}{\left(im \cdot im\right) \cdot \left(0.08333333333333333 - im \cdot \left(im \cdot 0.002777777777777778\right)\right)}}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        12. Simplified55.2%

          \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \color{blue}{\frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.006944444444444444 - \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot 7.71604938271605 \cdot 10^{-6}\right)}{\left(im \cdot im\right) \cdot \left(0.08333333333333333 - im \cdot \left(im \cdot 0.002777777777777778\right)\right)}}\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]

        if 3.6999999999999997e151 < im < 1.75e227

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

            \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
          3. exp-neg90.5%

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*90.5%

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

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

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

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

            \[\leadsto \left(2 + \color{blue}{im \cdot im}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        8. Simplified90.5%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 112000000:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \mathbf{elif}\;im \leq 5 \cdot 10^{+77}:\\ \;\;\;\;\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \frac{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.006944444444444444 - \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot 7.71604938271605 \cdot 10^{-6}\right)}{\left(im \cdot im\right) \cdot \left(0.08333333333333333 - im \cdot \left(im \cdot 0.002777777777777778\right)\right)}\right)\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151} \lor \neg \left(im \leq 1.75 \cdot 10^{+227}\right):\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 12: 58.4% accurate, 8.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ t_1 := 2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{if}\;im \leq 5.8 \cdot 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+51}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(t\_1 \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot t\_1\\ \mathbf{elif}\;im \leq 1.72 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (let* ((t_0 (+ 1.0 (* im (* im (+ 0.5 (* (* im im) 0.041666666666666664))))))
              (t_1
               (+
                2.0
                (* 0.002777777777777778 (* (* im im) (* (* im im) (* im im)))))))
         (if (<= im 5.8e+15)
           t_0
           (if (<= im 2.4e+51)
             (* (* re re) (* t_1 (+ -0.25 (/ 0.5 (* re re)))))
             (if (<= im 3.7e+151)
               (* 0.5 t_1)
               (if (<= im 1.72e+227)
                 (* (+ 2.0 (* im im)) (+ 0.5 (* re (* re -0.25))))
                 t_0))))))
      double code(double re, double im) {
      	double t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	double t_1 = 2.0 + (0.002777777777777778 * ((im * im) * ((im * im) * (im * im))));
      	double tmp;
      	if (im <= 5.8e+15) {
      		tmp = t_0;
      	} else if (im <= 2.4e+51) {
      		tmp = (re * re) * (t_1 * (-0.25 + (0.5 / (re * re))));
      	} else if (im <= 3.7e+151) {
      		tmp = 0.5 * t_1;
      	} else if (im <= 1.72e+227) {
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	} 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) :: t_1
          real(8) :: tmp
          t_0 = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
          t_1 = 2.0d0 + (0.002777777777777778d0 * ((im * im) * ((im * im) * (im * im))))
          if (im <= 5.8d+15) then
              tmp = t_0
          else if (im <= 2.4d+51) then
              tmp = (re * re) * (t_1 * ((-0.25d0) + (0.5d0 / (re * re))))
          else if (im <= 3.7d+151) then
              tmp = 0.5d0 * t_1
          else if (im <= 1.72d+227) then
              tmp = (2.0d0 + (im * im)) * (0.5d0 + (re * (re * (-0.25d0))))
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	double t_1 = 2.0 + (0.002777777777777778 * ((im * im) * ((im * im) * (im * im))));
      	double tmp;
      	if (im <= 5.8e+15) {
      		tmp = t_0;
      	} else if (im <= 2.4e+51) {
      		tmp = (re * re) * (t_1 * (-0.25 + (0.5 / (re * re))));
      	} else if (im <= 3.7e+151) {
      		tmp = 0.5 * t_1;
      	} else if (im <= 1.72e+227) {
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(re, im):
      	t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))))
      	t_1 = 2.0 + (0.002777777777777778 * ((im * im) * ((im * im) * (im * im))))
      	tmp = 0
      	if im <= 5.8e+15:
      		tmp = t_0
      	elif im <= 2.4e+51:
      		tmp = (re * re) * (t_1 * (-0.25 + (0.5 / (re * re))))
      	elif im <= 3.7e+151:
      		tmp = 0.5 * t_1
      	elif im <= 1.72e+227:
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)))
      	else:
      		tmp = t_0
      	return tmp
      
      function code(re, im)
      	t_0 = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664)))))
      	t_1 = Float64(2.0 + Float64(0.002777777777777778 * Float64(Float64(im * im) * Float64(Float64(im * im) * Float64(im * im)))))
      	tmp = 0.0
      	if (im <= 5.8e+15)
      		tmp = t_0;
      	elseif (im <= 2.4e+51)
      		tmp = Float64(Float64(re * re) * Float64(t_1 * Float64(-0.25 + Float64(0.5 / Float64(re * re)))));
      	elseif (im <= 3.7e+151)
      		tmp = Float64(0.5 * t_1);
      	elseif (im <= 1.72e+227)
      		tmp = Float64(Float64(2.0 + Float64(im * im)) * Float64(0.5 + Float64(re * Float64(re * -0.25))));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	t_1 = 2.0 + (0.002777777777777778 * ((im * im) * ((im * im) * (im * im))));
      	tmp = 0.0;
      	if (im <= 5.8e+15)
      		tmp = t_0;
      	elseif (im <= 2.4e+51)
      		tmp = (re * re) * (t_1 * (-0.25 + (0.5 / (re * re))));
      	elseif (im <= 3.7e+151)
      		tmp = 0.5 * t_1;
      	elseif (im <= 1.72e+227)
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := Block[{t$95$0 = N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 + N[(0.002777777777777778 * N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 5.8e+15], t$95$0, If[LessEqual[im, 2.4e+51], N[(N[(re * re), $MachinePrecision] * N[(t$95$1 * N[(-0.25 + N[(0.5 / N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.7e+151], N[(0.5 * t$95$1), $MachinePrecision], If[LessEqual[im, 1.72e+227], N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
      t_1 := 2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\\
      \mathbf{if}\;im \leq 5.8 \cdot 10^{+15}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;im \leq 2.4 \cdot 10^{+51}:\\
      \;\;\;\;\left(re \cdot re\right) \cdot \left(t\_1 \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\\
      
      \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151}:\\
      \;\;\;\;0.5 \cdot t\_1\\
      
      \mathbf{elif}\;im \leq 1.72 \cdot 10^{+227}:\\
      \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 regimes
      2. if im < 5.8e15 or 1.71999999999999995e227 < im

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in im around 0 93.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto 1 + \left(im \cdot im\right) \cdot \left(\color{blue}{im \cdot \left(im \cdot 0.041666666666666664\right)} + 0.5\right) \]
          6. associate-*r*59.7%

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

            \[\leadsto 1 + im \cdot \left(im \cdot \color{blue}{\left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)}\right) \]
          8. associate-*r*59.7%

            \[\leadsto 1 + im \cdot \left(im \cdot \left(0.5 + \color{blue}{\left(im \cdot im\right) \cdot 0.041666666666666664}\right)\right) \]
          9. *-commutative59.7%

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

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

        if 5.8e15 < im < 2.3999999999999999e51

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*85.7%

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

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

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

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

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

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

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + 0.002777777777777778 \cdot \color{blue}{\left(im \cdot im\right)}\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          4. *-commutative32.5%

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

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{im \cdot \left(im \cdot 0.002777777777777778\right)}\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        8. Simplified32.5%

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

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

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

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

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

            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \]
        11. Simplified32.5%

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

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

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

            \[\leadsto \left(re \cdot re\right) \cdot \left(\color{blue}{\left(2 + 0.002777777777777778 \cdot {im}^{6}\right) \cdot -0.25} + 0.5 \cdot \frac{2 + 0.002777777777777778 \cdot {im}^{6}}{{re}^{2}}\right) \]
          3. +-commutative57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\color{blue}{\left(0.002777777777777778 \cdot {im}^{6} + 2\right)} \cdot -0.25 + 0.5 \cdot \frac{2 + 0.002777777777777778 \cdot {im}^{6}}{{re}^{2}}\right) \]
          4. *-commutative57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\left(\color{blue}{{im}^{6} \cdot 0.002777777777777778} + 2\right) \cdot -0.25 + 0.5 \cdot \frac{2 + 0.002777777777777778 \cdot {im}^{6}}{{re}^{2}}\right) \]
          5. metadata-eval57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\left({im}^{\color{blue}{\left(2 \cdot 3\right)}} \cdot 0.002777777777777778 + 2\right) \cdot -0.25 + 0.5 \cdot \frac{2 + 0.002777777777777778 \cdot {im}^{6}}{{re}^{2}}\right) \]
          6. pow-sqr57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\left(\color{blue}{\left({im}^{3} \cdot {im}^{3}\right)} \cdot 0.002777777777777778 + 2\right) \cdot -0.25 + 0.5 \cdot \frac{2 + 0.002777777777777778 \cdot {im}^{6}}{{re}^{2}}\right) \]
          7. cube-unmult57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\left(\left(\color{blue}{\left(im \cdot \left(im \cdot im\right)\right)} \cdot {im}^{3}\right) \cdot 0.002777777777777778 + 2\right) \cdot -0.25 + 0.5 \cdot \frac{2 + 0.002777777777777778 \cdot {im}^{6}}{{re}^{2}}\right) \]
          8. cube-unmult57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\left(\left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \color{blue}{\left(im \cdot \left(im \cdot im\right)\right)}\right) \cdot 0.002777777777777778 + 2\right) \cdot -0.25 + 0.5 \cdot \frac{2 + 0.002777777777777778 \cdot {im}^{6}}{{re}^{2}}\right) \]
          9. *-commutative57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\left(\color{blue}{0.002777777777777778 \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)} + 2\right) \cdot -0.25 + 0.5 \cdot \frac{2 + 0.002777777777777778 \cdot {im}^{6}}{{re}^{2}}\right) \]
          10. associate-*r/57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\left(0.002777777777777778 \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) + 2\right) \cdot -0.25 + \color{blue}{\frac{0.5 \cdot \left(2 + 0.002777777777777778 \cdot {im}^{6}\right)}{{re}^{2}}}\right) \]
          11. *-commutative57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\left(0.002777777777777778 \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) + 2\right) \cdot -0.25 + \frac{\color{blue}{\left(2 + 0.002777777777777778 \cdot {im}^{6}\right) \cdot 0.5}}{{re}^{2}}\right) \]
          12. associate-/l*57.8%

            \[\leadsto \left(re \cdot re\right) \cdot \left(\left(0.002777777777777778 \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) + 2\right) \cdot -0.25 + \color{blue}{\left(2 + 0.002777777777777778 \cdot {im}^{6}\right) \cdot \frac{0.5}{{re}^{2}}}\right) \]
        14. Simplified57.8%

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

        if 2.3999999999999999e51 < im < 3.6999999999999997e151

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

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

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*66.7%

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

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

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

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

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

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

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + 0.002777777777777778 \cdot \color{blue}{\left(im \cdot im\right)}\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
          4. *-commutative66.7%

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

            \[\leadsto \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{im \cdot \left(im \cdot 0.002777777777777778\right)}\right)\right)\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        8. Simplified66.7%

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

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

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

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

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

            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \]
        11. Simplified66.7%

          \[\leadsto \left(2 + \color{blue}{0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        12. Taylor expanded in re around 0 80.0%

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

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot {im}^{\color{blue}{\left(2 \cdot 3\right)}}\right) \]
          2. pow-sqr80.0%

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left({im}^{3} \cdot {im}^{3}\right)}\right) \]
          3. cube-prod80.0%

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{{\left(im \cdot im\right)}^{3}}\right) \]
          4. cube-mult80.0%

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \]
        14. Simplified80.0%

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

        if 3.6999999999999997e151 < im < 1.71999999999999995e227

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

            \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
          3. exp-neg90.5%

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*90.5%

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

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

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

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

            \[\leadsto \left(2 + \color{blue}{im \cdot im}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        8. Simplified90.5%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 5.8 \cdot 10^{+15}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \mathbf{elif}\;im \leq 2.4 \cdot 10^{+51}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(\left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\right) \cdot \left(-0.25 + \frac{0.5}{re \cdot re}\right)\right)\\ \mathbf{elif}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.72 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 13: 58.7% accurate, 12.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;1 + 0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(1 + im \cdot \left(0.002777777777777778 \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= im 3.7e+151)
         (+
          1.0
          (*
           0.5
           (* (* im im) (+ 1.0 (* im (* 0.002777777777777778 (* im (* im im))))))))
         (if (<= im 1.6e+227)
           (* (+ 2.0 (* im im)) (+ 0.5 (* re (* re -0.25))))
           (+ 1.0 (* im (* im (+ 0.5 (* (* im im) 0.041666666666666664))))))))
      double code(double re, double im) {
      	double tmp;
      	if (im <= 3.7e+151) {
      		tmp = 1.0 + (0.5 * ((im * im) * (1.0 + (im * (0.002777777777777778 * (im * (im * im)))))));
      	} else if (im <= 1.6e+227) {
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	} else {
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	}
      	return tmp;
      }
      
      real(8) function code(re, im)
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8) :: tmp
          if (im <= 3.7d+151) then
              tmp = 1.0d0 + (0.5d0 * ((im * im) * (1.0d0 + (im * (0.002777777777777778d0 * (im * (im * im)))))))
          else if (im <= 1.6d+227) then
              tmp = (2.0d0 + (im * im)) * (0.5d0 + (re * (re * (-0.25d0))))
          else
              tmp = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double tmp;
      	if (im <= 3.7e+151) {
      		tmp = 1.0 + (0.5 * ((im * im) * (1.0 + (im * (0.002777777777777778 * (im * (im * im)))))));
      	} else if (im <= 1.6e+227) {
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	} else {
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if im <= 3.7e+151:
      		tmp = 1.0 + (0.5 * ((im * im) * (1.0 + (im * (0.002777777777777778 * (im * (im * im)))))))
      	elif im <= 1.6e+227:
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)))
      	else:
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))))
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if (im <= 3.7e+151)
      		tmp = Float64(1.0 + Float64(0.5 * Float64(Float64(im * im) * Float64(1.0 + Float64(im * Float64(0.002777777777777778 * Float64(im * Float64(im * im))))))));
      	elseif (im <= 1.6e+227)
      		tmp = Float64(Float64(2.0 + Float64(im * im)) * Float64(0.5 + Float64(re * Float64(re * -0.25))));
      	else
      		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664)))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if (im <= 3.7e+151)
      		tmp = 1.0 + (0.5 * ((im * im) * (1.0 + (im * (0.002777777777777778 * (im * (im * im)))))));
      	elseif (im <= 1.6e+227)
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	else
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[LessEqual[im, 3.7e+151], N[(1.0 + N[(0.5 * N[(N[(im * im), $MachinePrecision] * N[(1.0 + N[(im * N[(0.002777777777777778 * N[(im * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.6e+227], N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;im \leq 3.7 \cdot 10^{+151}:\\
      \;\;\;\;1 + 0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(1 + im \cdot \left(0.002777777777777778 \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right)\right)\\
      
      \mathbf{elif}\;im \leq 1.6 \cdot 10^{+227}:\\
      \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if im < 3.6999999999999997e151

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in im around 0 92.9%

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

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

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

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

            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{\left(im \cdot im\right)} \cdot 0.002777777777777778\right)\right)\right) \]
          5. associate-*l*92.9%

            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + \color{blue}{im \cdot \left(im \cdot 0.002777777777777778\right)}\right)\right)\right) \]
        5. Simplified92.9%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.08333333333333333 + im \cdot \left(im \cdot 0.002777777777777778\right)\right)\right)\right)} \]
        6. Taylor expanded in im around inf 92.5%

          \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + \color{blue}{0.002777777777777778 \cdot {im}^{4}}\right)\right) \]
        7. Step-by-step derivation
          1. metadata-eval92.5%

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

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

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

            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \color{blue}{\left(im \cdot im\right)}\right)\right)\right) \]
        8. Simplified92.5%

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

          \[\leadsto \color{blue}{0.5 \cdot \left(2 + {im}^{2} \cdot \left(1 + 0.002777777777777778 \cdot {im}^{4}\right)\right)} \]
        10. Step-by-step derivation
          1. distribute-rgt-in59.2%

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

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

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

            \[\leadsto 1 + \left(\left(im \cdot im\right) \cdot \left(1 + 0.002777777777777778 \cdot {im}^{\color{blue}{\left(3 + 1\right)}}\right)\right) \cdot 0.5 \]
          5. pow-plus59.2%

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

            \[\leadsto 1 + \left(\left(im \cdot im\right) \cdot \left(1 + 0.002777777777777778 \cdot \left(\color{blue}{\left(im \cdot \left(im \cdot im\right)\right)} \cdot im\right)\right)\right) \cdot 0.5 \]
          7. associate-*l*59.2%

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

            \[\leadsto 1 + \left(\left(im \cdot im\right) \cdot \left(1 + \color{blue}{im \cdot \left(0.002777777777777778 \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)}\right)\right) \cdot 0.5 \]
        11. Simplified59.2%

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

        if 3.6999999999999997e151 < im < 1.59999999999999994e227

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

            \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
          3. exp-neg90.5%

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*90.5%

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

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

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

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

            \[\leadsto \left(2 + \color{blue}{im \cdot im}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        8. Simplified90.5%

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

        if 1.59999999999999994e227 < im

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto 1 + \left(im \cdot im\right) \cdot \left(\color{blue}{im \cdot \left(im \cdot 0.041666666666666664\right)} + 0.5\right) \]
          6. associate-*r*82.4%

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

            \[\leadsto 1 + im \cdot \left(im \cdot \color{blue}{\left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)}\right) \]
          8. associate-*r*82.4%

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;1 + 0.5 \cdot \left(\left(im \cdot im\right) \cdot \left(1 + im \cdot \left(0.002777777777777778 \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.6 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 14: 55.8% accurate, 13.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 3.7 \cdot 10^{+151} \lor \neg \left(im \leq 1.6 \cdot 10^{+227}\right):\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (or (<= im 3.7e+151) (not (<= im 1.6e+227)))
         (+ 1.0 (* im (* im (+ 0.5 (* (* im im) 0.041666666666666664)))))
         (* (+ 2.0 (* im im)) (+ 0.5 (* re (* re -0.25))))))
      double code(double re, double im) {
      	double tmp;
      	if ((im <= 3.7e+151) || !(im <= 1.6e+227)) {
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	} else {
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	}
      	return tmp;
      }
      
      real(8) function code(re, im)
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8) :: tmp
          if ((im <= 3.7d+151) .or. (.not. (im <= 1.6d+227))) then
              tmp = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
          else
              tmp = (2.0d0 + (im * im)) * (0.5d0 + (re * (re * (-0.25d0))))
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double tmp;
      	if ((im <= 3.7e+151) || !(im <= 1.6e+227)) {
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	} else {
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if (im <= 3.7e+151) or not (im <= 1.6e+227):
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))))
      	else:
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)))
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if ((im <= 3.7e+151) || !(im <= 1.6e+227))
      		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664)))));
      	else
      		tmp = Float64(Float64(2.0 + Float64(im * im)) * Float64(0.5 + Float64(re * Float64(re * -0.25))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if ((im <= 3.7e+151) || ~((im <= 1.6e+227)))
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	else
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[Or[LessEqual[im, 3.7e+151], N[Not[LessEqual[im, 1.6e+227]], $MachinePrecision]], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;im \leq 3.7 \cdot 10^{+151} \lor \neg \left(im \leq 1.6 \cdot 10^{+227}\right):\\
      \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if im < 3.6999999999999997e151 or 1.59999999999999994e227 < im

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in im around 0 90.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto 1 + \left(im \cdot im\right) \cdot \left(\color{blue}{im \cdot \left(im \cdot 0.041666666666666664\right)} + 0.5\right) \]
          6. associate-*r*58.1%

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

            \[\leadsto 1 + im \cdot \left(im \cdot \color{blue}{\left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)}\right) \]
          8. associate-*r*58.1%

            \[\leadsto 1 + im \cdot \left(im \cdot \left(0.5 + \color{blue}{\left(im \cdot im\right) \cdot 0.041666666666666664}\right)\right) \]
          9. *-commutative58.1%

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

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

        if 3.6999999999999997e151 < im < 1.59999999999999994e227

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

            \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
          3. exp-neg90.5%

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*90.5%

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

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

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

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

            \[\leadsto \left(2 + \color{blue}{im \cdot im}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        8. Simplified90.5%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.7 \cdot 10^{+151} \lor \neg \left(im \leq 1.6 \cdot 10^{+227}\right):\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 15: 58.7% accurate, 13.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.65 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= im 3.7e+151)
         (*
          0.5
          (+ 2.0 (* 0.002777777777777778 (* (* im im) (* (* im im) (* im im))))))
         (if (<= im 1.65e+227)
           (* (+ 2.0 (* im im)) (+ 0.5 (* re (* re -0.25))))
           (+ 1.0 (* im (* im (+ 0.5 (* (* im im) 0.041666666666666664))))))))
      double code(double re, double im) {
      	double tmp;
      	if (im <= 3.7e+151) {
      		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * ((im * im) * (im * im)))));
      	} else if (im <= 1.65e+227) {
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	} else {
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	}
      	return tmp;
      }
      
      real(8) function code(re, im)
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8) :: tmp
          if (im <= 3.7d+151) then
              tmp = 0.5d0 * (2.0d0 + (0.002777777777777778d0 * ((im * im) * ((im * im) * (im * im)))))
          else if (im <= 1.65d+227) then
              tmp = (2.0d0 + (im * im)) * (0.5d0 + (re * (re * (-0.25d0))))
          else
              tmp = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double tmp;
      	if (im <= 3.7e+151) {
      		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * ((im * im) * (im * im)))));
      	} else if (im <= 1.65e+227) {
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	} else {
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if im <= 3.7e+151:
      		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * ((im * im) * (im * im)))))
      	elif im <= 1.65e+227:
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)))
      	else:
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))))
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if (im <= 3.7e+151)
      		tmp = Float64(0.5 * Float64(2.0 + Float64(0.002777777777777778 * Float64(Float64(im * im) * Float64(Float64(im * im) * Float64(im * im))))));
      	elseif (im <= 1.65e+227)
      		tmp = Float64(Float64(2.0 + Float64(im * im)) * Float64(0.5 + Float64(re * Float64(re * -0.25))));
      	else
      		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664)))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if (im <= 3.7e+151)
      		tmp = 0.5 * (2.0 + (0.002777777777777778 * ((im * im) * ((im * im) * (im * im)))));
      	elseif (im <= 1.65e+227)
      		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * -0.25)));
      	else
      		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[LessEqual[im, 3.7e+151], N[(0.5 * N[(2.0 + N[(0.002777777777777778 * N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.65e+227], N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;im \leq 3.7 \cdot 10^{+151}:\\
      \;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\right)\\
      
      \mathbf{elif}\;im \leq 1.65 \cdot 10^{+227}:\\
      \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if im < 3.6999999999999997e151

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 26.0%

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

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

            \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
          3. exp-neg57.6%

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*57.6%

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + \color{blue}{\left(-0.25 \cdot re\right) \cdot re}\right) \]
          7. *-commutative57.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \]
        11. Simplified53.9%

          \[\leadsto \left(2 + \color{blue}{0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        12. Taylor expanded in re around 0 59.0%

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

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot {im}^{\color{blue}{\left(2 \cdot 3\right)}}\right) \]
          2. pow-sqr59.0%

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left({im}^{3} \cdot {im}^{3}\right)}\right) \]
          3. cube-prod59.0%

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{{\left(im \cdot im\right)}^{3}}\right) \]
          4. cube-mult59.0%

            \[\leadsto 0.5 \cdot \left(2 + 0.002777777777777778 \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)}\right) \]
        14. Simplified59.0%

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

        if 3.6999999999999997e151 < im < 1.6499999999999999e227

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in re around 0 0.0%

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

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

            \[\leadsto \color{blue}{\left(e^{im} + e^{-im}\right) \cdot \left(-0.25 \cdot {re}^{2} + 0.5\right)} \]
          3. exp-neg90.5%

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

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

            \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
          6. associate-*r*90.5%

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

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

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

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

            \[\leadsto \left(2 + \color{blue}{im \cdot im}\right) \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
        8. Simplified90.5%

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

        if 1.6499999999999999e227 < im

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in im around 0 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto 1 + \left(im \cdot im\right) \cdot \left(\color{blue}{im \cdot \left(im \cdot 0.041666666666666664\right)} + 0.5\right) \]
          6. associate-*r*82.4%

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

            \[\leadsto 1 + im \cdot \left(im \cdot \color{blue}{\left(0.5 + im \cdot \left(im \cdot 0.041666666666666664\right)\right)}\right) \]
          8. associate-*r*82.4%

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.7 \cdot 10^{+151}:\\ \;\;\;\;0.5 \cdot \left(2 + 0.002777777777777778 \cdot \left(\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\right)\\ \mathbf{elif}\;im \leq 1.65 \cdot 10^{+227}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 16: 49.3% accurate, 23.7× speedup?

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

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0 22.1%

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

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

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

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

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

          \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
        6. associate-*r*61.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(2 + im \cdot im\right)} \cdot \left(0.5 + re \cdot \left(-0.25 \cdot re\right)\right) \]
      9. Final simplification49.7%

        \[\leadsto \left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \]
      10. Add Preprocessing

      Alternative 17: 35.4% accurate, 28.0× speedup?

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

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0 22.1%

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

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

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

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

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

          \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
        6. associate-*r*61.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(im + 2\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]
      10. Final simplification35.9%

        \[\leadsto \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot \left(im + 2\right) \]
      11. Add Preprocessing

      Alternative 18: 32.6% accurate, 44.0× speedup?

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

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in re around 0 22.1%

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

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

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

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

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

          \[\leadsto \left(e^{im} + \frac{1}{e^{im}}\right) \cdot \left(0.5 + -0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \]
        6. associate-*r*61.2%

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

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

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

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

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

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

          \[\leadsto 1 + \left(-0.25 \cdot \color{blue}{\left(re \cdot re\right)}\right) \cdot 2 \]
      8. Simplified30.2%

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

          \[\leadsto 1 + \color{blue}{\left(\left(re \cdot re\right) \cdot -0.25\right)} \cdot 2 \]
        2. associate-*l*30.2%

          \[\leadsto 1 + \color{blue}{\left(re \cdot re\right) \cdot \left(-0.25 \cdot 2\right)} \]
        3. metadata-eval30.2%

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

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

      Reproduce

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