math.cos on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 12.2s
Alternatives: 25
Speedup: 1.5×

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 25 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.5× speedup?

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

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

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
  2. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
    11. exp-negN/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
    15. exp-lowering-exp.f64100.0%

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

    \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
    5. distribute-lft-outN/A

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
    11. cos-lowering-cos.f64100.0%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
  6. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
  7. Step-by-step derivation
    1. *-lowering-*.f64N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cosh.f64}\left(im\right), \cos \color{blue}{re}\right) \]
    4. cos-lowering-cos.f64100.0%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cosh.f64}\left(im\right), \mathsf{cos.f64}\left(re\right)\right) \]
  8. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\cosh im \cdot \cos re} \]
  9. Add Preprocessing

Alternative 2: 87.4% accurate, 2.4× speedup?

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

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

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

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


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

    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

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

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

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

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

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

    if 0.016 < im < 7.20000000000000022e51

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
      11. exp-negN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
      15. exp-lowering-exp.f64100.0%

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

      \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
      5. distribute-lft-outN/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
      11. cos-lowering-cos.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
    6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

    if 7.20000000000000022e51 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
      11. exp-negN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
      15. exp-lowering-exp.f64100.0%

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

      \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
      5. distribute-lft-outN/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
      11. cos-lowering-cos.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
    6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.016:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 7.2 \cdot 10^{+51}:\\ \;\;\;\;\cosh im \cdot \left(1 + \left(re \cdot re\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 86.9% accurate, 2.5× speedup?

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

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

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

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


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

    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

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

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

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

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

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

    if 0.320000000000000007 < im < 2.6000000000000002e77

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
      11. exp-negN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
      15. exp-lowering-exp.f64100.0%

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

      \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
      5. distribute-lft-outN/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
      11. cos-lowering-cos.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
    6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

    if 2.6000000000000002e77 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
      11. exp-negN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
      15. exp-lowering-exp.f64100.0%

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

      \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in im around 0

      \[\leadsto \color{blue}{\cos re + {im}^{2} \cdot \left(\frac{1}{24} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-inN/A

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

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

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

        \[\leadsto \left(\cos re + \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \cos re\right) + {im}^{\color{blue}{2}} \cdot \left(\frac{1}{2} \cdot \cos re\right) \]
      5. distribute-rgt1-inN/A

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

        \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + 1\right) \cdot \cos re + \left({im}^{2} \cdot \frac{1}{2}\right) \cdot \color{blue}{\cos re} \]
      7. unpow2N/A

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

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

        \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + 1\right) \cdot \cos re + \left(im \cdot \left(\frac{1}{2} \cdot im\right)\right) \cdot \cos re \]
      10. distribute-rgt-outN/A

        \[\leadsto \cos re \cdot \color{blue}{\left(\left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + 1\right) + im \cdot \left(\frac{1}{2} \cdot im\right)\right)} \]
      11. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{1}{24}\right)}\right)\right)\right) \]
      12. *-lowering-*.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{24}}\right)\right)\right)\right) \]
    10. Simplified100.0%

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

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

Alternative 4: 86.9% accurate, 2.5× speedup?

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

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

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

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


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

    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

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

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

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

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

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

    if 0.025000000000000001 < im < 2.6000000000000002e77

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
      11. exp-negN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
      15. exp-lowering-exp.f64100.0%

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

      \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
      5. distribute-lft-outN/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
      11. cos-lowering-cos.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
    6. Applied egg-rr100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \color{blue}{1}\right) \]
    8. Step-by-step derivation
      1. Simplified50.1%

        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{1} \]
      2. Step-by-step derivation
        1. *-lft-identityN/A

          \[\leadsto \cosh im \cdot 1 \]
        2. *-rgt-identityN/A

          \[\leadsto \cosh im \]
        3. cosh-lowering-cosh.f6450.1%

          \[\leadsto \mathsf{cosh.f64}\left(im\right) \]
      3. Applied egg-rr50.1%

        \[\leadsto \color{blue}{\cosh 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. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
        11. exp-negN/A

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
        15. exp-lowering-exp.f64100.0%

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

        \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
      4. Add Preprocessing
      5. Taylor expanded in im around 0

        \[\leadsto \color{blue}{\cos re + {im}^{2} \cdot \left(\frac{1}{24} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right)} \]
      6. Step-by-step derivation
        1. distribute-lft-inN/A

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

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

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

          \[\leadsto \left(\cos re + \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \cos re\right) + {im}^{\color{blue}{2}} \cdot \left(\frac{1}{2} \cdot \cos re\right) \]
        5. distribute-rgt1-inN/A

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

          \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + 1\right) \cdot \cos re + \left({im}^{2} \cdot \frac{1}{2}\right) \cdot \color{blue}{\cos re} \]
        7. unpow2N/A

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

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

          \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + 1\right) \cdot \cos re + \left(im \cdot \left(\frac{1}{2} \cdot im\right)\right) \cdot \cos re \]
        10. distribute-rgt-outN/A

          \[\leadsto \cos re \cdot \color{blue}{\left(\left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + 1\right) + im \cdot \left(\frac{1}{2} \cdot im\right)\right)} \]
        11. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \frac{1}{24}\right)}\right)\right)\right) \]
        12. *-lowering-*.f64100.0%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{24}}\right)\right)\right)\right) \]
      10. Simplified100.0%

        \[\leadsto \cos re \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot 0.041666666666666664\right)\right)\right)} \]
    9. Recombined 3 regimes into one program.
    10. Final simplification85.3%

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

    Alternative 5: 85.3% accurate, 2.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{if}\;im \leq 0.023:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 8 \cdot 10^{+153}:\\ \;\;\;\;\cosh im\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (re im)
     :precision binary64
     (let* ((t_0 (* (* (cos re) 0.5) (+ 2.0 (* im im)))))
       (if (<= im 0.023) t_0 (if (<= im 8e+153) (cosh im) t_0))))
    double code(double re, double im) {
    	double t_0 = (cos(re) * 0.5) * (2.0 + (im * im));
    	double tmp;
    	if (im <= 0.023) {
    		tmp = t_0;
    	} else if (im <= 8e+153) {
    		tmp = cosh(im);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    real(8) function code(re, im)
        real(8), intent (in) :: re
        real(8), intent (in) :: im
        real(8) :: t_0
        real(8) :: tmp
        t_0 = (cos(re) * 0.5d0) * (2.0d0 + (im * im))
        if (im <= 0.023d0) then
            tmp = t_0
        else if (im <= 8d+153) then
            tmp = cosh(im)
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double re, double im) {
    	double t_0 = (Math.cos(re) * 0.5) * (2.0 + (im * im));
    	double tmp;
    	if (im <= 0.023) {
    		tmp = t_0;
    	} else if (im <= 8e+153) {
    		tmp = Math.cosh(im);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(re, im):
    	t_0 = (math.cos(re) * 0.5) * (2.0 + (im * im))
    	tmp = 0
    	if im <= 0.023:
    		tmp = t_0
    	elif im <= 8e+153:
    		tmp = math.cosh(im)
    	else:
    		tmp = t_0
    	return tmp
    
    function code(re, im)
    	t_0 = Float64(Float64(cos(re) * 0.5) * Float64(2.0 + Float64(im * im)))
    	tmp = 0.0
    	if (im <= 0.023)
    		tmp = t_0;
    	elseif (im <= 8e+153)
    		tmp = cosh(im);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(re, im)
    	t_0 = (cos(re) * 0.5) * (2.0 + (im * im));
    	tmp = 0.0;
    	if (im <= 0.023)
    		tmp = t_0;
    	elseif (im <= 8e+153)
    		tmp = cosh(im);
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[re_, im_] := Block[{t$95$0 = N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.023], t$95$0, If[LessEqual[im, 8e+153], N[Cosh[im], $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\
    \mathbf{if}\;im \leq 0.023:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;im \leq 8 \cdot 10^{+153}:\\
    \;\;\;\;\cosh im\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if im < 0.023 or 8e153 < 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

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

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

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

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

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

      if 0.023 < im < 8e153

      1. Initial program 100.0%

        \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
      2. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
        11. exp-negN/A

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
        15. exp-lowering-exp.f64100.0%

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

        \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
      4. Add Preprocessing
      5. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
        5. distribute-lft-outN/A

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
        11. cos-lowering-cos.f64100.0%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
      6. Applied egg-rr100.0%

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \color{blue}{1}\right) \]
      8. Step-by-step derivation
        1. Simplified64.1%

          \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{1} \]
        2. Step-by-step derivation
          1. *-lft-identityN/A

            \[\leadsto \cosh im \cdot 1 \]
          2. *-rgt-identityN/A

            \[\leadsto \cosh im \]
          3. cosh-lowering-cosh.f6464.1%

            \[\leadsto \mathsf{cosh.f64}\left(im\right) \]
        3. Applied egg-rr64.1%

          \[\leadsto \color{blue}{\cosh im} \]
      9. Recombined 2 regimes into one program.
      10. Final simplification84.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.023:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 8 \cdot 10^{+153}:\\ \;\;\;\;\cosh im\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(2 + im \cdot im\right)\\ \end{array} \]
      11. Add Preprocessing

      Alternative 6: 73.4% accurate, 2.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00044:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 8 \cdot 10^{+153}:\\ \;\;\;\;\cosh im\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= im 0.00044)
         (cos re)
         (if (<= im 8e+153) (cosh im) (* (* (cos re) 0.5) (* im im)))))
      double code(double re, double im) {
      	double tmp;
      	if (im <= 0.00044) {
      		tmp = cos(re);
      	} else if (im <= 8e+153) {
      		tmp = cosh(im);
      	} else {
      		tmp = (cos(re) * 0.5) * (im * im);
      	}
      	return tmp;
      }
      
      real(8) function code(re, im)
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8) :: tmp
          if (im <= 0.00044d0) then
              tmp = cos(re)
          else if (im <= 8d+153) then
              tmp = cosh(im)
          else
              tmp = (cos(re) * 0.5d0) * (im * im)
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double tmp;
      	if (im <= 0.00044) {
      		tmp = Math.cos(re);
      	} else if (im <= 8e+153) {
      		tmp = Math.cosh(im);
      	} else {
      		tmp = (Math.cos(re) * 0.5) * (im * im);
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if im <= 0.00044:
      		tmp = math.cos(re)
      	elif im <= 8e+153:
      		tmp = math.cosh(im)
      	else:
      		tmp = (math.cos(re) * 0.5) * (im * im)
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if (im <= 0.00044)
      		tmp = cos(re);
      	elseif (im <= 8e+153)
      		tmp = cosh(im);
      	else
      		tmp = Float64(Float64(cos(re) * 0.5) * Float64(im * im));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if (im <= 0.00044)
      		tmp = cos(re);
      	elseif (im <= 8e+153)
      		tmp = cosh(im);
      	else
      		tmp = (cos(re) * 0.5) * (im * im);
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[LessEqual[im, 0.00044], N[Cos[re], $MachinePrecision], If[LessEqual[im, 8e+153], N[Cosh[im], $MachinePrecision], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;im \leq 0.00044:\\
      \;\;\;\;\cos re\\
      
      \mathbf{elif}\;im \leq 8 \cdot 10^{+153}:\\
      \;\;\;\;\cosh im\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(im \cdot im\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if im < 4.40000000000000016e-4

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Step-by-step derivation
          1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
          11. exp-negN/A

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
          15. exp-lowering-exp.f64100.0%

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

          \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
        4. Add Preprocessing
        5. Taylor expanded in im around 0

          \[\leadsto \color{blue}{\cos re} \]
        6. Step-by-step derivation
          1. cos-lowering-cos.f6464.0%

            \[\leadsto \mathsf{cos.f64}\left(re\right) \]
        7. Simplified64.0%

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

        if 4.40000000000000016e-4 < im < 8e153

        1. Initial program 100.0%

          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
        2. Step-by-step derivation
          1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
          11. exp-negN/A

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
          15. exp-lowering-exp.f64100.0%

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

          \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
        4. Add Preprocessing
        5. Step-by-step derivation
          1. *-commutativeN/A

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
          5. distribute-lft-outN/A

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
          11. cos-lowering-cos.f64100.0%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
        6. Applied egg-rr100.0%

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \color{blue}{1}\right) \]
        8. Step-by-step derivation
          1. Simplified64.1%

            \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{1} \]
          2. Step-by-step derivation
            1. *-lft-identityN/A

              \[\leadsto \cosh im \cdot 1 \]
            2. *-rgt-identityN/A

              \[\leadsto \cosh im \]
            3. cosh-lowering-cosh.f6464.1%

              \[\leadsto \mathsf{cosh.f64}\left(im\right) \]
          3. Applied egg-rr64.1%

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

          if 8e153 < 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

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

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

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

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

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

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

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

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

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

          \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.00044:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 8 \cdot 10^{+153}:\\ \;\;\;\;\cosh im\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(im \cdot im\right)\\ \end{array} \]
        11. Add Preprocessing

        Alternative 7: 69.9% accurate, 2.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00019:\\ \;\;\;\;\cos re\\ \mathbf{else}:\\ \;\;\;\;\cosh im\\ \end{array} \end{array} \]
        (FPCore (re im) :precision binary64 (if (<= im 0.00019) (cos re) (cosh im)))
        double code(double re, double im) {
        	double tmp;
        	if (im <= 0.00019) {
        		tmp = cos(re);
        	} else {
        		tmp = cosh(im);
        	}
        	return tmp;
        }
        
        real(8) function code(re, im)
            real(8), intent (in) :: re
            real(8), intent (in) :: im
            real(8) :: tmp
            if (im <= 0.00019d0) then
                tmp = cos(re)
            else
                tmp = cosh(im)
            end if
            code = tmp
        end function
        
        public static double code(double re, double im) {
        	double tmp;
        	if (im <= 0.00019) {
        		tmp = Math.cos(re);
        	} else {
        		tmp = Math.cosh(im);
        	}
        	return tmp;
        }
        
        def code(re, im):
        	tmp = 0
        	if im <= 0.00019:
        		tmp = math.cos(re)
        	else:
        		tmp = math.cosh(im)
        	return tmp
        
        function code(re, im)
        	tmp = 0.0
        	if (im <= 0.00019)
        		tmp = cos(re);
        	else
        		tmp = cosh(im);
        	end
        	return tmp
        end
        
        function tmp_2 = code(re, im)
        	tmp = 0.0;
        	if (im <= 0.00019)
        		tmp = cos(re);
        	else
        		tmp = cosh(im);
        	end
        	tmp_2 = tmp;
        end
        
        code[re_, im_] := If[LessEqual[im, 0.00019], N[Cos[re], $MachinePrecision], N[Cosh[im], $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;im \leq 0.00019:\\
        \;\;\;\;\cos re\\
        
        \mathbf{else}:\\
        \;\;\;\;\cosh im\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if im < 1.9000000000000001e-4

          1. Initial program 100.0%

            \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
          2. Step-by-step derivation
            1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
            11. exp-negN/A

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
            15. exp-lowering-exp.f64100.0%

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

            \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
          4. Add Preprocessing
          5. Taylor expanded in im around 0

            \[\leadsto \color{blue}{\cos re} \]
          6. Step-by-step derivation
            1. cos-lowering-cos.f6464.0%

              \[\leadsto \mathsf{cos.f64}\left(re\right) \]
          7. Simplified64.0%

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

          if 1.9000000000000001e-4 < im

          1. Initial program 100.0%

            \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
          2. Step-by-step derivation
            1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
            11. exp-negN/A

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
            15. exp-lowering-exp.f64100.0%

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

            \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
          4. Add Preprocessing
          5. Step-by-step derivation
            1. *-commutativeN/A

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
            5. distribute-lft-outN/A

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
            11. cos-lowering-cos.f64100.0%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
          6. Applied egg-rr100.0%

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \color{blue}{1}\right) \]
          8. Step-by-step derivation
            1. Simplified69.9%

              \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{1} \]
            2. Step-by-step derivation
              1. *-lft-identityN/A

                \[\leadsto \cosh im \cdot 1 \]
              2. *-rgt-identityN/A

                \[\leadsto \cosh im \]
              3. cosh-lowering-cosh.f6469.9%

                \[\leadsto \mathsf{cosh.f64}\left(im\right) \]
            3. Applied egg-rr69.9%

              \[\leadsto \color{blue}{\cosh im} \]
          9. Recombined 2 regimes into one program.
          10. Add Preprocessing

          Alternative 8: 68.1% accurate, 2.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(im \cdot im\right) \cdot 0.08333333333333333\\ \mathbf{if}\;im \leq 1100:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+64}:\\ \;\;\;\;\frac{\left(4 + \left(im \cdot \left(im \cdot \left(1 + t\_0\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-1 - t\_0\right)\right)\right)\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)}{2 - im \cdot im}\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \end{array} \end{array} \]
          (FPCore (re im)
           :precision binary64
           (let* ((t_0 (* (* im im) 0.08333333333333333)))
             (if (<= im 1100.0)
               (cos re)
               (if (<= im 2e+64)
                 (/
                  (*
                   (+ 4.0 (* (* im (* im (+ 1.0 t_0))) (* im (* im (- -1.0 t_0)))))
                   (+ 0.5 (* (* re re) -0.25)))
                  (- 2.0 (* im im)))
                 (+
                  1.0
                  (*
                   im
                   (*
                    im
                    (+
                     0.5
                     (*
                      (* im im)
                      (+
                       (* (* im im) 0.001388888888888889)
                       0.041666666666666664))))))))))
          double code(double re, double im) {
          	double t_0 = (im * im) * 0.08333333333333333;
          	double tmp;
          	if (im <= 1100.0) {
          		tmp = cos(re);
          	} else if (im <= 2e+64) {
          		tmp = ((4.0 + ((im * (im * (1.0 + t_0))) * (im * (im * (-1.0 - t_0))))) * (0.5 + ((re * re) * -0.25))) / (2.0 - (im * im));
          	} else {
          		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 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) :: tmp
              t_0 = (im * im) * 0.08333333333333333d0
              if (im <= 1100.0d0) then
                  tmp = cos(re)
              else if (im <= 2d+64) then
                  tmp = ((4.0d0 + ((im * (im * (1.0d0 + t_0))) * (im * (im * ((-1.0d0) - t_0))))) * (0.5d0 + ((re * re) * (-0.25d0)))) / (2.0d0 - (im * im))
              else
                  tmp = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * (((im * im) * 0.001388888888888889d0) + 0.041666666666666664d0)))))
              end if
              code = tmp
          end function
          
          public static double code(double re, double im) {
          	double t_0 = (im * im) * 0.08333333333333333;
          	double tmp;
          	if (im <= 1100.0) {
          		tmp = Math.cos(re);
          	} else if (im <= 2e+64) {
          		tmp = ((4.0 + ((im * (im * (1.0 + t_0))) * (im * (im * (-1.0 - t_0))))) * (0.5 + ((re * re) * -0.25))) / (2.0 - (im * im));
          	} else {
          		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
          	}
          	return tmp;
          }
          
          def code(re, im):
          	t_0 = (im * im) * 0.08333333333333333
          	tmp = 0
          	if im <= 1100.0:
          		tmp = math.cos(re)
          	elif im <= 2e+64:
          		tmp = ((4.0 + ((im * (im * (1.0 + t_0))) * (im * (im * (-1.0 - t_0))))) * (0.5 + ((re * re) * -0.25))) / (2.0 - (im * im))
          	else:
          		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))))
          	return tmp
          
          function code(re, im)
          	t_0 = Float64(Float64(im * im) * 0.08333333333333333)
          	tmp = 0.0
          	if (im <= 1100.0)
          		tmp = cos(re);
          	elseif (im <= 2e+64)
          		tmp = Float64(Float64(Float64(4.0 + Float64(Float64(im * Float64(im * Float64(1.0 + t_0))) * Float64(im * Float64(im * Float64(-1.0 - t_0))))) * Float64(0.5 + Float64(Float64(re * re) * -0.25))) / Float64(2.0 - Float64(im * im)));
          	else
          		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * Float64(Float64(Float64(im * im) * 0.001388888888888889) + 0.041666666666666664))))));
          	end
          	return tmp
          end
          
          function tmp_2 = code(re, im)
          	t_0 = (im * im) * 0.08333333333333333;
          	tmp = 0.0;
          	if (im <= 1100.0)
          		tmp = cos(re);
          	elseif (im <= 2e+64)
          		tmp = ((4.0 + ((im * (im * (1.0 + t_0))) * (im * (im * (-1.0 - t_0))))) * (0.5 + ((re * re) * -0.25))) / (2.0 - (im * im));
          	else
          		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
          	end
          	tmp_2 = tmp;
          end
          
          code[re_, im_] := Block[{t$95$0 = N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]}, If[LessEqual[im, 1100.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2e+64], N[(N[(N[(4.0 + N[(N[(im * N[(im * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * N[(im * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * N[(N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \left(im \cdot im\right) \cdot 0.08333333333333333\\
          \mathbf{if}\;im \leq 1100:\\
          \;\;\;\;\cos re\\
          
          \mathbf{elif}\;im \leq 2 \cdot 10^{+64}:\\
          \;\;\;\;\frac{\left(4 + \left(im \cdot \left(im \cdot \left(1 + t\_0\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-1 - t\_0\right)\right)\right)\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)}{2 - im \cdot im}\\
          
          \mathbf{else}:\\
          \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if im < 1100

            1. Initial program 100.0%

              \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
            2. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
              11. exp-negN/A

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
              15. exp-lowering-exp.f64100.0%

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

              \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
            4. Add Preprocessing
            5. Taylor expanded in im around 0

              \[\leadsto \color{blue}{\cos re} \]
            6. Step-by-step derivation
              1. cos-lowering-cos.f6463.5%

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

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

            if 1100 < im < 2.00000000000000004e64

            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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
              11. *-lowering-*.f644.7%

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
            9. Step-by-step derivation
              1. flip-+N/A

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

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

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

              \[\leadsto \color{blue}{\frac{\left(4 - \left(im \cdot \left(im \cdot \left(1 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(1 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)}{2 - im \cdot \left(im \cdot \left(1 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)}} \]
            11. Taylor expanded in im around 0

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

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

                \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \frac{-1}{4}\right)\right)\right), \mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
            13. Simplified51.6%

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

            if 2.00000000000000004e64 < im

            1. Initial program 100.0%

              \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
            2. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
              11. exp-negN/A

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
              15. exp-lowering-exp.f64100.0%

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

              \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
            4. Add Preprocessing
            5. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
              5. distribute-lft-outN/A

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
              11. cos-lowering-cos.f64100.0%

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
            6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
              14. *-lowering-*.f6482.9%

                \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
            12. Simplified82.9%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1100:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im \leq 2 \cdot 10^{+64}:\\ \;\;\;\;\frac{\left(4 + \left(im \cdot \left(im \cdot \left(1 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-1 - \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)}{2 - im \cdot im}\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \end{array} \]
          5. Add Preprocessing

          Alternative 9: 44.9% accurate, 6.3× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(im \cdot im\right) \cdot 0.08333333333333333\\ \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\ \;\;\;\;1\\ \mathbf{elif}\;im \leq 2.15 \cdot 10^{+65}:\\ \;\;\;\;\frac{\left(4 + \left(im \cdot \left(im \cdot \left(1 + t\_0\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-1 - t\_0\right)\right)\right)\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)}{2 - im \cdot im}\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \end{array} \end{array} \]
          (FPCore (re im)
           :precision binary64
           (let* ((t_0 (* (* im im) 0.08333333333333333)))
             (if (<= im 3.05e-61)
               1.0
               (if (<= im 2.15e+65)
                 (/
                  (*
                   (+ 4.0 (* (* im (* im (+ 1.0 t_0))) (* im (* im (- -1.0 t_0)))))
                   (+ 0.5 (* (* re re) -0.25)))
                  (- 2.0 (* im im)))
                 (+
                  1.0
                  (*
                   im
                   (*
                    im
                    (+
                     0.5
                     (*
                      (* im im)
                      (+
                       (* (* im im) 0.001388888888888889)
                       0.041666666666666664))))))))))
          double code(double re, double im) {
          	double t_0 = (im * im) * 0.08333333333333333;
          	double tmp;
          	if (im <= 3.05e-61) {
          		tmp = 1.0;
          	} else if (im <= 2.15e+65) {
          		tmp = ((4.0 + ((im * (im * (1.0 + t_0))) * (im * (im * (-1.0 - t_0))))) * (0.5 + ((re * re) * -0.25))) / (2.0 - (im * im));
          	} else {
          		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 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) :: tmp
              t_0 = (im * im) * 0.08333333333333333d0
              if (im <= 3.05d-61) then
                  tmp = 1.0d0
              else if (im <= 2.15d+65) then
                  tmp = ((4.0d0 + ((im * (im * (1.0d0 + t_0))) * (im * (im * ((-1.0d0) - t_0))))) * (0.5d0 + ((re * re) * (-0.25d0)))) / (2.0d0 - (im * im))
              else
                  tmp = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * (((im * im) * 0.001388888888888889d0) + 0.041666666666666664d0)))))
              end if
              code = tmp
          end function
          
          public static double code(double re, double im) {
          	double t_0 = (im * im) * 0.08333333333333333;
          	double tmp;
          	if (im <= 3.05e-61) {
          		tmp = 1.0;
          	} else if (im <= 2.15e+65) {
          		tmp = ((4.0 + ((im * (im * (1.0 + t_0))) * (im * (im * (-1.0 - t_0))))) * (0.5 + ((re * re) * -0.25))) / (2.0 - (im * im));
          	} else {
          		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
          	}
          	return tmp;
          }
          
          def code(re, im):
          	t_0 = (im * im) * 0.08333333333333333
          	tmp = 0
          	if im <= 3.05e-61:
          		tmp = 1.0
          	elif im <= 2.15e+65:
          		tmp = ((4.0 + ((im * (im * (1.0 + t_0))) * (im * (im * (-1.0 - t_0))))) * (0.5 + ((re * re) * -0.25))) / (2.0 - (im * im))
          	else:
          		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))))
          	return tmp
          
          function code(re, im)
          	t_0 = Float64(Float64(im * im) * 0.08333333333333333)
          	tmp = 0.0
          	if (im <= 3.05e-61)
          		tmp = 1.0;
          	elseif (im <= 2.15e+65)
          		tmp = Float64(Float64(Float64(4.0 + Float64(Float64(im * Float64(im * Float64(1.0 + t_0))) * Float64(im * Float64(im * Float64(-1.0 - t_0))))) * Float64(0.5 + Float64(Float64(re * re) * -0.25))) / Float64(2.0 - Float64(im * im)));
          	else
          		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * Float64(Float64(Float64(im * im) * 0.001388888888888889) + 0.041666666666666664))))));
          	end
          	return tmp
          end
          
          function tmp_2 = code(re, im)
          	t_0 = (im * im) * 0.08333333333333333;
          	tmp = 0.0;
          	if (im <= 3.05e-61)
          		tmp = 1.0;
          	elseif (im <= 2.15e+65)
          		tmp = ((4.0 + ((im * (im * (1.0 + t_0))) * (im * (im * (-1.0 - t_0))))) * (0.5 + ((re * re) * -0.25))) / (2.0 - (im * im));
          	else
          		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
          	end
          	tmp_2 = tmp;
          end
          
          code[re_, im_] := Block[{t$95$0 = N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]}, If[LessEqual[im, 3.05e-61], 1.0, If[LessEqual[im, 2.15e+65], N[(N[(N[(4.0 + N[(N[(im * N[(im * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * N[(im * N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 - N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * N[(N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \left(im \cdot im\right) \cdot 0.08333333333333333\\
          \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\
          \;\;\;\;1\\
          
          \mathbf{elif}\;im \leq 2.15 \cdot 10^{+65}:\\
          \;\;\;\;\frac{\left(4 + \left(im \cdot \left(im \cdot \left(1 + t\_0\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-1 - t\_0\right)\right)\right)\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)}{2 - im \cdot im}\\
          
          \mathbf{else}:\\
          \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if im < 3.05e-61

            1. Initial program 100.0%

              \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
            2. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
              11. exp-negN/A

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
              15. exp-lowering-exp.f64100.0%

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

              \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
            4. Add Preprocessing
            5. Taylor expanded in im around 0

              \[\leadsto \color{blue}{\cos re} \]
            6. Step-by-step derivation
              1. cos-lowering-cos.f6462.6%

                \[\leadsto \mathsf{cos.f64}\left(re\right) \]
            7. Simplified62.6%

              \[\leadsto \color{blue}{\cos re} \]
            8. Taylor expanded in re around 0

              \[\leadsto \color{blue}{1} \]
            9. Step-by-step derivation
              1. Simplified34.7%

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

              if 3.05e-61 < im < 2.15000000000000023e65

              1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
              9. Step-by-step derivation
                1. flip-+N/A

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

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

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

                \[\leadsto \color{blue}{\frac{\left(4 - \left(im \cdot \left(im \cdot \left(1 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(1 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)}{2 - im \cdot \left(im \cdot \left(1 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)}} \]
              11. Taylor expanded in im around 0

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

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

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \frac{-1}{4}\right)\right)\right), \mathsf{\_.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
              13. Simplified52.2%

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

              if 2.15000000000000023e65 < im

              1. Initial program 100.0%

                \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
              2. Step-by-step derivation
                1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                11. exp-negN/A

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

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

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

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                15. exp-lowering-exp.f64100.0%

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

                \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
              4. Add Preprocessing
              5. Step-by-step derivation
                1. *-commutativeN/A

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

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

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

                  \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
                5. distribute-lft-outN/A

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

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

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

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

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

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
                11. cos-lowering-cos.f64100.0%

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
              6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                14. *-lowering-*.f6482.9%

                  \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
              12. Simplified82.9%

                \[\leadsto \color{blue}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)} \]
            10. Recombined 3 regimes into one program.
            11. Final simplification44.5%

              \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\ \;\;\;\;1\\ \mathbf{elif}\;im \leq 2.15 \cdot 10^{+65}:\\ \;\;\;\;\frac{\left(4 + \left(im \cdot \left(im \cdot \left(1 + \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right) \cdot \left(im \cdot \left(im \cdot \left(-1 - \left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)}{2 - im \cdot im}\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \end{array} \]
            12. Add Preprocessing

            Alternative 10: 44.5% 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 \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\ \;\;\;\;1\\ \mathbf{elif}\;im \leq 4.1 \cdot 10^{+65}:\\ \;\;\;\;\left(1 + \left(re \cdot re\right) \cdot -0.5\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
            (FPCore (re im)
             :precision binary64
             (let* ((t_0
                     (+
                      1.0
                      (*
                       im
                       (*
                        im
                        (+
                         0.5
                         (*
                          (* im im)
                          (+
                           (* (* im im) 0.001388888888888889)
                           0.041666666666666664))))))))
               (if (<= im 3.05e-61)
                 1.0
                 (if (<= im 4.1e+65) (* (+ 1.0 (* (* re re) -0.5)) t_0) t_0))))
            double code(double re, double im) {
            	double t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
            	double tmp;
            	if (im <= 3.05e-61) {
            		tmp = 1.0;
            	} else if (im <= 4.1e+65) {
            		tmp = (1.0 + ((re * re) * -0.5)) * t_0;
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            real(8) function code(re, im)
                real(8), intent (in) :: re
                real(8), intent (in) :: im
                real(8) :: t_0
                real(8) :: tmp
                t_0 = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * (((im * im) * 0.001388888888888889d0) + 0.041666666666666664d0)))))
                if (im <= 3.05d-61) then
                    tmp = 1.0d0
                else if (im <= 4.1d+65) then
                    tmp = (1.0d0 + ((re * re) * (-0.5d0))) * t_0
                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) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
            	double tmp;
            	if (im <= 3.05e-61) {
            		tmp = 1.0;
            	} else if (im <= 4.1e+65) {
            		tmp = (1.0 + ((re * re) * -0.5)) * t_0;
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            def code(re, im):
            	t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))))
            	tmp = 0
            	if im <= 3.05e-61:
            		tmp = 1.0
            	elif im <= 4.1e+65:
            		tmp = (1.0 + ((re * re) * -0.5)) * t_0
            	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) * Float64(Float64(Float64(im * im) * 0.001388888888888889) + 0.041666666666666664))))))
            	tmp = 0.0
            	if (im <= 3.05e-61)
            		tmp = 1.0;
            	elseif (im <= 4.1e+65)
            		tmp = Float64(Float64(1.0 + Float64(Float64(re * re) * -0.5)) * t_0);
            	else
            		tmp = t_0;
            	end
            	return tmp
            end
            
            function tmp_2 = code(re, im)
            	t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
            	tmp = 0.0;
            	if (im <= 3.05e-61)
            		tmp = 1.0;
            	elseif (im <= 4.1e+65)
            		tmp = (1.0 + ((re * re) * -0.5)) * t_0;
            	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] * N[(N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 3.05e-61], 1.0, If[LessEqual[im, 4.1e+65], N[(N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] * t$95$0), $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 \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\
            \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\
            \;\;\;\;1\\
            
            \mathbf{elif}\;im \leq 4.1 \cdot 10^{+65}:\\
            \;\;\;\;\left(1 + \left(re \cdot re\right) \cdot -0.5\right) \cdot t\_0\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if im < 3.05e-61

              1. Initial program 100.0%

                \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
              2. Step-by-step derivation
                1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                11. exp-negN/A

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

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

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

                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                15. exp-lowering-exp.f64100.0%

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

                \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
              4. Add Preprocessing
              5. Taylor expanded in im around 0

                \[\leadsto \color{blue}{\cos re} \]
              6. Step-by-step derivation
                1. cos-lowering-cos.f6462.6%

                  \[\leadsto \mathsf{cos.f64}\left(re\right) \]
              7. Simplified62.6%

                \[\leadsto \color{blue}{\cos re} \]
              8. Taylor expanded in re around 0

                \[\leadsto \color{blue}{1} \]
              9. Step-by-step derivation
                1. Simplified34.7%

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

                if 3.05e-61 < im < 4.1000000000000001e65

                1. Initial program 99.9%

                  \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                2. Step-by-step derivation
                  1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                  11. exp-negN/A

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                  15. exp-lowering-exp.f64100.0%

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

                  \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                4. Add Preprocessing
                5. Step-by-step derivation
                  1. *-commutativeN/A

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
                  5. distribute-lft-outN/A

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

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

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
                  11. cos-lowering-cos.f64100.0%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                  14. *-lowering-*.f6446.9%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                9. Simplified46.9%

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

                  \[\leadsto \color{blue}{1 + \left(\frac{-1}{2} \cdot \left({re}^{2} \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right) + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)} \]
                11. Step-by-step derivation
                  1. +-commutativeN/A

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

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

                    \[\leadsto \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right) + \left(\frac{-1}{2} \cdot {re}^{2}\right) \cdot \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)} \]
                  4. metadata-evalN/A

                    \[\leadsto \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right) + \left(\left(2 \cdot \frac{-1}{4}\right) \cdot {re}^{2}\right) \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right) \]
                  5. associate-*r*N/A

                    \[\leadsto \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right) + \left(2 \cdot \left(\frac{-1}{4} \cdot {re}^{2}\right)\right) \cdot \left(\color{blue}{1} + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right) \]
                  6. distribute-rgt1-inN/A

                    \[\leadsto \left(2 \cdot \left(\frac{-1}{4} \cdot {re}^{2}\right) + 1\right) \cdot \color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)} \]
                12. Simplified46.2%

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

                if 4.1000000000000001e65 < im

                1. Initial program 100.0%

                  \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                2. Step-by-step derivation
                  1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                  11. exp-negN/A

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                  15. exp-lowering-exp.f64100.0%

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

                  \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                4. Add Preprocessing
                5. Step-by-step derivation
                  1. *-commutativeN/A

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
                  5. distribute-lft-outN/A

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

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

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
                  11. cos-lowering-cos.f64100.0%

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                  14. *-lowering-*.f6482.9%

                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                12. Simplified82.9%

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

                \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\ \;\;\;\;1\\ \mathbf{elif}\;im \leq 4.1 \cdot 10^{+65}:\\ \;\;\;\;\left(1 + \left(re \cdot re\right) \cdot -0.5\right) \cdot \left(1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \end{array} \]
              12. Add Preprocessing

              Alternative 11: 44.3% accurate, 8.8× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\ \;\;\;\;1\\ \mathbf{elif}\;im \leq 3.4 \cdot 10^{+39}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot \left(-0.25 + \left(re \cdot re\right) \cdot \left(0.020833333333333332 + \left(re \cdot re\right) \cdot -0.0006944444444444445\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \end{array} \end{array} \]
              (FPCore (re im)
               :precision binary64
               (if (<= im 3.05e-61)
                 1.0
                 (if (<= im 3.4e+39)
                   (*
                    (+ 2.0 (* im im))
                    (+
                     0.5
                     (*
                      re
                      (*
                       re
                       (+
                        -0.25
                        (*
                         (* re re)
                         (+ 0.020833333333333332 (* (* re re) -0.0006944444444444445))))))))
                   (+
                    1.0
                    (*
                     im
                     (*
                      im
                      (+
                       0.5
                       (*
                        (* im im)
                        (+ (* (* im im) 0.001388888888888889) 0.041666666666666664)))))))))
              double code(double re, double im) {
              	double tmp;
              	if (im <= 3.05e-61) {
              		tmp = 1.0;
              	} else if (im <= 3.4e+39) {
              		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * (-0.25 + ((re * re) * (0.020833333333333332 + ((re * re) * -0.0006944444444444445)))))));
              	} else {
              		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 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.05d-61) then
                      tmp = 1.0d0
                  else if (im <= 3.4d+39) then
                      tmp = (2.0d0 + (im * im)) * (0.5d0 + (re * (re * ((-0.25d0) + ((re * re) * (0.020833333333333332d0 + ((re * re) * (-0.0006944444444444445d0))))))))
                  else
                      tmp = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * (((im * im) * 0.001388888888888889d0) + 0.041666666666666664d0)))))
                  end if
                  code = tmp
              end function
              
              public static double code(double re, double im) {
              	double tmp;
              	if (im <= 3.05e-61) {
              		tmp = 1.0;
              	} else if (im <= 3.4e+39) {
              		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * (-0.25 + ((re * re) * (0.020833333333333332 + ((re * re) * -0.0006944444444444445)))))));
              	} else {
              		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
              	}
              	return tmp;
              }
              
              def code(re, im):
              	tmp = 0
              	if im <= 3.05e-61:
              		tmp = 1.0
              	elif im <= 3.4e+39:
              		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * (-0.25 + ((re * re) * (0.020833333333333332 + ((re * re) * -0.0006944444444444445)))))))
              	else:
              		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))))
              	return tmp
              
              function code(re, im)
              	tmp = 0.0
              	if (im <= 3.05e-61)
              		tmp = 1.0;
              	elseif (im <= 3.4e+39)
              		tmp = Float64(Float64(2.0 + Float64(im * im)) * Float64(0.5 + Float64(re * Float64(re * Float64(-0.25 + Float64(Float64(re * re) * Float64(0.020833333333333332 + Float64(Float64(re * re) * -0.0006944444444444445))))))));
              	else
              		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * Float64(Float64(Float64(im * im) * 0.001388888888888889) + 0.041666666666666664))))));
              	end
              	return tmp
              end
              
              function tmp_2 = code(re, im)
              	tmp = 0.0;
              	if (im <= 3.05e-61)
              		tmp = 1.0;
              	elseif (im <= 3.4e+39)
              		tmp = (2.0 + (im * im)) * (0.5 + (re * (re * (-0.25 + ((re * re) * (0.020833333333333332 + ((re * re) * -0.0006944444444444445)))))));
              	else
              		tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
              	end
              	tmp_2 = tmp;
              end
              
              code[re_, im_] := If[LessEqual[im, 3.05e-61], 1.0, If[LessEqual[im, 3.4e+39], N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(re * N[(re * N[(-0.25 + N[(N[(re * re), $MachinePrecision] * N[(0.020833333333333332 + N[(N[(re * re), $MachinePrecision] * -0.0006944444444444445), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * N[(N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\
              \;\;\;\;1\\
              
              \mathbf{elif}\;im \leq 3.4 \cdot 10^{+39}:\\
              \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot \left(-0.25 + \left(re \cdot re\right) \cdot \left(0.020833333333333332 + \left(re \cdot re\right) \cdot -0.0006944444444444445\right)\right)\right)\right)\\
              
              \mathbf{else}:\\
              \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if im < 3.05e-61

                1. Initial program 100.0%

                  \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                2. Step-by-step derivation
                  1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                  11. exp-negN/A

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

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

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                  15. exp-lowering-exp.f64100.0%

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

                  \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                4. Add Preprocessing
                5. Taylor expanded in im around 0

                  \[\leadsto \color{blue}{\cos re} \]
                6. Step-by-step derivation
                  1. cos-lowering-cos.f6462.6%

                    \[\leadsto \mathsf{cos.f64}\left(re\right) \]
                7. Simplified62.6%

                  \[\leadsto \color{blue}{\cos re} \]
                8. Taylor expanded in re around 0

                  \[\leadsto \color{blue}{1} \]
                9. Step-by-step derivation
                  1. Simplified34.7%

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

                  if 3.05e-61 < im < 3.3999999999999999e39

                  1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left({re}^{2} \cdot \left(\frac{1}{48} + \frac{-1}{1440} \cdot {re}^{2}\right) - \frac{1}{4}\right)\right)\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, im\right)\right)\right) \]
                    6. sub-negN/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left({re}^{2} \cdot \left(\frac{1}{48} + \frac{-1}{1440} \cdot {re}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, im\right)\right)\right) \]
                    7. metadata-evalN/A

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{1}{48}, \mathsf{*.f64}\left(\left({re}^{2}\right), \frac{-1}{1440}\right)\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, im\right)\right)\right) \]
                    16. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{1}{48}, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{-1}{1440}\right)\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, im\right)\right)\right) \]
                    17. *-lowering-*.f6448.2%

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

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

                  if 3.3999999999999999e39 < im

                  1. Initial program 100.0%

                    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                  2. Step-by-step derivation
                    1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                    11. exp-negN/A

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                    15. exp-lowering-exp.f64100.0%

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

                    \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                  4. Add Preprocessing
                  5. Step-by-step derivation
                    1. *-commutativeN/A

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
                    5. distribute-lft-outN/A

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

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

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
                    11. cos-lowering-cos.f64100.0%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                  6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                  12. Simplified76.8%

                    \[\leadsto \color{blue}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)} \]
                10. Recombined 3 regimes into one program.
                11. Final simplification43.7%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\ \;\;\;\;1\\ \mathbf{elif}\;im \leq 3.4 \cdot 10^{+39}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot \left(-0.25 + \left(re \cdot re\right) \cdot \left(0.020833333333333332 + \left(re \cdot re\right) \cdot -0.0006944444444444445\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \end{array} \]
                12. Add Preprocessing

                Alternative 12: 59.0% accurate, 10.6× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \mathbf{if}\;im \leq 26:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 3.4 \cdot 10^{+39}:\\ \;\;\;\;1 + \left(re \cdot re\right) \cdot \left(-0.5 + re \cdot \left(re \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.001388888888888889\right)\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)
                              (+
                               (* (* im im) 0.001388888888888889)
                               0.041666666666666664))))))))
                   (if (<= im 26.0)
                     t_0
                     (if (<= im 3.4e+39)
                       (+
                        1.0
                        (*
                         (* re re)
                         (+
                          -0.5
                          (*
                           re
                           (*
                            re
                            (+ 0.041666666666666664 (* (* re re) -0.001388888888888889)))))))
                       t_0))))
                double code(double re, double im) {
                	double t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
                	double tmp;
                	if (im <= 26.0) {
                		tmp = t_0;
                	} else if (im <= 3.4e+39) {
                		tmp = 1.0 + ((re * re) * (-0.5 + (re * (re * (0.041666666666666664 + ((re * re) * -0.001388888888888889))))));
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                real(8) function code(re, im)
                    real(8), intent (in) :: re
                    real(8), intent (in) :: im
                    real(8) :: t_0
                    real(8) :: tmp
                    t_0 = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * (((im * im) * 0.001388888888888889d0) + 0.041666666666666664d0)))))
                    if (im <= 26.0d0) then
                        tmp = t_0
                    else if (im <= 3.4d+39) then
                        tmp = 1.0d0 + ((re * re) * ((-0.5d0) + (re * (re * (0.041666666666666664d0 + ((re * re) * (-0.001388888888888889d0)))))))
                    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) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
                	double tmp;
                	if (im <= 26.0) {
                		tmp = t_0;
                	} else if (im <= 3.4e+39) {
                		tmp = 1.0 + ((re * re) * (-0.5 + (re * (re * (0.041666666666666664 + ((re * re) * -0.001388888888888889))))));
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(re, im):
                	t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))))
                	tmp = 0
                	if im <= 26.0:
                		tmp = t_0
                	elif im <= 3.4e+39:
                		tmp = 1.0 + ((re * re) * (-0.5 + (re * (re * (0.041666666666666664 + ((re * re) * -0.001388888888888889))))))
                	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) * Float64(Float64(Float64(im * im) * 0.001388888888888889) + 0.041666666666666664))))))
                	tmp = 0.0
                	if (im <= 26.0)
                		tmp = t_0;
                	elseif (im <= 3.4e+39)
                		tmp = Float64(1.0 + Float64(Float64(re * re) * Float64(-0.5 + Float64(re * Float64(re * Float64(0.041666666666666664 + Float64(Float64(re * re) * -0.001388888888888889)))))));
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(re, im)
                	t_0 = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
                	tmp = 0.0;
                	if (im <= 26.0)
                		tmp = t_0;
                	elseif (im <= 3.4e+39)
                		tmp = 1.0 + ((re * re) * (-0.5 + (re * (re * (0.041666666666666664 + ((re * re) * -0.001388888888888889))))));
                	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] * N[(N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 26.0], t$95$0, If[LessEqual[im, 3.4e+39], N[(1.0 + N[(N[(re * re), $MachinePrecision] * N[(-0.5 + N[(re * N[(re * N[(0.041666666666666664 + N[(N[(re * re), $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\
                \mathbf{if}\;im \leq 26:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;im \leq 3.4 \cdot 10^{+39}:\\
                \;\;\;\;1 + \left(re \cdot re\right) \cdot \left(-0.5 + re \cdot \left(re \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.001388888888888889\right)\right)\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if im < 26 or 3.3999999999999999e39 < im

                  1. Initial program 100.0%

                    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                  2. Step-by-step derivation
                    1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                    11. exp-negN/A

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                    15. exp-lowering-exp.f64100.0%

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

                    \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                  4. Add Preprocessing
                  5. Step-by-step derivation
                    1. *-commutativeN/A

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
                    5. distribute-lft-outN/A

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

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

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
                    11. cos-lowering-cos.f64100.0%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                  6. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                  9. Simplified96.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                    14. *-lowering-*.f6462.7%

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                  12. Simplified62.7%

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

                  if 26 < im < 3.3999999999999999e39

                  1. Initial program 100.0%

                    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                  2. Step-by-step derivation
                    1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                    11. exp-negN/A

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

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

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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                    15. exp-lowering-exp.f64100.0%

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

                    \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                  4. Add Preprocessing
                  5. Taylor expanded in im around 0

                    \[\leadsto \color{blue}{\cos re} \]
                  6. Step-by-step derivation
                    1. cos-lowering-cos.f643.6%

                      \[\leadsto \mathsf{cos.f64}\left(re\right) \]
                  7. Simplified3.6%

                    \[\leadsto \color{blue}{\cos re} \]
                  8. Taylor expanded in re around 0

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

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

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

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

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \left(\color{blue}{{re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right)} - \frac{1}{2}\right)\right)\right) \]
                    5. sub-negN/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right) \]
                    6. metadata-evalN/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) + \frac{-1}{2}\right)\right)\right) \]
                    7. +-commutativeN/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \left(\frac{-1}{2} + \color{blue}{{re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right)}\right)\right)\right) \]
                    8. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \color{blue}{\left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right)\right)}\right)\right)\right) \]
                    9. unpow2N/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \left(\left(re \cdot re\right) \cdot \left(\color{blue}{\frac{1}{24}} + \frac{-1}{720} \cdot {re}^{2}\right)\right)\right)\right)\right) \]
                    10. associate-*l*N/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \left(re \cdot \color{blue}{\left(re \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right)\right)}\right)\right)\right)\right) \]
                    11. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\left(re \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right)\right)}\right)\right)\right)\right) \]
                    12. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right)}\right)\right)\right)\right)\right) \]
                    13. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{24}, \color{blue}{\left(\frac{-1}{720} \cdot {re}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
                    14. *-commutativeN/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{24}, \left({re}^{2} \cdot \color{blue}{\frac{-1}{720}}\right)\right)\right)\right)\right)\right)\right) \]
                    15. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\frac{-1}{720}}\right)\right)\right)\right)\right)\right)\right) \]
                    16. unpow2N/A

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{-1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                    17. *-lowering-*.f6441.8%

                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \frac{-1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                  10. Simplified41.8%

                    \[\leadsto \color{blue}{1 + \left(re \cdot re\right) \cdot \left(-0.5 + re \cdot \left(re \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.001388888888888889\right)\right)\right)} \]
                3. Recombined 2 regimes into one program.
                4. Final simplification61.5%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 26:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \mathbf{elif}\;im \leq 3.4 \cdot 10^{+39}:\\ \;\;\;\;1 + \left(re \cdot re\right) \cdot \left(-0.5 + re \cdot \left(re \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.001388888888888889\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right)\\ \end{array} \]
                5. Add Preprocessing

                Alternative 13: 52.1% accurate, 10.6× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00012:\\ \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\ \;\;\;\;\left(im \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(im \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\ \end{array} \end{array} \]
                (FPCore (re im)
                 :precision binary64
                 (if (<= im 0.00012)
                   (* 0.5 (+ 2.0 (* im im)))
                   (if (<= im 4.2e+65)
                     (*
                      (* im (+ 0.5 (* re (* re -0.25))))
                      (* im (+ 1.0 (* im (* im 0.08333333333333333)))))
                     (* 0.5 (* im (* im (* (* im im) 0.08333333333333333)))))))
                double code(double re, double im) {
                	double tmp;
                	if (im <= 0.00012) {
                		tmp = 0.5 * (2.0 + (im * im));
                	} else if (im <= 4.2e+65) {
                		tmp = (im * (0.5 + (re * (re * -0.25)))) * (im * (1.0 + (im * (im * 0.08333333333333333))));
                	} else {
                		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                	}
                	return tmp;
                }
                
                real(8) function code(re, im)
                    real(8), intent (in) :: re
                    real(8), intent (in) :: im
                    real(8) :: tmp
                    if (im <= 0.00012d0) then
                        tmp = 0.5d0 * (2.0d0 + (im * im))
                    else if (im <= 4.2d+65) then
                        tmp = (im * (0.5d0 + (re * (re * (-0.25d0))))) * (im * (1.0d0 + (im * (im * 0.08333333333333333d0))))
                    else
                        tmp = 0.5d0 * (im * (im * ((im * im) * 0.08333333333333333d0)))
                    end if
                    code = tmp
                end function
                
                public static double code(double re, double im) {
                	double tmp;
                	if (im <= 0.00012) {
                		tmp = 0.5 * (2.0 + (im * im));
                	} else if (im <= 4.2e+65) {
                		tmp = (im * (0.5 + (re * (re * -0.25)))) * (im * (1.0 + (im * (im * 0.08333333333333333))));
                	} else {
                		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                	}
                	return tmp;
                }
                
                def code(re, im):
                	tmp = 0
                	if im <= 0.00012:
                		tmp = 0.5 * (2.0 + (im * im))
                	elif im <= 4.2e+65:
                		tmp = (im * (0.5 + (re * (re * -0.25)))) * (im * (1.0 + (im * (im * 0.08333333333333333))))
                	else:
                		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)))
                	return tmp
                
                function code(re, im)
                	tmp = 0.0
                	if (im <= 0.00012)
                		tmp = Float64(0.5 * Float64(2.0 + Float64(im * im)));
                	elseif (im <= 4.2e+65)
                		tmp = Float64(Float64(im * Float64(0.5 + Float64(re * Float64(re * -0.25)))) * Float64(im * Float64(1.0 + Float64(im * Float64(im * 0.08333333333333333)))));
                	else
                		tmp = Float64(0.5 * Float64(im * Float64(im * Float64(Float64(im * im) * 0.08333333333333333))));
                	end
                	return tmp
                end
                
                function tmp_2 = code(re, im)
                	tmp = 0.0;
                	if (im <= 0.00012)
                		tmp = 0.5 * (2.0 + (im * im));
                	elseif (im <= 4.2e+65)
                		tmp = (im * (0.5 + (re * (re * -0.25)))) * (im * (1.0 + (im * (im * 0.08333333333333333))));
                	else
                		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                	end
                	tmp_2 = tmp;
                end
                
                code[re_, im_] := If[LessEqual[im, 0.00012], N[(0.5 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.2e+65], N[(N[(im * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * N[(1.0 + N[(im * N[(im * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;im \leq 0.00012:\\
                \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\
                
                \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\
                \;\;\;\;\left(im \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(im \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 3 regimes
                2. if im < 1.20000000000000003e-4

                  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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                  4. Step-by-step derivation
                    1. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                    2. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                    3. *-lowering-*.f6486.8%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                  5. Simplified86.8%

                    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                  6. Taylor expanded in re around 0

                    \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                  7. Step-by-step derivation
                    1. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                    2. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                    3. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                    4. *-lowering-*.f6450.7%

                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                  8. Simplified50.7%

                    \[\leadsto \color{blue}{0.5 \cdot \left(2 + im \cdot im\right)} \]

                  if 1.20000000000000003e-4 < im < 4.19999999999999983e65

                  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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                  4. Step-by-step derivation
                    1. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                    2. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                    3. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                    4. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                    5. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                    6. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                    7. associate-*r*N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                    8. *-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                    9. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                    10. *-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                    11. *-lowering-*.f645.7%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                  5. Simplified5.7%

                    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                  6. Taylor expanded in re around 0

                    \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)\right) + \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)} \]
                  7. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) + \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)} \]
                    2. associate-*r*N/A

                      \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) + \left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)} \]
                    3. distribute-rgt-outN/A

                      \[\leadsto \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
                    4. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right), \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}\right) \]
                  8. Simplified31.0%

                    \[\leadsto \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
                  9. Taylor expanded in im around inf

                    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left({im}^{4} \cdot \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right)}, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                  10. Step-by-step derivation
                    1. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{4}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    2. metadata-evalN/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{\left(2 \cdot 2\right)}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    3. pow-sqrN/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{2} \cdot {im}^{2}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    4. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\left(im \cdot im\right) \cdot {im}^{2}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    5. associate-*l*N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(im \cdot \left(im \cdot {im}^{2}\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    6. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \left(im \cdot {im}^{2}\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    7. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2}\right)\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    8. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(im \cdot im\right)\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    9. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    10. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \left(\frac{1}{{im}^{2}}\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    11. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \mathsf{/.f64}\left(1, \left({im}^{2}\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    12. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \mathsf{/.f64}\left(1, \left(im \cdot im\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    13. *-lowering-*.f6431.0%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                  11. Simplified31.0%

                    \[\leadsto \color{blue}{\left(\left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot \left(0.08333333333333333 + \frac{1}{im \cdot im}\right)\right)} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
                  12. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto \left(\frac{1}{2} + \frac{-1}{4} \cdot \left(re \cdot re\right)\right) \cdot \color{blue}{\left(\left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot \left(\frac{1}{12} + \frac{1}{im \cdot im}\right)\right)} \]
                    2. *-commutativeN/A

                      \[\leadsto \left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot \left(\left(im \cdot \color{blue}{\left(im \cdot \left(im \cdot im\right)\right)}\right) \cdot \left(\frac{1}{12} + \frac{1}{im \cdot im}\right)\right) \]
                    3. associate-*l*N/A

                      \[\leadsto \left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot \left(im \cdot \color{blue}{\left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(\frac{1}{12} + \frac{1}{im \cdot im}\right)\right)}\right) \]
                    4. associate-*r*N/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \color{blue}{\left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(\frac{1}{12} + \frac{1}{im \cdot im}\right)\right)} \]
                    5. +-commutativeN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(\frac{1}{im \cdot im} + \color{blue}{\frac{1}{12}}\right)\right) \]
                    6. distribute-lft-inN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \frac{1}{im \cdot im} + \color{blue}{\left(im \cdot \left(im \cdot im\right)\right) \cdot \frac{1}{12}}\right) \]
                    7. cube-unmultN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left({im}^{3} \cdot \frac{1}{im \cdot im} + \left(\color{blue}{im} \cdot \left(im \cdot im\right)\right) \cdot \frac{1}{12}\right) \]
                    8. inv-powN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left({im}^{3} \cdot {\left(im \cdot im\right)}^{-1} + \left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot \frac{1}{12}\right) \]
                    9. pow2N/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left({im}^{3} \cdot {\left({im}^{2}\right)}^{-1} + \left(im \cdot \left(\color{blue}{im} \cdot im\right)\right) \cdot \frac{1}{12}\right) \]
                    10. pow-powN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left({im}^{3} \cdot {im}^{\left(2 \cdot -1\right)} + \left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot \frac{1}{12}\right) \]
                    11. pow-prod-upN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left({im}^{\left(3 + 2 \cdot -1\right)} + \color{blue}{\left(im \cdot \left(im \cdot im\right)\right)} \cdot \frac{1}{12}\right) \]
                    12. metadata-evalN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left({im}^{\left(3 + -2\right)} + \left(im \cdot \left(im \cdot \color{blue}{im}\right)\right) \cdot \frac{1}{12}\right) \]
                    13. metadata-evalN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left({im}^{1} + \left(im \cdot \color{blue}{\left(im \cdot im\right)}\right) \cdot \frac{1}{12}\right) \]
                    14. unpow1N/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left(im + \color{blue}{\left(im \cdot \left(im \cdot im\right)\right)} \cdot \frac{1}{12}\right) \]
                    15. *-rgt-identityN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left(im \cdot 1 + \color{blue}{\left(im \cdot \left(im \cdot im\right)\right)} \cdot \frac{1}{12}\right) \]
                    16. associate-*r*N/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left(im \cdot 1 + im \cdot \color{blue}{\left(\left(im \cdot im\right) \cdot \frac{1}{12}\right)}\right) \]
                    17. distribute-lft-inN/A

                      \[\leadsto \left(\left(\frac{1}{2} + \left(re \cdot re\right) \cdot \frac{-1}{4}\right) \cdot im\right) \cdot \left(im \cdot \color{blue}{\left(1 + \left(im \cdot im\right) \cdot \frac{1}{12}\right)}\right) \]
                  13. Applied egg-rr31.0%

                    \[\leadsto \color{blue}{\left(\left(0.5 + re \cdot \left(re \cdot -0.25\right)\right) \cdot im\right) \cdot \left(im \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]

                  if 4.19999999999999983e65 < 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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                  4. Step-by-step derivation
                    1. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                    2. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                    3. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                    4. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                    5. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                    6. unpow2N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                    7. associate-*r*N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                    8. *-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                    9. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                    10. *-commutativeN/A

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                    11. *-lowering-*.f6497.7%

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                  5. Simplified97.7%

                    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                  6. Taylor expanded in re around 0

                    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \frac{1}{12}\right)\right)\right)\right)\right)\right) \]
                  7. Step-by-step derivation
                    1. Simplified80.7%

                      \[\leadsto \color{blue}{0.5} \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \]
                    2. Taylor expanded in im around inf

                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{12} \cdot {im}^{4}\right)}\right) \]
                    3. Step-by-step derivation
                      1. metadata-evalN/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot {im}^{\left(2 \cdot \color{blue}{2}\right)}\right)\right) \]
                      2. pow-sqrN/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot \left({im}^{2} \cdot \color{blue}{{im}^{2}}\right)\right)\right) \]
                      3. associate-*l*N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(\frac{1}{12} \cdot {im}^{2}\right) \cdot \color{blue}{{im}^{2}}\right)\right) \]
                      4. *-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right) \]
                      5. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{12}} \cdot {im}^{2}\right)\right)\right) \]
                      6. associate-*l*N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                      7. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                      8. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                      9. *-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                      10. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                      11. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{12}\right)\right)\right)\right) \]
                      12. *-lowering-*.f6480.7%

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right) \]
                    4. Simplified80.7%

                      \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)} \]
                  8. Recombined 3 regimes into one program.
                  9. Final simplification53.8%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.00012:\\ \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\ \;\;\;\;\left(im \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\right) \cdot \left(im \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\ \end{array} \]
                  10. Add Preprocessing

                  Alternative 14: 52.1% accurate, 12.3× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00012:\\ \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\ \;\;\;\;\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.020833333333333332\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\ \end{array} \end{array} \]
                  (FPCore (re im)
                   :precision binary64
                   (if (<= im 0.00012)
                     (* 0.5 (+ 2.0 (* im im)))
                     (if (<= im 4.2e+65)
                       (*
                        (* (* im im) (* im im))
                        (+ 0.041666666666666664 (* (* re re) -0.020833333333333332)))
                       (* 0.5 (* im (* im (* (* im im) 0.08333333333333333)))))))
                  double code(double re, double im) {
                  	double tmp;
                  	if (im <= 0.00012) {
                  		tmp = 0.5 * (2.0 + (im * im));
                  	} else if (im <= 4.2e+65) {
                  		tmp = ((im * im) * (im * im)) * (0.041666666666666664 + ((re * re) * -0.020833333333333332));
                  	} else {
                  		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                  	}
                  	return tmp;
                  }
                  
                  real(8) function code(re, im)
                      real(8), intent (in) :: re
                      real(8), intent (in) :: im
                      real(8) :: tmp
                      if (im <= 0.00012d0) then
                          tmp = 0.5d0 * (2.0d0 + (im * im))
                      else if (im <= 4.2d+65) then
                          tmp = ((im * im) * (im * im)) * (0.041666666666666664d0 + ((re * re) * (-0.020833333333333332d0)))
                      else
                          tmp = 0.5d0 * (im * (im * ((im * im) * 0.08333333333333333d0)))
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double re, double im) {
                  	double tmp;
                  	if (im <= 0.00012) {
                  		tmp = 0.5 * (2.0 + (im * im));
                  	} else if (im <= 4.2e+65) {
                  		tmp = ((im * im) * (im * im)) * (0.041666666666666664 + ((re * re) * -0.020833333333333332));
                  	} else {
                  		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                  	}
                  	return tmp;
                  }
                  
                  def code(re, im):
                  	tmp = 0
                  	if im <= 0.00012:
                  		tmp = 0.5 * (2.0 + (im * im))
                  	elif im <= 4.2e+65:
                  		tmp = ((im * im) * (im * im)) * (0.041666666666666664 + ((re * re) * -0.020833333333333332))
                  	else:
                  		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)))
                  	return tmp
                  
                  function code(re, im)
                  	tmp = 0.0
                  	if (im <= 0.00012)
                  		tmp = Float64(0.5 * Float64(2.0 + Float64(im * im)));
                  	elseif (im <= 4.2e+65)
                  		tmp = Float64(Float64(Float64(im * im) * Float64(im * im)) * Float64(0.041666666666666664 + Float64(Float64(re * re) * -0.020833333333333332)));
                  	else
                  		tmp = Float64(0.5 * Float64(im * Float64(im * Float64(Float64(im * im) * 0.08333333333333333))));
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(re, im)
                  	tmp = 0.0;
                  	if (im <= 0.00012)
                  		tmp = 0.5 * (2.0 + (im * im));
                  	elseif (im <= 4.2e+65)
                  		tmp = ((im * im) * (im * im)) * (0.041666666666666664 + ((re * re) * -0.020833333333333332));
                  	else
                  		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[re_, im_] := If[LessEqual[im, 0.00012], N[(0.5 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.2e+65], N[(N[(N[(im * im), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(0.041666666666666664 + N[(N[(re * re), $MachinePrecision] * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;im \leq 0.00012:\\
                  \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\
                  
                  \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\
                  \;\;\;\;\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.020833333333333332\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if im < 1.20000000000000003e-4

                    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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                    4. Step-by-step derivation
                      1. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                      2. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                      3. *-lowering-*.f6486.8%

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                    5. Simplified86.8%

                      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                    6. Taylor expanded in re around 0

                      \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                    7. Step-by-step derivation
                      1. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                      2. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                      3. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                      4. *-lowering-*.f6450.7%

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                    8. Simplified50.7%

                      \[\leadsto \color{blue}{0.5 \cdot \left(2 + im \cdot im\right)} \]

                    if 1.20000000000000003e-4 < im < 4.19999999999999983e65

                    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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                    4. Step-by-step derivation
                      1. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                      2. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                      3. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                      4. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                      5. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                      6. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                      7. associate-*r*N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                      8. *-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                      9. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                      10. *-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                      11. *-lowering-*.f645.7%

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                    5. Simplified5.7%

                      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                    6. Taylor expanded in re around 0

                      \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)\right) + \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)} \]
                    7. Step-by-step derivation
                      1. +-commutativeN/A

                        \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) + \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)} \]
                      2. associate-*r*N/A

                        \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) + \left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)} \]
                      3. distribute-rgt-outN/A

                        \[\leadsto \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
                      4. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right), \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}\right) \]
                    8. Simplified31.0%

                      \[\leadsto \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
                    9. Taylor expanded in im around inf

                      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left({im}^{4} \cdot \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right)}, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    10. Step-by-step derivation
                      1. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{4}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      2. metadata-evalN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{\left(2 \cdot 2\right)}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      3. pow-sqrN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{2} \cdot {im}^{2}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      4. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\left(im \cdot im\right) \cdot {im}^{2}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      5. associate-*l*N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(im \cdot \left(im \cdot {im}^{2}\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      6. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \left(im \cdot {im}^{2}\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      7. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2}\right)\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      8. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(im \cdot im\right)\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      9. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      10. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \left(\frac{1}{{im}^{2}}\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      11. /-lowering-/.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \mathsf{/.f64}\left(1, \left({im}^{2}\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      12. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \mathsf{/.f64}\left(1, \left(im \cdot im\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                      13. *-lowering-*.f6431.0%

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                    11. Simplified31.0%

                      \[\leadsto \color{blue}{\left(\left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot \left(0.08333333333333333 + \frac{1}{im \cdot im}\right)\right)} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
                    12. Taylor expanded in im around inf

                      \[\leadsto \color{blue}{\frac{1}{12} \cdot \left({im}^{4} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)} \]
                    13. Step-by-step derivation
                      1. associate-*r*N/A

                        \[\leadsto \left(\frac{1}{12} \cdot {im}^{4}\right) \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
                      2. *-commutativeN/A

                        \[\leadsto \left({im}^{4} \cdot \frac{1}{12}\right) \cdot \left(\color{blue}{\frac{1}{2}} + \frac{-1}{4} \cdot {re}^{2}\right) \]
                      3. associate-*l*N/A

                        \[\leadsto {im}^{4} \cdot \color{blue}{\left(\frac{1}{12} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)} \]
                      4. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\left({im}^{4}\right), \color{blue}{\left(\frac{1}{12} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)}\right) \]
                      5. metadata-evalN/A

                        \[\leadsto \mathsf{*.f64}\left(\left({im}^{\left(2 \cdot 2\right)}\right), \left(\frac{1}{12} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
                      6. pow-sqrN/A

                        \[\leadsto \mathsf{*.f64}\left(\left({im}^{2} \cdot {im}^{2}\right), \left(\color{blue}{\frac{1}{12}} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
                      7. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{2}\right), \left({im}^{2}\right)\right), \left(\color{blue}{\frac{1}{12}} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
                      8. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(im \cdot im\right), \left({im}^{2}\right)\right), \left(\frac{1}{12} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
                      9. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2}\right)\right), \left(\frac{1}{12} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
                      10. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(im \cdot im\right)\right), \left(\frac{1}{12} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
                      11. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \left(\frac{1}{12} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
                      12. distribute-lft-inN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \left(\frac{1}{12} \cdot \frac{1}{2} + \color{blue}{\frac{1}{12} \cdot \left(\frac{-1}{4} \cdot {re}^{2}\right)}\right)\right) \]
                      13. metadata-evalN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \left(\frac{1}{24} + \color{blue}{\frac{1}{12}} \cdot \left(\frac{-1}{4} \cdot {re}^{2}\right)\right)\right) \]
                      14. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \color{blue}{\left(\frac{1}{12} \cdot \left(\frac{-1}{4} \cdot {re}^{2}\right)\right)}\right)\right) \]
                      15. *-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \color{blue}{\frac{1}{12}}\right)\right)\right) \]
                      16. *-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\left({re}^{2} \cdot \frac{-1}{4}\right) \cdot \frac{1}{12}\right)\right)\right) \]
                      17. associate-*l*N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \left({re}^{2} \cdot \color{blue}{\left(\frac{-1}{4} \cdot \frac{1}{12}\right)}\right)\right)\right) \]
                      18. metadata-evalN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \left({re}^{2} \cdot \frac{-1}{48}\right)\right)\right) \]
                      19. metadata-evalN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \left({re}^{2} \cdot \left(\frac{1}{12} \cdot \color{blue}{\frac{-1}{4}}\right)\right)\right)\right) \]
                      20. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\left(\frac{1}{12} \cdot \frac{-1}{4}\right)}\right)\right)\right) \]
                      21. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(re \cdot re\right), \left(\color{blue}{\frac{1}{12}} \cdot \frac{-1}{4}\right)\right)\right)\right) \]
                      22. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \left(\color{blue}{\frac{1}{12}} \cdot \frac{-1}{4}\right)\right)\right)\right) \]
                      23. metadata-eval30.9%

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \frac{-1}{48}\right)\right)\right) \]
                    14. Simplified30.9%

                      \[\leadsto \color{blue}{\left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right) \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.020833333333333332\right)} \]

                    if 4.19999999999999983e65 < 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

                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                    4. Step-by-step derivation
                      1. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                      2. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                      3. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                      4. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                      5. +-lowering-+.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                      6. unpow2N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                      7. associate-*r*N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                      8. *-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                      9. *-lowering-*.f64N/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                      10. *-commutativeN/A

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                      11. *-lowering-*.f6497.7%

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                    5. Simplified97.7%

                      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                    6. Taylor expanded in re around 0

                      \[\leadsto \mathsf{*.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \frac{1}{12}\right)\right)\right)\right)\right)\right) \]
                    7. Step-by-step derivation
                      1. Simplified80.7%

                        \[\leadsto \color{blue}{0.5} \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \]
                      2. Taylor expanded in im around inf

                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{12} \cdot {im}^{4}\right)}\right) \]
                      3. Step-by-step derivation
                        1. metadata-evalN/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot {im}^{\left(2 \cdot \color{blue}{2}\right)}\right)\right) \]
                        2. pow-sqrN/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot \left({im}^{2} \cdot \color{blue}{{im}^{2}}\right)\right)\right) \]
                        3. associate-*l*N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(\frac{1}{12} \cdot {im}^{2}\right) \cdot \color{blue}{{im}^{2}}\right)\right) \]
                        4. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right) \]
                        5. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{12}} \cdot {im}^{2}\right)\right)\right) \]
                        6. associate-*l*N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                        7. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                        8. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                        9. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                        10. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                        11. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{12}\right)\right)\right)\right) \]
                        12. *-lowering-*.f6480.7%

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right) \]
                      4. Simplified80.7%

                        \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)} \]
                    8. Recombined 3 regimes into one program.
                    9. Add Preprocessing

                    Alternative 15: 52.1% accurate, 12.3× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00012:\\ \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(0.041666666666666664 + re \cdot \left(re \cdot -0.020833333333333332\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\ \end{array} \end{array} \]
                    (FPCore (re im)
                     :precision binary64
                     (if (<= im 0.00012)
                       (* 0.5 (+ 2.0 (* im im)))
                       (if (<= im 4.2e+65)
                         (*
                          (* im im)
                          (*
                           (* im im)
                           (+ 0.041666666666666664 (* re (* re -0.020833333333333332)))))
                         (* 0.5 (* im (* im (* (* im im) 0.08333333333333333)))))))
                    double code(double re, double im) {
                    	double tmp;
                    	if (im <= 0.00012) {
                    		tmp = 0.5 * (2.0 + (im * im));
                    	} else if (im <= 4.2e+65) {
                    		tmp = (im * im) * ((im * im) * (0.041666666666666664 + (re * (re * -0.020833333333333332))));
                    	} else {
                    		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                    	}
                    	return tmp;
                    }
                    
                    real(8) function code(re, im)
                        real(8), intent (in) :: re
                        real(8), intent (in) :: im
                        real(8) :: tmp
                        if (im <= 0.00012d0) then
                            tmp = 0.5d0 * (2.0d0 + (im * im))
                        else if (im <= 4.2d+65) then
                            tmp = (im * im) * ((im * im) * (0.041666666666666664d0 + (re * (re * (-0.020833333333333332d0)))))
                        else
                            tmp = 0.5d0 * (im * (im * ((im * im) * 0.08333333333333333d0)))
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double re, double im) {
                    	double tmp;
                    	if (im <= 0.00012) {
                    		tmp = 0.5 * (2.0 + (im * im));
                    	} else if (im <= 4.2e+65) {
                    		tmp = (im * im) * ((im * im) * (0.041666666666666664 + (re * (re * -0.020833333333333332))));
                    	} else {
                    		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                    	}
                    	return tmp;
                    }
                    
                    def code(re, im):
                    	tmp = 0
                    	if im <= 0.00012:
                    		tmp = 0.5 * (2.0 + (im * im))
                    	elif im <= 4.2e+65:
                    		tmp = (im * im) * ((im * im) * (0.041666666666666664 + (re * (re * -0.020833333333333332))))
                    	else:
                    		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)))
                    	return tmp
                    
                    function code(re, im)
                    	tmp = 0.0
                    	if (im <= 0.00012)
                    		tmp = Float64(0.5 * Float64(2.0 + Float64(im * im)));
                    	elseif (im <= 4.2e+65)
                    		tmp = Float64(Float64(im * im) * Float64(Float64(im * im) * Float64(0.041666666666666664 + Float64(re * Float64(re * -0.020833333333333332)))));
                    	else
                    		tmp = Float64(0.5 * Float64(im * Float64(im * Float64(Float64(im * im) * 0.08333333333333333))));
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(re, im)
                    	tmp = 0.0;
                    	if (im <= 0.00012)
                    		tmp = 0.5 * (2.0 + (im * im));
                    	elseif (im <= 4.2e+65)
                    		tmp = (im * im) * ((im * im) * (0.041666666666666664 + (re * (re * -0.020833333333333332))));
                    	else
                    		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[re_, im_] := If[LessEqual[im, 0.00012], N[(0.5 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.2e+65], N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(0.041666666666666664 + N[(re * N[(re * -0.020833333333333332), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;im \leq 0.00012:\\
                    \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\
                    
                    \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\
                    \;\;\;\;\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(0.041666666666666664 + re \cdot \left(re \cdot -0.020833333333333332\right)\right)\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 3 regimes
                    2. if im < 1.20000000000000003e-4

                      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

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                      4. Step-by-step derivation
                        1. +-lowering-+.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                        2. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                        3. *-lowering-*.f6486.8%

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                      5. Simplified86.8%

                        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                      6. Taylor expanded in re around 0

                        \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                      7. Step-by-step derivation
                        1. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                        2. +-lowering-+.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                        3. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                        4. *-lowering-*.f6450.7%

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                      8. Simplified50.7%

                        \[\leadsto \color{blue}{0.5 \cdot \left(2 + im \cdot im\right)} \]

                      if 1.20000000000000003e-4 < im < 4.19999999999999983e65

                      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

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                      4. Step-by-step derivation
                        1. +-lowering-+.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                        2. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                        3. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                        4. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                        5. +-lowering-+.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                        6. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                        7. associate-*r*N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                        8. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                        9. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                        10. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                        11. *-lowering-*.f645.7%

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                      5. Simplified5.7%

                        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                      6. Taylor expanded in re around 0

                        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)\right) + \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)} \]
                      7. Step-by-step derivation
                        1. +-commutativeN/A

                          \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) + \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)} \]
                        2. associate-*r*N/A

                          \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) + \left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)} \]
                        3. distribute-rgt-outN/A

                          \[\leadsto \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
                        4. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right), \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}\right) \]
                      8. Simplified31.0%

                        \[\leadsto \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
                      9. Taylor expanded in im around inf

                        \[\leadsto \color{blue}{\frac{1}{12} \cdot \left({im}^{4} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)} \]
                      10. Step-by-step derivation
                        1. associate-*r*N/A

                          \[\leadsto \left(\frac{1}{12} \cdot {im}^{4}\right) \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
                        2. metadata-evalN/A

                          \[\leadsto \left(\frac{1}{12} \cdot {im}^{\left(2 \cdot 2\right)}\right) \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right) \]
                        3. pow-sqrN/A

                          \[\leadsto \left(\frac{1}{12} \cdot \left({im}^{2} \cdot {im}^{2}\right)\right) \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right) \]
                        4. associate-*l*N/A

                          \[\leadsto \left(\left(\frac{1}{12} \cdot {im}^{2}\right) \cdot {im}^{2}\right) \cdot \left(\color{blue}{\frac{1}{2}} + \frac{-1}{4} \cdot {re}^{2}\right) \]
                        5. *-commutativeN/A

                          \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right) \cdot \left(\color{blue}{\frac{1}{2}} + \frac{-1}{4} \cdot {re}^{2}\right) \]
                        6. associate-*r*N/A

                          \[\leadsto {im}^{2} \cdot \color{blue}{\left(\left(\frac{1}{12} \cdot {im}^{2}\right) \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)} \]
                        7. associate-*r*N/A

                          \[\leadsto {im}^{2} \cdot \left(\frac{1}{12} \cdot \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)}\right) \]
                        8. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{1}{12} \cdot \left({im}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right)}\right) \]
                        9. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{1}{12}} \cdot \left({im}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right)\right) \]
                        10. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{1}{12}} \cdot \left({im}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right)\right) \]
                        11. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\left({im}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \cdot \color{blue}{\frac{1}{12}}\right)\right) \]
                        12. associate-*l*N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \color{blue}{\left(\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right) \cdot \frac{1}{12}\right)}\right)\right) \]
                        13. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left({im}^{2} \cdot \left(\frac{1}{12} \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}\right)\right)\right) \]
                        14. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{1}{12} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)}\right)\right) \]
                        15. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{1}{12}} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right)\right) \]
                        16. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{1}{12}} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right)\right)\right) \]
                        17. distribute-rgt-inN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{1}{2} \cdot \frac{1}{12} + \color{blue}{\left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \frac{1}{12}}\right)\right)\right) \]
                        18. metadata-evalN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{1}{24} + \color{blue}{\left(\frac{-1}{4} \cdot {re}^{2}\right)} \cdot \frac{1}{12}\right)\right)\right) \]
                        19. +-lowering-+.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \color{blue}{\left(\left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \frac{1}{12}\right)}\right)\right)\right) \]
                        20. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\frac{1}{12} \cdot \color{blue}{\left(\frac{-1}{4} \cdot {re}^{2}\right)}\right)\right)\right)\right) \]
                        21. associate-*r*N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\left(\frac{1}{12} \cdot \frac{-1}{4}\right) \cdot \color{blue}{{re}^{2}}\right)\right)\right)\right) \]
                        22. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \left({re}^{2} \cdot \color{blue}{\left(\frac{1}{12} \cdot \frac{-1}{4}\right)}\right)\right)\right)\right) \]
                        23. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\left(re \cdot re\right) \cdot \left(\color{blue}{\frac{1}{12}} \cdot \frac{-1}{4}\right)\right)\right)\right)\right) \]
                        24. associate-*l*N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(re \cdot \color{blue}{\left(re \cdot \left(\frac{1}{12} \cdot \frac{-1}{4}\right)\right)}\right)\right)\right)\right) \]
                        25. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(re, \color{blue}{\left(re \cdot \left(\frac{1}{12} \cdot \frac{-1}{4}\right)\right)}\right)\right)\right)\right) \]
                      11. Simplified30.9%

                        \[\leadsto \color{blue}{\left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(0.041666666666666664 + re \cdot \left(re \cdot -0.020833333333333332\right)\right)\right)} \]

                      if 4.19999999999999983e65 < 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

                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                      4. Step-by-step derivation
                        1. +-lowering-+.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                        2. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                        3. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                        4. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                        5. +-lowering-+.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                        6. unpow2N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                        7. associate-*r*N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                        8. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                        9. *-lowering-*.f64N/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                        10. *-commutativeN/A

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                        11. *-lowering-*.f6497.7%

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                      5. Simplified97.7%

                        \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                      6. Taylor expanded in re around 0

                        \[\leadsto \mathsf{*.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \frac{1}{12}\right)\right)\right)\right)\right)\right) \]
                      7. Step-by-step derivation
                        1. Simplified80.7%

                          \[\leadsto \color{blue}{0.5} \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \]
                        2. Taylor expanded in im around inf

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{12} \cdot {im}^{4}\right)}\right) \]
                        3. Step-by-step derivation
                          1. metadata-evalN/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot {im}^{\left(2 \cdot \color{blue}{2}\right)}\right)\right) \]
                          2. pow-sqrN/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot \left({im}^{2} \cdot \color{blue}{{im}^{2}}\right)\right)\right) \]
                          3. associate-*l*N/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(\frac{1}{12} \cdot {im}^{2}\right) \cdot \color{blue}{{im}^{2}}\right)\right) \]
                          4. *-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right) \]
                          5. unpow2N/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{12}} \cdot {im}^{2}\right)\right)\right) \]
                          6. associate-*l*N/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                          7. *-lowering-*.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                          8. *-lowering-*.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                          9. *-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                          10. *-lowering-*.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                          11. unpow2N/A

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{12}\right)\right)\right)\right) \]
                          12. *-lowering-*.f6480.7%

                            \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right) \]
                        4. Simplified80.7%

                          \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)} \]
                      8. Recombined 3 regimes into one program.
                      9. Add Preprocessing

                      Alternative 16: 43.3% accurate, 13.4× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\ \;\;\;\;1\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\ \end{array} \end{array} \]
                      (FPCore (re im)
                       :precision binary64
                       (if (<= im 3.05e-61)
                         1.0
                         (if (<= im 4.2e+65)
                           (* (+ 2.0 (* im im)) (+ 0.5 (* (* re re) -0.25)))
                           (* 0.5 (* im (* im (* (* im im) 0.08333333333333333)))))))
                      double code(double re, double im) {
                      	double tmp;
                      	if (im <= 3.05e-61) {
                      		tmp = 1.0;
                      	} else if (im <= 4.2e+65) {
                      		tmp = (2.0 + (im * im)) * (0.5 + ((re * re) * -0.25));
                      	} else {
                      		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                      	}
                      	return tmp;
                      }
                      
                      real(8) function code(re, im)
                          real(8), intent (in) :: re
                          real(8), intent (in) :: im
                          real(8) :: tmp
                          if (im <= 3.05d-61) then
                              tmp = 1.0d0
                          else if (im <= 4.2d+65) then
                              tmp = (2.0d0 + (im * im)) * (0.5d0 + ((re * re) * (-0.25d0)))
                          else
                              tmp = 0.5d0 * (im * (im * ((im * im) * 0.08333333333333333d0)))
                          end if
                          code = tmp
                      end function
                      
                      public static double code(double re, double im) {
                      	double tmp;
                      	if (im <= 3.05e-61) {
                      		tmp = 1.0;
                      	} else if (im <= 4.2e+65) {
                      		tmp = (2.0 + (im * im)) * (0.5 + ((re * re) * -0.25));
                      	} else {
                      		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                      	}
                      	return tmp;
                      }
                      
                      def code(re, im):
                      	tmp = 0
                      	if im <= 3.05e-61:
                      		tmp = 1.0
                      	elif im <= 4.2e+65:
                      		tmp = (2.0 + (im * im)) * (0.5 + ((re * re) * -0.25))
                      	else:
                      		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)))
                      	return tmp
                      
                      function code(re, im)
                      	tmp = 0.0
                      	if (im <= 3.05e-61)
                      		tmp = 1.0;
                      	elseif (im <= 4.2e+65)
                      		tmp = Float64(Float64(2.0 + Float64(im * im)) * Float64(0.5 + Float64(Float64(re * re) * -0.25)));
                      	else
                      		tmp = Float64(0.5 * Float64(im * Float64(im * Float64(Float64(im * im) * 0.08333333333333333))));
                      	end
                      	return tmp
                      end
                      
                      function tmp_2 = code(re, im)
                      	tmp = 0.0;
                      	if (im <= 3.05e-61)
                      		tmp = 1.0;
                      	elseif (im <= 4.2e+65)
                      		tmp = (2.0 + (im * im)) * (0.5 + ((re * re) * -0.25));
                      	else
                      		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                      	end
                      	tmp_2 = tmp;
                      end
                      
                      code[re_, im_] := If[LessEqual[im, 3.05e-61], 1.0, If[LessEqual[im, 4.2e+65], N[(N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\
                      \;\;\;\;1\\
                      
                      \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\
                      \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 3 regimes
                      2. if im < 3.05e-61

                        1. Initial program 100.0%

                          \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                        2. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \left(\cos re \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} + e^{im}\right) \]
                          2. associate-*l*N/A

                            \[\leadsto \cos re \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)} \]
                          3. *-lowering-*.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\cos re, \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)}\right) \]
                          4. cos-lowering-cos.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{\frac{1}{2}} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)\right) \]
                          5. +-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\frac{1}{2} \cdot \left(e^{im} + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
                          6. distribute-rgt-inN/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(e^{im} \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}}\right)\right) \]
                          7. +-lowering-+.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{1}{2}\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right)\right) \]
                          8. *-commutativeN/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot e^{im}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                          9. *-lowering-*.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(e^{im}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                          10. exp-lowering-exp.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                          11. exp-negN/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right)\right) \]
                          12. associate-*l/N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right)\right) \]
                          13. metadata-evalN/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right)\right) \]
                          14. /-lowering-/.f64N/A

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                          15. exp-lowering-exp.f64100.0%

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
                        3. Simplified100.0%

                          \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                        4. Add Preprocessing
                        5. Taylor expanded in im around 0

                          \[\leadsto \color{blue}{\cos re} \]
                        6. Step-by-step derivation
                          1. cos-lowering-cos.f6462.6%

                            \[\leadsto \mathsf{cos.f64}\left(re\right) \]
                        7. Simplified62.6%

                          \[\leadsto \color{blue}{\cos re} \]
                        8. Taylor expanded in re around 0

                          \[\leadsto \color{blue}{1} \]
                        9. Step-by-step derivation
                          1. Simplified34.7%

                            \[\leadsto \color{blue}{1} \]

                          if 3.05e-61 < im < 4.19999999999999983e65

                          1. Initial program 99.9%

                            \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                          2. Add Preprocessing
                          3. Taylor expanded in im around 0

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                          4. Step-by-step derivation
                            1. +-lowering-+.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                            2. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                            3. *-lowering-*.f6430.1%

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                          5. Simplified30.1%

                            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                          6. Taylor expanded in re around 0

                            \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2}\right)\right) + \frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                          7. Step-by-step derivation
                            1. +-commutativeN/A

                              \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2}\right) + \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2}\right)\right)} \]
                            2. associate-*r*N/A

                              \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2}\right) + \left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \color{blue}{\left(2 + {im}^{2}\right)} \]
                            3. distribute-rgt-outN/A

                              \[\leadsto \left(2 + {im}^{2}\right) \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
                            4. *-lowering-*.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\left(2 + {im}^{2}\right), \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}\right) \]
                            5. +-lowering-+.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(2, \left({im}^{2}\right)\right), \left(\color{blue}{\frac{1}{2}} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
                            6. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(2, \left(im \cdot im\right)\right), \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
                            7. *-lowering-*.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, im\right)\right), \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
                            8. +-lowering-+.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{-1}{4} \cdot {re}^{2}\right)}\right)\right) \]
                            9. *-lowering-*.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \color{blue}{\left({re}^{2}\right)}\right)\right)\right) \]
                            10. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \left(re \cdot \color{blue}{re}\right)\right)\right)\right) \]
                            11. *-lowering-*.f6439.3%

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right)\right) \]
                          8. Simplified39.3%

                            \[\leadsto \color{blue}{\left(2 + im \cdot im\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]

                          if 4.19999999999999983e65 < 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

                            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                          4. Step-by-step derivation
                            1. +-lowering-+.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                            2. *-lowering-*.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                            3. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                            4. *-lowering-*.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                            5. +-lowering-+.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                            6. unpow2N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                            7. associate-*r*N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                            8. *-commutativeN/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                            9. *-lowering-*.f64N/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                            10. *-commutativeN/A

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                            11. *-lowering-*.f6497.7%

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                          5. Simplified97.7%

                            \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                          6. Taylor expanded in re around 0

                            \[\leadsto \mathsf{*.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \frac{1}{12}\right)\right)\right)\right)\right)\right) \]
                          7. Step-by-step derivation
                            1. Simplified80.7%

                              \[\leadsto \color{blue}{0.5} \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \]
                            2. Taylor expanded in im around inf

                              \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{12} \cdot {im}^{4}\right)}\right) \]
                            3. Step-by-step derivation
                              1. metadata-evalN/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot {im}^{\left(2 \cdot \color{blue}{2}\right)}\right)\right) \]
                              2. pow-sqrN/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot \left({im}^{2} \cdot \color{blue}{{im}^{2}}\right)\right)\right) \]
                              3. associate-*l*N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(\frac{1}{12} \cdot {im}^{2}\right) \cdot \color{blue}{{im}^{2}}\right)\right) \]
                              4. *-commutativeN/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right) \]
                              5. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{12}} \cdot {im}^{2}\right)\right)\right) \]
                              6. associate-*l*N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                              7. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                              8. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                              9. *-commutativeN/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                              10. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                              11. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{12}\right)\right)\right)\right) \]
                              12. *-lowering-*.f6480.7%

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right) \]
                            4. Simplified80.7%

                              \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)} \]
                          8. Recombined 3 regimes into one program.
                          9. Final simplification42.6%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 3.05 \cdot 10^{-61}:\\ \;\;\;\;1\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\ \;\;\;\;\left(2 + im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\ \end{array} \]
                          10. Add Preprocessing

                          Alternative 17: 52.0% accurate, 14.6× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00012:\\ \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\ \end{array} \end{array} \]
                          (FPCore (re im)
                           :precision binary64
                           (if (<= im 0.00012)
                             (* 0.5 (+ 2.0 (* im im)))
                             (if (<= im 4.2e+65)
                               (* (* im im) (+ 0.5 (* re (* re -0.25))))
                               (* 0.5 (* im (* im (* (* im im) 0.08333333333333333)))))))
                          double code(double re, double im) {
                          	double tmp;
                          	if (im <= 0.00012) {
                          		tmp = 0.5 * (2.0 + (im * im));
                          	} else if (im <= 4.2e+65) {
                          		tmp = (im * im) * (0.5 + (re * (re * -0.25)));
                          	} else {
                          		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                          	}
                          	return tmp;
                          }
                          
                          real(8) function code(re, im)
                              real(8), intent (in) :: re
                              real(8), intent (in) :: im
                              real(8) :: tmp
                              if (im <= 0.00012d0) then
                                  tmp = 0.5d0 * (2.0d0 + (im * im))
                              else if (im <= 4.2d+65) then
                                  tmp = (im * im) * (0.5d0 + (re * (re * (-0.25d0))))
                              else
                                  tmp = 0.5d0 * (im * (im * ((im * im) * 0.08333333333333333d0)))
                              end if
                              code = tmp
                          end function
                          
                          public static double code(double re, double im) {
                          	double tmp;
                          	if (im <= 0.00012) {
                          		tmp = 0.5 * (2.0 + (im * im));
                          	} else if (im <= 4.2e+65) {
                          		tmp = (im * im) * (0.5 + (re * (re * -0.25)));
                          	} else {
                          		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                          	}
                          	return tmp;
                          }
                          
                          def code(re, im):
                          	tmp = 0
                          	if im <= 0.00012:
                          		tmp = 0.5 * (2.0 + (im * im))
                          	elif im <= 4.2e+65:
                          		tmp = (im * im) * (0.5 + (re * (re * -0.25)))
                          	else:
                          		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)))
                          	return tmp
                          
                          function code(re, im)
                          	tmp = 0.0
                          	if (im <= 0.00012)
                          		tmp = Float64(0.5 * Float64(2.0 + Float64(im * im)));
                          	elseif (im <= 4.2e+65)
                          		tmp = Float64(Float64(im * im) * Float64(0.5 + Float64(re * Float64(re * -0.25))));
                          	else
                          		tmp = Float64(0.5 * Float64(im * Float64(im * Float64(Float64(im * im) * 0.08333333333333333))));
                          	end
                          	return tmp
                          end
                          
                          function tmp_2 = code(re, im)
                          	tmp = 0.0;
                          	if (im <= 0.00012)
                          		tmp = 0.5 * (2.0 + (im * im));
                          	elseif (im <= 4.2e+65)
                          		tmp = (im * im) * (0.5 + (re * (re * -0.25)));
                          	else
                          		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          code[re_, im_] := If[LessEqual[im, 0.00012], N[(0.5 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 4.2e+65], N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(re * N[(re * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;im \leq 0.00012:\\
                          \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\
                          
                          \mathbf{elif}\;im \leq 4.2 \cdot 10^{+65}:\\
                          \;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 3 regimes
                          2. if im < 1.20000000000000003e-4

                            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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                            4. Step-by-step derivation
                              1. +-lowering-+.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                              2. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                              3. *-lowering-*.f6486.8%

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                            5. Simplified86.8%

                              \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                            6. Taylor expanded in re around 0

                              \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                            7. Step-by-step derivation
                              1. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                              2. +-lowering-+.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                              3. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                              4. *-lowering-*.f6450.7%

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                            8. Simplified50.7%

                              \[\leadsto \color{blue}{0.5 \cdot \left(2 + im \cdot im\right)} \]

                            if 1.20000000000000003e-4 < im < 4.19999999999999983e65

                            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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                            4. Step-by-step derivation
                              1. +-lowering-+.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                              2. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                              3. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                              4. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                              5. +-lowering-+.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                              6. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                              7. associate-*r*N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                              8. *-commutativeN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                              9. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                              10. *-commutativeN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                              11. *-lowering-*.f645.7%

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                            5. Simplified5.7%

                              \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                            6. Taylor expanded in re around 0

                              \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)\right) + \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)} \]
                            7. Step-by-step derivation
                              1. +-commutativeN/A

                                \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) + \color{blue}{\frac{-1}{4} \cdot \left({re}^{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)} \]
                              2. associate-*r*N/A

                                \[\leadsto \frac{1}{2} \cdot \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) + \left(\frac{-1}{4} \cdot {re}^{2}\right) \cdot \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)} \]
                              3. distribute-rgt-outN/A

                                \[\leadsto \left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right) \cdot \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
                              4. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right), \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}\right) \]
                            8. Simplified31.0%

                              \[\leadsto \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right)} \]
                            9. Taylor expanded in im around inf

                              \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left({im}^{4} \cdot \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right)}, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                            10. Step-by-step derivation
                              1. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{4}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              2. metadata-evalN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{\left(2 \cdot 2\right)}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              3. pow-sqrN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left({im}^{2} \cdot {im}^{2}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              4. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(\left(im \cdot im\right) \cdot {im}^{2}\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              5. associate-*l*N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(im \cdot \left(im \cdot {im}^{2}\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              6. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \left(im \cdot {im}^{2}\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              7. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2}\right)\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              8. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(im \cdot im\right)\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              9. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \left(\frac{1}{12} + \frac{1}{{im}^{2}}\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              10. +-lowering-+.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \left(\frac{1}{{im}^{2}}\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              11. /-lowering-/.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \mathsf{/.f64}\left(1, \left({im}^{2}\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              12. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \mathsf{/.f64}\left(1, \left(im \cdot im\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                              13. *-lowering-*.f6431.0%

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{12}, \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(re, re\right)\right)\right)\right) \]
                            11. Simplified31.0%

                              \[\leadsto \color{blue}{\left(\left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot \left(0.08333333333333333 + \frac{1}{im \cdot im}\right)\right)} \cdot \left(0.5 + -0.25 \cdot \left(re \cdot re\right)\right) \]
                            12. Taylor expanded in im around 0

                              \[\leadsto \color{blue}{{im}^{2} \cdot \left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)} \]
                            13. Step-by-step derivation
                              1. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right)}\right) \]
                              2. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{1}{2}} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
                              3. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{1}{2}} + \frac{-1}{4} \cdot {re}^{2}\right)\right) \]
                              4. +-lowering-+.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{-1}{4} \cdot {re}^{2}\right)}\right)\right) \]
                              5. *-commutativeN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \left({re}^{2} \cdot \color{blue}{\frac{-1}{4}}\right)\right)\right) \]
                              6. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(re \cdot re\right) \cdot \frac{-1}{4}\right)\right)\right) \]
                              7. associate-*l*N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \left(re \cdot \color{blue}{\left(re \cdot \frac{-1}{4}\right)}\right)\right)\right) \]
                              8. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \color{blue}{\left(re \cdot \frac{-1}{4}\right)}\right)\right)\right) \]
                              9. *-lowering-*.f6430.4%

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{\frac{-1}{4}}\right)\right)\right)\right) \]
                            14. Simplified30.4%

                              \[\leadsto \color{blue}{\left(im \cdot im\right) \cdot \left(0.5 + re \cdot \left(re \cdot -0.25\right)\right)} \]

                            if 4.19999999999999983e65 < 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

                              \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                            4. Step-by-step derivation
                              1. +-lowering-+.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                              2. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                              3. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                              4. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                              5. +-lowering-+.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                              6. unpow2N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                              7. associate-*r*N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                              8. *-commutativeN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                              9. *-lowering-*.f64N/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                              10. *-commutativeN/A

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                              11. *-lowering-*.f6497.7%

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                            5. Simplified97.7%

                              \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                            6. Taylor expanded in re around 0

                              \[\leadsto \mathsf{*.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \frac{1}{12}\right)\right)\right)\right)\right)\right) \]
                            7. Step-by-step derivation
                              1. Simplified80.7%

                                \[\leadsto \color{blue}{0.5} \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \]
                              2. Taylor expanded in im around inf

                                \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{12} \cdot {im}^{4}\right)}\right) \]
                              3. Step-by-step derivation
                                1. metadata-evalN/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot {im}^{\left(2 \cdot \color{blue}{2}\right)}\right)\right) \]
                                2. pow-sqrN/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot \left({im}^{2} \cdot \color{blue}{{im}^{2}}\right)\right)\right) \]
                                3. associate-*l*N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(\frac{1}{12} \cdot {im}^{2}\right) \cdot \color{blue}{{im}^{2}}\right)\right) \]
                                4. *-commutativeN/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right) \]
                                5. unpow2N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{12}} \cdot {im}^{2}\right)\right)\right) \]
                                6. associate-*l*N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                                7. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                                8. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                                9. *-commutativeN/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                                10. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                                11. unpow2N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{12}\right)\right)\right)\right) \]
                                12. *-lowering-*.f6480.7%

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right) \]
                              4. Simplified80.7%

                                \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)} \]
                            8. Recombined 3 regimes into one program.
                            9. Add Preprocessing

                            Alternative 18: 51.9% accurate, 14.6× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00012:\\ \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 1.95 \cdot 10^{+65}:\\ \;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\ \end{array} \end{array} \]
                            (FPCore (re im)
                             :precision binary64
                             (if (<= im 0.00012)
                               (* 0.5 (+ 2.0 (* im im)))
                               (if (<= im 1.95e+65)
                                 (+ 1.0 (* (* re re) -0.5))
                                 (* 0.5 (* im (* im (* (* im im) 0.08333333333333333)))))))
                            double code(double re, double im) {
                            	double tmp;
                            	if (im <= 0.00012) {
                            		tmp = 0.5 * (2.0 + (im * im));
                            	} else if (im <= 1.95e+65) {
                            		tmp = 1.0 + ((re * re) * -0.5);
                            	} else {
                            		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                            	}
                            	return tmp;
                            }
                            
                            real(8) function code(re, im)
                                real(8), intent (in) :: re
                                real(8), intent (in) :: im
                                real(8) :: tmp
                                if (im <= 0.00012d0) then
                                    tmp = 0.5d0 * (2.0d0 + (im * im))
                                else if (im <= 1.95d+65) then
                                    tmp = 1.0d0 + ((re * re) * (-0.5d0))
                                else
                                    tmp = 0.5d0 * (im * (im * ((im * im) * 0.08333333333333333d0)))
                                end if
                                code = tmp
                            end function
                            
                            public static double code(double re, double im) {
                            	double tmp;
                            	if (im <= 0.00012) {
                            		tmp = 0.5 * (2.0 + (im * im));
                            	} else if (im <= 1.95e+65) {
                            		tmp = 1.0 + ((re * re) * -0.5);
                            	} else {
                            		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                            	}
                            	return tmp;
                            }
                            
                            def code(re, im):
                            	tmp = 0
                            	if im <= 0.00012:
                            		tmp = 0.5 * (2.0 + (im * im))
                            	elif im <= 1.95e+65:
                            		tmp = 1.0 + ((re * re) * -0.5)
                            	else:
                            		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)))
                            	return tmp
                            
                            function code(re, im)
                            	tmp = 0.0
                            	if (im <= 0.00012)
                            		tmp = Float64(0.5 * Float64(2.0 + Float64(im * im)));
                            	elseif (im <= 1.95e+65)
                            		tmp = Float64(1.0 + Float64(Float64(re * re) * -0.5));
                            	else
                            		tmp = Float64(0.5 * Float64(im * Float64(im * Float64(Float64(im * im) * 0.08333333333333333))));
                            	end
                            	return tmp
                            end
                            
                            function tmp_2 = code(re, im)
                            	tmp = 0.0;
                            	if (im <= 0.00012)
                            		tmp = 0.5 * (2.0 + (im * im));
                            	elseif (im <= 1.95e+65)
                            		tmp = 1.0 + ((re * re) * -0.5);
                            	else
                            		tmp = 0.5 * (im * (im * ((im * im) * 0.08333333333333333)));
                            	end
                            	tmp_2 = tmp;
                            end
                            
                            code[re_, im_] := If[LessEqual[im, 0.00012], N[(0.5 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.95e+65], N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * 0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            \mathbf{if}\;im \leq 0.00012:\\
                            \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\
                            
                            \mathbf{elif}\;im \leq 1.95 \cdot 10^{+65}:\\
                            \;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;0.5 \cdot \left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if im < 1.20000000000000003e-4

                              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

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                              4. Step-by-step derivation
                                1. +-lowering-+.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                2. unpow2N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                3. *-lowering-*.f6486.8%

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                              5. Simplified86.8%

                                \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                              6. Taylor expanded in re around 0

                                \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                              7. Step-by-step derivation
                                1. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                                2. +-lowering-+.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                3. unpow2N/A

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                4. *-lowering-*.f6450.7%

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                              8. Simplified50.7%

                                \[\leadsto \color{blue}{0.5 \cdot \left(2 + im \cdot im\right)} \]

                              if 1.20000000000000003e-4 < im < 1.9499999999999999e65

                              1. Initial program 100.0%

                                \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                              2. Step-by-step derivation
                                1. *-commutativeN/A

                                  \[\leadsto \left(\cos re \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} + e^{im}\right) \]
                                2. associate-*l*N/A

                                  \[\leadsto \cos re \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)} \]
                                3. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\cos re, \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)}\right) \]
                                4. cos-lowering-cos.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{\frac{1}{2}} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)\right) \]
                                5. +-commutativeN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\frac{1}{2} \cdot \left(e^{im} + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
                                6. distribute-rgt-inN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(e^{im} \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}}\right)\right) \]
                                7. +-lowering-+.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{1}{2}\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right)\right) \]
                                8. *-commutativeN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot e^{im}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                9. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(e^{im}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                10. exp-lowering-exp.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                                11. exp-negN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right)\right) \]
                                12. associate-*l/N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right)\right) \]
                                13. metadata-evalN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right)\right) \]
                                14. /-lowering-/.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                                15. exp-lowering-exp.f64100.0%

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
                              3. Simplified100.0%

                                \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                              4. Add Preprocessing
                              5. Taylor expanded in im around 0

                                \[\leadsto \color{blue}{\cos re} \]
                              6. Step-by-step derivation
                                1. cos-lowering-cos.f644.0%

                                  \[\leadsto \mathsf{cos.f64}\left(re\right) \]
                              7. Simplified4.0%

                                \[\leadsto \color{blue}{\cos re} \]
                              8. Taylor expanded in re around 0

                                \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot {re}^{2}} \]
                              9. Step-by-step derivation
                                1. +-lowering-+.f64N/A

                                  \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {re}^{2}\right)}\right) \]
                                2. *-commutativeN/A

                                  \[\leadsto \mathsf{+.f64}\left(1, \left({re}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
                                3. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\frac{-1}{2}}\right)\right) \]
                                4. unpow2N/A

                                  \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{-1}{2}\right)\right) \]
                                5. *-lowering-*.f6417.7%

                                  \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \frac{-1}{2}\right)\right) \]
                              10. Simplified17.7%

                                \[\leadsto \color{blue}{1 + \left(re \cdot re\right) \cdot -0.5} \]

                              if 1.9499999999999999e65 < 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

                                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                              4. Step-by-step derivation
                                1. +-lowering-+.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                                2. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                                3. unpow2N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                                4. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                                5. +-lowering-+.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                                6. unpow2N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                                7. associate-*r*N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                                8. *-commutativeN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                                9. *-lowering-*.f64N/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                                10. *-commutativeN/A

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                                11. *-lowering-*.f6497.7%

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                              5. Simplified97.7%

                                \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                              6. Taylor expanded in re around 0

                                \[\leadsto \mathsf{*.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \frac{1}{12}\right)\right)\right)\right)\right)\right) \]
                              7. Step-by-step derivation
                                1. Simplified80.7%

                                  \[\leadsto \color{blue}{0.5} \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \]
                                2. Taylor expanded in im around inf

                                  \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{1}{12} \cdot {im}^{4}\right)}\right) \]
                                3. Step-by-step derivation
                                  1. metadata-evalN/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot {im}^{\left(2 \cdot \color{blue}{2}\right)}\right)\right) \]
                                  2. pow-sqrN/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\frac{1}{12} \cdot \left({im}^{2} \cdot \color{blue}{{im}^{2}}\right)\right)\right) \]
                                  3. associate-*l*N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(\frac{1}{12} \cdot {im}^{2}\right) \cdot \color{blue}{{im}^{2}}\right)\right) \]
                                  4. *-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right) \]
                                  5. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{12}} \cdot {im}^{2}\right)\right)\right) \]
                                  6. associate-*l*N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                                  7. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                                  8. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                                  9. *-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                                  10. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{1}{12}}\right)\right)\right)\right) \]
                                  11. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{12}\right)\right)\right)\right) \]
                                  12. *-lowering-*.f6480.7%

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right) \]
                                4. Simplified80.7%

                                  \[\leadsto 0.5 \cdot \color{blue}{\left(im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.08333333333333333\right)\right)\right)} \]
                              8. Recombined 3 regimes into one program.
                              9. Add Preprocessing

                              Alternative 19: 51.9% accurate, 16.2× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00012:\\ \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\ \mathbf{elif}\;im \leq 3.6 \cdot 10^{+65}:\\ \;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\ \end{array} \end{array} \]
                              (FPCore (re im)
                               :precision binary64
                               (if (<= im 0.00012)
                                 (* 0.5 (+ 2.0 (* im im)))
                                 (if (<= im 3.6e+65)
                                   (+ 1.0 (* (* re re) -0.5))
                                   (* im (* im (* (* im im) 0.041666666666666664))))))
                              double code(double re, double im) {
                              	double tmp;
                              	if (im <= 0.00012) {
                              		tmp = 0.5 * (2.0 + (im * im));
                              	} else if (im <= 3.6e+65) {
                              		tmp = 1.0 + ((re * re) * -0.5);
                              	} else {
                              		tmp = 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 <= 0.00012d0) then
                                      tmp = 0.5d0 * (2.0d0 + (im * im))
                                  else if (im <= 3.6d+65) then
                                      tmp = 1.0d0 + ((re * re) * (-0.5d0))
                                  else
                                      tmp = im * (im * ((im * im) * 0.041666666666666664d0))
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double re, double im) {
                              	double tmp;
                              	if (im <= 0.00012) {
                              		tmp = 0.5 * (2.0 + (im * im));
                              	} else if (im <= 3.6e+65) {
                              		tmp = 1.0 + ((re * re) * -0.5);
                              	} else {
                              		tmp = im * (im * ((im * im) * 0.041666666666666664));
                              	}
                              	return tmp;
                              }
                              
                              def code(re, im):
                              	tmp = 0
                              	if im <= 0.00012:
                              		tmp = 0.5 * (2.0 + (im * im))
                              	elif im <= 3.6e+65:
                              		tmp = 1.0 + ((re * re) * -0.5)
                              	else:
                              		tmp = im * (im * ((im * im) * 0.041666666666666664))
                              	return tmp
                              
                              function code(re, im)
                              	tmp = 0.0
                              	if (im <= 0.00012)
                              		tmp = Float64(0.5 * Float64(2.0 + Float64(im * im)));
                              	elseif (im <= 3.6e+65)
                              		tmp = Float64(1.0 + Float64(Float64(re * re) * -0.5));
                              	else
                              		tmp = Float64(im * Float64(im * Float64(Float64(im * im) * 0.041666666666666664)));
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(re, im)
                              	tmp = 0.0;
                              	if (im <= 0.00012)
                              		tmp = 0.5 * (2.0 + (im * im));
                              	elseif (im <= 3.6e+65)
                              		tmp = 1.0 + ((re * re) * -0.5);
                              	else
                              		tmp = im * (im * ((im * im) * 0.041666666666666664));
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[re_, im_] := If[LessEqual[im, 0.00012], N[(0.5 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.6e+65], N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;im \leq 0.00012:\\
                              \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\
                              
                              \mathbf{elif}\;im \leq 3.6 \cdot 10^{+65}:\\
                              \;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 3 regimes
                              2. if im < 1.20000000000000003e-4

                                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

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                                4. Step-by-step derivation
                                  1. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                  2. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                  3. *-lowering-*.f6486.8%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                                5. Simplified86.8%

                                  \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                                6. Taylor expanded in re around 0

                                  \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                                7. Step-by-step derivation
                                  1. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                                  2. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                  3. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                  4. *-lowering-*.f6450.7%

                                    \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                                8. Simplified50.7%

                                  \[\leadsto \color{blue}{0.5 \cdot \left(2 + im \cdot im\right)} \]

                                if 1.20000000000000003e-4 < im < 3.59999999999999978e65

                                1. Initial program 100.0%

                                  \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                                2. Step-by-step derivation
                                  1. *-commutativeN/A

                                    \[\leadsto \left(\cos re \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} + e^{im}\right) \]
                                  2. associate-*l*N/A

                                    \[\leadsto \cos re \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)} \]
                                  3. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\cos re, \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)}\right) \]
                                  4. cos-lowering-cos.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{\frac{1}{2}} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)\right) \]
                                  5. +-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\frac{1}{2} \cdot \left(e^{im} + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
                                  6. distribute-rgt-inN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(e^{im} \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}}\right)\right) \]
                                  7. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{1}{2}\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right)\right) \]
                                  8. *-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot e^{im}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                  9. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(e^{im}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                  10. exp-lowering-exp.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                                  11. exp-negN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right)\right) \]
                                  12. associate-*l/N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right)\right) \]
                                  13. metadata-evalN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right)\right) \]
                                  14. /-lowering-/.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                                  15. exp-lowering-exp.f64100.0%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
                                3. Simplified100.0%

                                  \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                                4. Add Preprocessing
                                5. Taylor expanded in im around 0

                                  \[\leadsto \color{blue}{\cos re} \]
                                6. Step-by-step derivation
                                  1. cos-lowering-cos.f644.0%

                                    \[\leadsto \mathsf{cos.f64}\left(re\right) \]
                                7. Simplified4.0%

                                  \[\leadsto \color{blue}{\cos re} \]
                                8. Taylor expanded in re around 0

                                  \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot {re}^{2}} \]
                                9. Step-by-step derivation
                                  1. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {re}^{2}\right)}\right) \]
                                  2. *-commutativeN/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \left({re}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
                                  3. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\frac{-1}{2}}\right)\right) \]
                                  4. unpow2N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{-1}{2}\right)\right) \]
                                  5. *-lowering-*.f6417.7%

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \frac{-1}{2}\right)\right) \]
                                10. Simplified17.7%

                                  \[\leadsto \color{blue}{1 + \left(re \cdot re\right) \cdot -0.5} \]

                                if 3.59999999999999978e65 < 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

                                  \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right) \]
                                4. Step-by-step derivation
                                  1. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2} \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right) \]
                                  2. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(1 + \frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right) \]
                                  3. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                                  4. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
                                  5. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{12} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
                                  6. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\frac{1}{12} \cdot \left(im \cdot \color{blue}{im}\right)\right)\right)\right)\right)\right) \]
                                  7. associate-*r*N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(\left(\frac{1}{12} \cdot im\right) \cdot \color{blue}{im}\right)\right)\right)\right)\right) \]
                                  8. *-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                                  9. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{12} \cdot im\right)}\right)\right)\right)\right)\right) \]
                                  10. *-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \left(im \cdot \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                                  11. *-lowering-*.f6497.7%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\frac{1}{12}}\right)\right)\right)\right)\right)\right) \]
                                5. Simplified97.7%

                                  \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right)} \]
                                6. Taylor expanded in re around 0

                                  \[\leadsto \mathsf{*.f64}\left(\color{blue}{\frac{1}{2}}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \frac{1}{12}\right)\right)\right)\right)\right)\right) \]
                                7. Step-by-step derivation
                                  1. Simplified80.7%

                                    \[\leadsto \color{blue}{0.5} \cdot \left(2 + \left(im \cdot im\right) \cdot \left(1 + im \cdot \left(im \cdot 0.08333333333333333\right)\right)\right) \]
                                  2. Taylor expanded in im around inf

                                    \[\leadsto \color{blue}{\frac{1}{24} \cdot {im}^{4}} \]
                                  3. Step-by-step derivation
                                    1. metadata-evalN/A

                                      \[\leadsto \frac{1}{24} \cdot {im}^{\left(2 \cdot \color{blue}{2}\right)} \]
                                    2. pow-sqrN/A

                                      \[\leadsto \frac{1}{24} \cdot \left({im}^{2} \cdot \color{blue}{{im}^{2}}\right) \]
                                    3. associate-*l*N/A

                                      \[\leadsto \left(\frac{1}{24} \cdot {im}^{2}\right) \cdot \color{blue}{{im}^{2}} \]
                                    4. *-commutativeN/A

                                      \[\leadsto {im}^{2} \cdot \color{blue}{\left(\frac{1}{24} \cdot {im}^{2}\right)} \]
                                    5. unpow2N/A

                                      \[\leadsto \left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{24}} \cdot {im}^{2}\right) \]
                                    6. associate-*l*N/A

                                      \[\leadsto im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right)} \]
                                    7. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right)}\right) \]
                                    8. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{24} \cdot {im}^{2}\right)}\right)\right) \]
                                    9. *-commutativeN/A

                                      \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left({im}^{2} \cdot \color{blue}{\frac{1}{24}}\right)\right)\right) \]
                                    10. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{1}{24}}\right)\right)\right) \]
                                    11. unpow2N/A

                                      \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{24}\right)\right)\right) \]
                                    12. *-lowering-*.f6478.7%

                                      \[\leadsto \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{24}\right)\right)\right) \]
                                  4. Simplified78.7%

                                    \[\leadsto \color{blue}{im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)} \]
                                8. Recombined 3 regimes into one program.
                                9. Add Preprocessing

                                Alternative 20: 58.4% accurate, 16.2× speedup?

                                \[\begin{array}{l} \\ 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right) \end{array} \]
                                (FPCore (re im)
                                 :precision binary64
                                 (+
                                  1.0
                                  (*
                                   im
                                   (*
                                    im
                                    (+
                                     0.5
                                     (*
                                      (* im im)
                                      (+ (* (* im im) 0.001388888888888889) 0.041666666666666664)))))))
                                double code(double re, double im) {
                                	return 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
                                }
                                
                                real(8) function code(re, im)
                                    real(8), intent (in) :: re
                                    real(8), intent (in) :: im
                                    code = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * (((im * im) * 0.001388888888888889d0) + 0.041666666666666664d0)))))
                                end function
                                
                                public static double code(double re, double im) {
                                	return 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
                                }
                                
                                def code(re, im):
                                	return 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))))
                                
                                function code(re, im)
                                	return Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * Float64(Float64(Float64(im * im) * 0.001388888888888889) + 0.041666666666666664))))))
                                end
                                
                                function tmp = code(re, im)
                                	tmp = 1.0 + (im * (im * (0.5 + ((im * im) * (((im * im) * 0.001388888888888889) + 0.041666666666666664)))));
                                end
                                
                                code[re_, im_] := N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * N[(N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                                
                                \begin{array}{l}
                                
                                \\
                                1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\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. Step-by-step derivation
                                  1. *-commutativeN/A

                                    \[\leadsto \left(\cos re \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} + e^{im}\right) \]
                                  2. associate-*l*N/A

                                    \[\leadsto \cos re \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)} \]
                                  3. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\cos re, \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)}\right) \]
                                  4. cos-lowering-cos.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{\frac{1}{2}} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)\right) \]
                                  5. +-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\frac{1}{2} \cdot \left(e^{im} + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
                                  6. distribute-rgt-inN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(e^{im} \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}}\right)\right) \]
                                  7. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{1}{2}\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right)\right) \]
                                  8. *-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot e^{im}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                  9. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(e^{im}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                  10. exp-lowering-exp.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                                  11. exp-negN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right)\right) \]
                                  12. associate-*l/N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right)\right) \]
                                  13. metadata-evalN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right)\right) \]
                                  14. /-lowering-/.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                                  15. exp-lowering-exp.f64100.0%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
                                3. Simplified100.0%

                                  \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                                4. Add Preprocessing
                                5. Step-by-step derivation
                                  1. *-commutativeN/A

                                    \[\leadsto \left(\frac{1}{2} \cdot e^{im} + \frac{\frac{1}{2}}{e^{im}}\right) \cdot \color{blue}{\cos re} \]
                                  2. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{\frac{1}{2}}{e^{im}}\right), \color{blue}{\cos re}\right) \]
                                  3. div-invN/A

                                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot \frac{1}{e^{im}}\right), \cos re\right) \]
                                  4. exp-negN/A

                                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
                                  5. distribute-lft-outN/A

                                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos \color{blue}{re}\right) \]
                                  6. cosh-undefN/A

                                    \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(2 \cdot \cosh im\right)\right), \cos re\right) \]
                                  7. associate-*r*N/A

                                    \[\leadsto \mathsf{*.f64}\left(\left(\left(\frac{1}{2} \cdot 2\right) \cdot \cosh im\right), \cos \color{blue}{re}\right) \]
                                  8. metadata-evalN/A

                                    \[\leadsto \mathsf{*.f64}\left(\left(1 \cdot \cosh im\right), \cos re\right) \]
                                  9. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \cosh im\right), \cos \color{blue}{re}\right) \]
                                  10. cosh-lowering-cosh.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
                                  11. cos-lowering-cos.f64100.0%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                6. Applied egg-rr100.0%

                                  \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
                                7. Taylor expanded in im around 0

                                  \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}, \mathsf{cos.f64}\left(re\right)\right) \]
                                8. Step-by-step derivation
                                  1. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \left({im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(\color{blue}{re}\right)\right) \]
                                  2. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({im}^{2}\right), \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  3. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  4. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  5. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  6. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \left(\left(im \cdot im\right) \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  7. associate-*l*N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \left(im \cdot \left(im \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  8. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \left(im \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  9. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  10. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{24}, \left(\frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  11. *-commutativeN/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{24}, \left({im}^{2} \cdot \frac{1}{720}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  12. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left({im}^{2}\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  13. unpow2N/A

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                  14. *-lowering-*.f6490.8%

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                9. Simplified90.8%

                                  \[\leadsto \color{blue}{\left(1 + \left(im \cdot im\right) \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)} \cdot \cos re \]
                                10. Taylor expanded in re around 0

                                  \[\leadsto \color{blue}{1 + {im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)} \]
                                11. Step-by-step derivation
                                  1. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}\right) \]
                                  2. unpow2N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{2}} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right) \]
                                  3. associate-*l*N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \left(im \cdot \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right) \]
                                  4. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \color{blue}{\left(im \cdot \left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)}\right)\right) \]
                                  5. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \color{blue}{\left(\frac{1}{2} + {im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right) \]
                                  6. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)\right)}\right)\right)\right)\right) \]
                                  7. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\left(\frac{1}{24} + \frac{1}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right) \]
                                  8. unpow2N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(im \cdot im\right), \left(\color{blue}{\frac{1}{24}} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right) \]
                                  9. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \left(\color{blue}{\frac{1}{24}} + \frac{1}{720} \cdot {im}^{2}\right)\right)\right)\right)\right)\right) \]
                                  10. +-lowering-+.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \color{blue}{\left(\frac{1}{720} \cdot {im}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
                                  11. *-commutativeN/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \left({im}^{2} \cdot \color{blue}{\frac{1}{720}}\right)\right)\right)\right)\right)\right)\right) \]
                                  12. *-lowering-*.f64N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left({im}^{2}\right), \color{blue}{\frac{1}{720}}\right)\right)\right)\right)\right)\right)\right) \]
                                  13. unpow2N/A

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                                  14. *-lowering-*.f6459.1%

                                    \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right)\right) \]
                                12. Simplified59.1%

                                  \[\leadsto \color{blue}{1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)} \]
                                13. Final simplification59.1%

                                  \[\leadsto 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot 0.001388888888888889 + 0.041666666666666664\right)\right)\right) \]
                                14. Add Preprocessing

                                Alternative 21: 48.0% accurate, 22.0× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 1.3 \cdot 10^{+85}:\\ \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(re \cdot \left(re \cdot \left(re \cdot re\right)\right)\right)\\ \end{array} \end{array} \]
                                (FPCore (re im)
                                 :precision binary64
                                 (if (<= re 1.3e+85)
                                   (* 0.5 (+ 2.0 (* im im)))
                                   (* 0.041666666666666664 (* re (* re (* re re))))))
                                double code(double re, double im) {
                                	double tmp;
                                	if (re <= 1.3e+85) {
                                		tmp = 0.5 * (2.0 + (im * im));
                                	} else {
                                		tmp = 0.041666666666666664 * (re * (re * (re * re)));
                                	}
                                	return tmp;
                                }
                                
                                real(8) function code(re, im)
                                    real(8), intent (in) :: re
                                    real(8), intent (in) :: im
                                    real(8) :: tmp
                                    if (re <= 1.3d+85) then
                                        tmp = 0.5d0 * (2.0d0 + (im * im))
                                    else
                                        tmp = 0.041666666666666664d0 * (re * (re * (re * re)))
                                    end if
                                    code = tmp
                                end function
                                
                                public static double code(double re, double im) {
                                	double tmp;
                                	if (re <= 1.3e+85) {
                                		tmp = 0.5 * (2.0 + (im * im));
                                	} else {
                                		tmp = 0.041666666666666664 * (re * (re * (re * re)));
                                	}
                                	return tmp;
                                }
                                
                                def code(re, im):
                                	tmp = 0
                                	if re <= 1.3e+85:
                                		tmp = 0.5 * (2.0 + (im * im))
                                	else:
                                		tmp = 0.041666666666666664 * (re * (re * (re * re)))
                                	return tmp
                                
                                function code(re, im)
                                	tmp = 0.0
                                	if (re <= 1.3e+85)
                                		tmp = Float64(0.5 * Float64(2.0 + Float64(im * im)));
                                	else
                                		tmp = Float64(0.041666666666666664 * Float64(re * Float64(re * Float64(re * re))));
                                	end
                                	return tmp
                                end
                                
                                function tmp_2 = code(re, im)
                                	tmp = 0.0;
                                	if (re <= 1.3e+85)
                                		tmp = 0.5 * (2.0 + (im * im));
                                	else
                                		tmp = 0.041666666666666664 * (re * (re * (re * re)));
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                code[re_, im_] := If[LessEqual[re, 1.3e+85], N[(0.5 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.041666666666666664 * N[(re * N[(re * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;re \leq 1.3 \cdot 10^{+85}:\\
                                \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;0.041666666666666664 \cdot \left(re \cdot \left(re \cdot \left(re \cdot re\right)\right)\right)\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if re < 1.30000000000000005e85

                                  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

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                                  4. Step-by-step derivation
                                    1. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                    2. unpow2N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                    3. *-lowering-*.f6476.9%

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                                  5. Simplified76.9%

                                    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                                  6. Taylor expanded in re around 0

                                    \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                                  7. Step-by-step derivation
                                    1. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                                    2. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                    3. unpow2N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                    4. *-lowering-*.f6453.3%

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                                  8. Simplified53.3%

                                    \[\leadsto \color{blue}{0.5 \cdot \left(2 + im \cdot im\right)} \]

                                  if 1.30000000000000005e85 < re

                                  1. Initial program 100.0%

                                    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                                  2. Step-by-step derivation
                                    1. *-commutativeN/A

                                      \[\leadsto \left(\cos re \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} + e^{im}\right) \]
                                    2. associate-*l*N/A

                                      \[\leadsto \cos re \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)} \]
                                    3. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\cos re, \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)}\right) \]
                                    4. cos-lowering-cos.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{\frac{1}{2}} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)\right) \]
                                    5. +-commutativeN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\frac{1}{2} \cdot \left(e^{im} + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
                                    6. distribute-rgt-inN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(e^{im} \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}}\right)\right) \]
                                    7. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{1}{2}\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right)\right) \]
                                    8. *-commutativeN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot e^{im}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                    9. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(e^{im}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                    10. exp-lowering-exp.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                                    11. exp-negN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right)\right) \]
                                    12. associate-*l/N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right)\right) \]
                                    13. metadata-evalN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right)\right) \]
                                    14. /-lowering-/.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                                    15. exp-lowering-exp.f64100.0%

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
                                  3. Simplified100.0%

                                    \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                                  4. Add Preprocessing
                                  5. Taylor expanded in im around 0

                                    \[\leadsto \color{blue}{\cos re} \]
                                  6. Step-by-step derivation
                                    1. cos-lowering-cos.f6448.4%

                                      \[\leadsto \mathsf{cos.f64}\left(re\right) \]
                                  7. Simplified48.4%

                                    \[\leadsto \color{blue}{\cos re} \]
                                  8. Taylor expanded in re around 0

                                    \[\leadsto \color{blue}{1 + {re}^{2} \cdot \left(\frac{1}{24} \cdot {re}^{2} - \frac{1}{2}\right)} \]
                                  9. Step-by-step derivation
                                    1. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left({re}^{2} \cdot \left(\frac{1}{24} \cdot {re}^{2} - \frac{1}{2}\right)\right)}\right) \]
                                    2. unpow2N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \left(\left(re \cdot re\right) \cdot \left(\color{blue}{\frac{1}{24} \cdot {re}^{2}} - \frac{1}{2}\right)\right)\right) \]
                                    3. associate-*l*N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \left(re \cdot \color{blue}{\left(re \cdot \left(\frac{1}{24} \cdot {re}^{2} - \frac{1}{2}\right)\right)}\right)\right) \]
                                    4. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \color{blue}{\left(re \cdot \left(\frac{1}{24} \cdot {re}^{2} - \frac{1}{2}\right)\right)}\right)\right) \]
                                    5. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{\left(\frac{1}{24} \cdot {re}^{2} - \frac{1}{2}\right)}\right)\right)\right) \]
                                    6. sub-negN/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{1}{24} \cdot {re}^{2} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)\right)\right)\right) \]
                                    7. metadata-evalN/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{1}{24} \cdot {re}^{2} + \frac{-1}{2}\right)\right)\right)\right) \]
                                    8. +-commutativeN/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(\frac{-1}{2} + \color{blue}{\frac{1}{24} \cdot {re}^{2}}\right)\right)\right)\right) \]
                                    9. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{-1}{2}, \color{blue}{\left(\frac{1}{24} \cdot {re}^{2}\right)}\right)\right)\right)\right) \]
                                    10. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \color{blue}{\left({re}^{2}\right)}\right)\right)\right)\right)\right) \]
                                    11. unpow2N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \left(re \cdot \color{blue}{re}\right)\right)\right)\right)\right)\right) \]
                                    12. *-lowering-*.f6428.0%

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right)\right)\right)\right) \]
                                  10. Simplified28.0%

                                    \[\leadsto \color{blue}{1 + re \cdot \left(re \cdot \left(-0.5 + 0.041666666666666664 \cdot \left(re \cdot re\right)\right)\right)} \]
                                  11. Taylor expanded in re around inf

                                    \[\leadsto \color{blue}{\frac{1}{24} \cdot {re}^{4}} \]
                                  12. Step-by-step derivation
                                    1. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \color{blue}{\left({re}^{4}\right)}\right) \]
                                    2. metadata-evalN/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \left({re}^{\left(2 \cdot \color{blue}{2}\right)}\right)\right) \]
                                    3. pow-sqrN/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \left({re}^{2} \cdot \color{blue}{{re}^{2}}\right)\right) \]
                                    4. unpow2N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \left(\left(re \cdot re\right) \cdot {\color{blue}{re}}^{2}\right)\right) \]
                                    5. associate-*l*N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \left(re \cdot \color{blue}{\left(re \cdot {re}^{2}\right)}\right)\right) \]
                                    6. unpow2N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \left(re \cdot \left(re \cdot \left(re \cdot \color{blue}{re}\right)\right)\right)\right) \]
                                    7. cube-multN/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \left(re \cdot {re}^{\color{blue}{3}}\right)\right) \]
                                    8. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(re, \color{blue}{\left({re}^{3}\right)}\right)\right) \]
                                    9. cube-multN/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(re, \left(re \cdot \color{blue}{\left(re \cdot re\right)}\right)\right)\right) \]
                                    10. unpow2N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(re, \left(re \cdot {re}^{\color{blue}{2}}\right)\right)\right) \]
                                    11. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{\left({re}^{2}\right)}\right)\right)\right) \]
                                    12. unpow2N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \left(re \cdot \color{blue}{re}\right)\right)\right)\right) \]
                                    13. *-lowering-*.f6428.0%

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right)\right) \]
                                  13. Simplified28.0%

                                    \[\leadsto \color{blue}{0.041666666666666664 \cdot \left(re \cdot \left(re \cdot \left(re \cdot re\right)\right)\right)} \]
                                3. Recombined 2 regimes into one program.
                                4. Add Preprocessing

                                Alternative 22: 48.3% accurate, 25.6× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 4.25 \cdot 10^{+186}:\\ \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\ \end{array} \end{array} \]
                                (FPCore (re im)
                                 :precision binary64
                                 (if (<= re 4.25e+186) (* 0.5 (+ 2.0 (* im im))) (+ 1.0 (* (* re re) -0.5))))
                                double code(double re, double im) {
                                	double tmp;
                                	if (re <= 4.25e+186) {
                                		tmp = 0.5 * (2.0 + (im * im));
                                	} else {
                                		tmp = 1.0 + ((re * re) * -0.5);
                                	}
                                	return tmp;
                                }
                                
                                real(8) function code(re, im)
                                    real(8), intent (in) :: re
                                    real(8), intent (in) :: im
                                    real(8) :: tmp
                                    if (re <= 4.25d+186) then
                                        tmp = 0.5d0 * (2.0d0 + (im * im))
                                    else
                                        tmp = 1.0d0 + ((re * re) * (-0.5d0))
                                    end if
                                    code = tmp
                                end function
                                
                                public static double code(double re, double im) {
                                	double tmp;
                                	if (re <= 4.25e+186) {
                                		tmp = 0.5 * (2.0 + (im * im));
                                	} else {
                                		tmp = 1.0 + ((re * re) * -0.5);
                                	}
                                	return tmp;
                                }
                                
                                def code(re, im):
                                	tmp = 0
                                	if re <= 4.25e+186:
                                		tmp = 0.5 * (2.0 + (im * im))
                                	else:
                                		tmp = 1.0 + ((re * re) * -0.5)
                                	return tmp
                                
                                function code(re, im)
                                	tmp = 0.0
                                	if (re <= 4.25e+186)
                                		tmp = Float64(0.5 * Float64(2.0 + Float64(im * im)));
                                	else
                                		tmp = Float64(1.0 + Float64(Float64(re * re) * -0.5));
                                	end
                                	return tmp
                                end
                                
                                function tmp_2 = code(re, im)
                                	tmp = 0.0;
                                	if (re <= 4.25e+186)
                                		tmp = 0.5 * (2.0 + (im * im));
                                	else
                                		tmp = 1.0 + ((re * re) * -0.5);
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                code[re_, im_] := If[LessEqual[re, 4.25e+186], N[(0.5 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;re \leq 4.25 \cdot 10^{+186}:\\
                                \;\;\;\;0.5 \cdot \left(2 + im \cdot im\right)\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;1 + \left(re \cdot re\right) \cdot -0.5\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if re < 4.2499999999999999e186

                                  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

                                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                                  4. Step-by-step derivation
                                    1. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                    2. unpow2N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                    3. *-lowering-*.f6475.3%

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                                  5. Simplified75.3%

                                    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                                  6. Taylor expanded in re around 0

                                    \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                                  7. Step-by-step derivation
                                    1. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                                    2. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                    3. unpow2N/A

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                    4. *-lowering-*.f6450.4%

                                      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                                  8. Simplified50.4%

                                    \[\leadsto \color{blue}{0.5 \cdot \left(2 + im \cdot im\right)} \]

                                  if 4.2499999999999999e186 < re

                                  1. Initial program 100.0%

                                    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                                  2. Step-by-step derivation
                                    1. *-commutativeN/A

                                      \[\leadsto \left(\cos re \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} + e^{im}\right) \]
                                    2. associate-*l*N/A

                                      \[\leadsto \cos re \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)} \]
                                    3. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\cos re, \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)}\right) \]
                                    4. cos-lowering-cos.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{\frac{1}{2}} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)\right) \]
                                    5. +-commutativeN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\frac{1}{2} \cdot \left(e^{im} + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
                                    6. distribute-rgt-inN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(e^{im} \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}}\right)\right) \]
                                    7. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{1}{2}\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right)\right) \]
                                    8. *-commutativeN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot e^{im}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                    9. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(e^{im}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                    10. exp-lowering-exp.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                                    11. exp-negN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right)\right) \]
                                    12. associate-*l/N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right)\right) \]
                                    13. metadata-evalN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right)\right) \]
                                    14. /-lowering-/.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                                    15. exp-lowering-exp.f64100.0%

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
                                  3. Simplified100.0%

                                    \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                                  4. Add Preprocessing
                                  5. Taylor expanded in im around 0

                                    \[\leadsto \color{blue}{\cos re} \]
                                  6. Step-by-step derivation
                                    1. cos-lowering-cos.f6456.9%

                                      \[\leadsto \mathsf{cos.f64}\left(re\right) \]
                                  7. Simplified56.9%

                                    \[\leadsto \color{blue}{\cos re} \]
                                  8. Taylor expanded in re around 0

                                    \[\leadsto \color{blue}{1 + \frac{-1}{2} \cdot {re}^{2}} \]
                                  9. Step-by-step derivation
                                    1. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{2} \cdot {re}^{2}\right)}\right) \]
                                    2. *-commutativeN/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \left({re}^{2} \cdot \color{blue}{\frac{-1}{2}}\right)\right) \]
                                    3. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\frac{-1}{2}}\right)\right) \]
                                    4. unpow2N/A

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{-1}{2}\right)\right) \]
                                    5. *-lowering-*.f6427.0%

                                      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \frac{-1}{2}\right)\right) \]
                                  10. Simplified27.0%

                                    \[\leadsto \color{blue}{1 + \left(re \cdot re\right) \cdot -0.5} \]
                                3. Recombined 2 regimes into one program.
                                4. Add Preprocessing

                                Alternative 23: 38.5% accurate, 30.8× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 0.00012:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot im\right)\\ \end{array} \end{array} \]
                                (FPCore (re im) :precision binary64 (if (<= im 0.00012) 1.0 (* 0.5 (* im im))))
                                double code(double re, double im) {
                                	double tmp;
                                	if (im <= 0.00012) {
                                		tmp = 1.0;
                                	} else {
                                		tmp = 0.5 * (im * im);
                                	}
                                	return tmp;
                                }
                                
                                real(8) function code(re, im)
                                    real(8), intent (in) :: re
                                    real(8), intent (in) :: im
                                    real(8) :: tmp
                                    if (im <= 0.00012d0) then
                                        tmp = 1.0d0
                                    else
                                        tmp = 0.5d0 * (im * im)
                                    end if
                                    code = tmp
                                end function
                                
                                public static double code(double re, double im) {
                                	double tmp;
                                	if (im <= 0.00012) {
                                		tmp = 1.0;
                                	} else {
                                		tmp = 0.5 * (im * im);
                                	}
                                	return tmp;
                                }
                                
                                def code(re, im):
                                	tmp = 0
                                	if im <= 0.00012:
                                		tmp = 1.0
                                	else:
                                		tmp = 0.5 * (im * im)
                                	return tmp
                                
                                function code(re, im)
                                	tmp = 0.0
                                	if (im <= 0.00012)
                                		tmp = 1.0;
                                	else
                                		tmp = Float64(0.5 * Float64(im * im));
                                	end
                                	return tmp
                                end
                                
                                function tmp_2 = code(re, im)
                                	tmp = 0.0;
                                	if (im <= 0.00012)
                                		tmp = 1.0;
                                	else
                                		tmp = 0.5 * (im * im);
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                code[re_, im_] := If[LessEqual[im, 0.00012], 1.0, N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                \mathbf{if}\;im \leq 0.00012:\\
                                \;\;\;\;1\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;0.5 \cdot \left(im \cdot im\right)\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if im < 1.20000000000000003e-4

                                  1. Initial program 100.0%

                                    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                                  2. Step-by-step derivation
                                    1. *-commutativeN/A

                                      \[\leadsto \left(\cos re \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} + e^{im}\right) \]
                                    2. associate-*l*N/A

                                      \[\leadsto \cos re \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)} \]
                                    3. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\cos re, \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)}\right) \]
                                    4. cos-lowering-cos.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{\frac{1}{2}} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)\right) \]
                                    5. +-commutativeN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\frac{1}{2} \cdot \left(e^{im} + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
                                    6. distribute-rgt-inN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(e^{im} \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}}\right)\right) \]
                                    7. +-lowering-+.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{1}{2}\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right)\right) \]
                                    8. *-commutativeN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot e^{im}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                    9. *-lowering-*.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(e^{im}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                    10. exp-lowering-exp.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                                    11. exp-negN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right)\right) \]
                                    12. associate-*l/N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right)\right) \]
                                    13. metadata-evalN/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right)\right) \]
                                    14. /-lowering-/.f64N/A

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                                    15. exp-lowering-exp.f64100.0%

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
                                  3. Simplified100.0%

                                    \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                                  4. Add Preprocessing
                                  5. Taylor expanded in im around 0

                                    \[\leadsto \color{blue}{\cos re} \]
                                  6. Step-by-step derivation
                                    1. cos-lowering-cos.f6464.0%

                                      \[\leadsto \mathsf{cos.f64}\left(re\right) \]
                                  7. Simplified64.0%

                                    \[\leadsto \color{blue}{\cos re} \]
                                  8. Taylor expanded in re around 0

                                    \[\leadsto \color{blue}{1} \]
                                  9. Step-by-step derivation
                                    1. Simplified35.8%

                                      \[\leadsto \color{blue}{1} \]

                                    if 1.20000000000000003e-4 < im

                                    1. Initial program 100.0%

                                      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                                    2. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto \left(\cos re \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} + e^{im}\right) \]
                                      2. associate-*l*N/A

                                        \[\leadsto \cos re \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)} \]
                                      3. *-lowering-*.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\cos re, \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)}\right) \]
                                      4. cos-lowering-cos.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{\frac{1}{2}} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)\right) \]
                                      5. +-commutativeN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\frac{1}{2} \cdot \left(e^{im} + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
                                      6. distribute-rgt-inN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(e^{im} \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}}\right)\right) \]
                                      7. +-lowering-+.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{1}{2}\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right)\right) \]
                                      8. *-commutativeN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot e^{im}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                      9. *-lowering-*.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(e^{im}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                      10. exp-lowering-exp.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                                      11. exp-negN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right)\right) \]
                                      12. associate-*l/N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right)\right) \]
                                      13. metadata-evalN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right)\right) \]
                                      14. /-lowering-/.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                                      15. exp-lowering-exp.f64100.0%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
                                    3. Simplified100.0%

                                      \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                                    4. Add Preprocessing
                                    5. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto \left(\frac{1}{2} \cdot e^{im} + \frac{\frac{1}{2}}{e^{im}}\right) \cdot \color{blue}{\cos re} \]
                                      2. *-lowering-*.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{\frac{1}{2}}{e^{im}}\right), \color{blue}{\cos re}\right) \]
                                      3. div-invN/A

                                        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot \frac{1}{e^{im}}\right), \cos re\right) \]
                                      4. exp-negN/A

                                        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot e^{im} + \frac{1}{2} \cdot e^{\mathsf{neg}\left(im\right)}\right), \cos re\right) \]
                                      5. distribute-lft-outN/A

                                        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos \color{blue}{re}\right) \]
                                      6. cosh-undefN/A

                                        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(2 \cdot \cosh im\right)\right), \cos re\right) \]
                                      7. associate-*r*N/A

                                        \[\leadsto \mathsf{*.f64}\left(\left(\left(\frac{1}{2} \cdot 2\right) \cdot \cosh im\right), \cos \color{blue}{re}\right) \]
                                      8. metadata-evalN/A

                                        \[\leadsto \mathsf{*.f64}\left(\left(1 \cdot \cosh im\right), \cos re\right) \]
                                      9. *-lowering-*.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \cosh im\right), \cos \color{blue}{re}\right) \]
                                      10. cosh-lowering-cosh.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \cos re\right) \]
                                      11. cos-lowering-cos.f64100.0%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \mathsf{cos.f64}\left(re\right)\right) \]
                                    6. Applied egg-rr100.0%

                                      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
                                    7. Taylor expanded in re around 0

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(1, \mathsf{cosh.f64}\left(im\right)\right), \color{blue}{1}\right) \]
                                    8. Step-by-step derivation
                                      1. Simplified69.9%

                                        \[\leadsto \left(1 \cdot \cosh im\right) \cdot \color{blue}{1} \]
                                      2. Taylor expanded in im around 0

                                        \[\leadsto \color{blue}{1 + \frac{1}{2} \cdot {im}^{2}} \]
                                      3. Step-by-step derivation
                                        1. +-lowering-+.f64N/A

                                          \[\leadsto \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{1}{2} \cdot {im}^{2}\right)}\right) \]
                                        2. *-lowering-*.f64N/A

                                          \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                        3. unpow2N/A

                                          \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                        4. *-lowering-*.f6432.6%

                                          \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                                      4. Simplified32.6%

                                        \[\leadsto \color{blue}{1 + 0.5 \cdot \left(im \cdot im\right)} \]
                                      5. Taylor expanded in im around inf

                                        \[\leadsto \color{blue}{\frac{1}{2} \cdot {im}^{2}} \]
                                      6. Step-by-step derivation
                                        1. *-lowering-*.f64N/A

                                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left({im}^{2}\right)}\right) \]
                                        2. unpow2N/A

                                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \left(im \cdot \color{blue}{im}\right)\right) \]
                                        3. *-lowering-*.f6432.6%

                                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right) \]
                                      7. Simplified32.6%

                                        \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot im\right)} \]
                                    9. Recombined 2 regimes into one program.
                                    10. Add Preprocessing

                                    Alternative 24: 47.3% accurate, 44.0× speedup?

                                    \[\begin{array}{l} \\ 0.5 \cdot \left(2 + im \cdot im\right) \end{array} \]
                                    (FPCore (re im) :precision binary64 (* 0.5 (+ 2.0 (* im im))))
                                    double code(double re, double im) {
                                    	return 0.5 * (2.0 + (im * im));
                                    }
                                    
                                    real(8) function code(re, im)
                                        real(8), intent (in) :: re
                                        real(8), intent (in) :: im
                                        code = 0.5d0 * (2.0d0 + (im * im))
                                    end function
                                    
                                    public static double code(double re, double im) {
                                    	return 0.5 * (2.0 + (im * im));
                                    }
                                    
                                    def code(re, im):
                                    	return 0.5 * (2.0 + (im * im))
                                    
                                    function code(re, im)
                                    	return Float64(0.5 * Float64(2.0 + Float64(im * im)))
                                    end
                                    
                                    function tmp = code(re, im)
                                    	tmp = 0.5 * (2.0 + (im * im));
                                    end
                                    
                                    code[re_, im_] := N[(0.5 * N[(2.0 + N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    0.5 \cdot \left(2 + im \cdot 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. Taylor expanded in im around 0

                                      \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                                    4. Step-by-step derivation
                                      1. +-lowering-+.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                      2. unpow2N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                      3. *-lowering-*.f6475.3%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                                    5. Simplified75.3%

                                      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(2 + im \cdot im\right)} \]
                                    6. Taylor expanded in re around 0

                                      \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(2 + {im}^{2}\right)} \]
                                    7. Step-by-step derivation
                                      1. *-lowering-*.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(2 + {im}^{2}\right)}\right) \]
                                      2. +-lowering-+.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \color{blue}{\left({im}^{2}\right)}\right)\right) \]
                                      3. unpow2N/A

                                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                                      4. *-lowering-*.f6446.2%

                                        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right)\right) \]
                                    8. Simplified46.2%

                                      \[\leadsto \color{blue}{0.5 \cdot \left(2 + im \cdot im\right)} \]
                                    9. Add Preprocessing

                                    Alternative 25: 29.0% accurate, 308.0× speedup?

                                    \[\begin{array}{l} \\ 1 \end{array} \]
                                    (FPCore (re im) :precision binary64 1.0)
                                    double code(double re, double im) {
                                    	return 1.0;
                                    }
                                    
                                    real(8) function code(re, im)
                                        real(8), intent (in) :: re
                                        real(8), intent (in) :: im
                                        code = 1.0d0
                                    end function
                                    
                                    public static double code(double re, double im) {
                                    	return 1.0;
                                    }
                                    
                                    def code(re, im):
                                    	return 1.0
                                    
                                    function code(re, im)
                                    	return 1.0
                                    end
                                    
                                    function tmp = code(re, im)
                                    	tmp = 1.0;
                                    end
                                    
                                    code[re_, im_] := 1.0
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    1
                                    \end{array}
                                    
                                    Derivation
                                    1. Initial program 100.0%

                                      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
                                    2. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto \left(\cos re \cdot \frac{1}{2}\right) \cdot \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} + e^{im}\right) \]
                                      2. associate-*l*N/A

                                        \[\leadsto \cos re \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)} \]
                                      3. *-lowering-*.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\cos re, \color{blue}{\left(\frac{1}{2} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)}\right) \]
                                      4. cos-lowering-cos.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\color{blue}{\frac{1}{2}} \cdot \left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right)\right)\right) \]
                                      5. +-commutativeN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(\frac{1}{2} \cdot \left(e^{im} + \color{blue}{e^{\mathsf{neg}\left(im\right)}}\right)\right)\right) \]
                                      6. distribute-rgt-inN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \left(e^{im} \cdot \frac{1}{2} + \color{blue}{e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}}\right)\right) \]
                                      7. +-lowering-+.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(e^{im} \cdot \frac{1}{2}\right), \color{blue}{\left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)}\right)\right) \]
                                      8. *-commutativeN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot e^{im}\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                      9. *-lowering-*.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(e^{im}\right)\right), \left(\color{blue}{e^{\mathsf{neg}\left(im\right)}} \cdot \frac{1}{2}\right)\right)\right) \]
                                      10. exp-lowering-exp.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(e^{\mathsf{neg}\left(im\right)} \cdot \frac{1}{2}\right)\right)\right) \]
                                      11. exp-negN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1}{e^{im}} \cdot \frac{1}{2}\right)\right)\right) \]
                                      12. associate-*l/N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{1 \cdot \frac{1}{2}}{\color{blue}{e^{im}}}\right)\right)\right) \]
                                      13. metadata-evalN/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \left(\frac{\frac{1}{2}}{e^{\color{blue}{im}}}\right)\right)\right) \]
                                      14. /-lowering-/.f64N/A

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(e^{im}\right)}\right)\right)\right) \]
                                      15. exp-lowering-exp.f64100.0%

                                        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right), \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
                                    3. Simplified100.0%

                                      \[\leadsto \color{blue}{\cos re \cdot \left(0.5 \cdot e^{im} + \frac{0.5}{e^{im}}\right)} \]
                                    4. Add Preprocessing
                                    5. Taylor expanded in im around 0

                                      \[\leadsto \color{blue}{\cos re} \]
                                    6. Step-by-step derivation
                                      1. cos-lowering-cos.f6449.1%

                                        \[\leadsto \mathsf{cos.f64}\left(re\right) \]
                                    7. Simplified49.1%

                                      \[\leadsto \color{blue}{\cos re} \]
                                    8. Taylor expanded in re around 0

                                      \[\leadsto \color{blue}{1} \]
                                    9. Step-by-step derivation
                                      1. Simplified27.6%

                                        \[\leadsto \color{blue}{1} \]
                                      2. Add Preprocessing

                                      Reproduce

                                      ?
                                      herbie shell --seed 2024154 
                                      (FPCore (re im)
                                        :name "math.cos on complex, real part"
                                        :precision binary64
                                        (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))