math.cos on complex, real part

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

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

Initial Program: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \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. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos 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) \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
  5. 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) \]
  6. Applied egg-rr100.0%

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

Alternative 2: 94.6% accurate, 2.4× speedup?

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

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

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

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


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

    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 \color{blue}{\cos re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right) + \cos re \]
      3. distribute-lft-inN/A

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

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

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

    if 0.450000000000000011 < im < 7e51

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos 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) \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
    5. 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) \]
    6. Applied egg-rr100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{-1}{2}\right)\right)\right) \]
      5. *-lowering-*.f6492.3%

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

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

    if 7e51 < im

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos 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) \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
    5. 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) \]
    6. Simplified100.0%

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

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

Alternative 3: 94.6% accurate, 2.4× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 0.619999999999999996 or 7e51 < im

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos 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) \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
    5. 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) \]
    6. Simplified95.4%

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

    if 0.619999999999999996 < im < 7e51

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos 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) \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
    5. 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) \]
    6. Applied egg-rr100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{-1}{2}\right)\right)\right) \]
      5. *-lowering-*.f6492.3%

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

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

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

Alternative 4: 92.0% accurate, 2.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 0.12 or 3.6000000000000003e76 < 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 \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)} \]
    4. 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. associate-+r+N/A

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

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

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

    if 0.12 < im < 3.6000000000000003e76

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos 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) \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
    5. 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) \]
    6. Applied egg-rr100.0%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{-1}{2}\right)\right)\right) \]
      5. *-lowering-*.f6489.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.12:\\ \;\;\;\;\cos re \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{elif}\;im \leq 3.6 \cdot 10^{+76}:\\ \;\;\;\;\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 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 84.4% accurate, 2.5× speedup?

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

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

\mathbf{elif}\;im \leq 8 \cdot 10^{+127}:\\
\;\;\;\;\cosh im\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 0.0280000000000000006 or 1.35000000000000003e154 < 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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0280000000000000006 < im < 7.99999999999999964e127

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos 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) \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
    5. 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) \]
    6. Applied egg-rr100.0%

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

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

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

      if 7.99999999999999964e127 < im < 1.35000000000000003e154

      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 \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)} \]
      4. 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. associate-+r+N/A

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.028:\\ \;\;\;\;\cos re \cdot \left(1 + \left(im \cdot im\right) \cdot 0.5\right)\\ \mathbf{elif}\;im \leq 8 \cdot 10^{+127}:\\ \;\;\;\;\cosh im\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\left(1 + \left(im \cdot im\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(1 + \left(im \cdot im\right) \cdot 0.5\right)\\ \end{array} \]
    11. Add Preprocessing

    Alternative 6: 84.2% accurate, 2.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos re \cdot \left(1 + \left(im \cdot im\right) \cdot 0.5\right)\\ \mathbf{if}\;im \leq 0.0155:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\cosh im \cdot \left(1 + \left(re \cdot re\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (re im)
     :precision binary64
     (let* ((t_0 (* (cos re) (+ 1.0 (* (* im im) 0.5)))))
       (if (<= im 0.0155)
         t_0
         (if (<= im 1.35e+154) (* (cosh im) (+ 1.0 (* (* re re) -0.5))) t_0))))
    double code(double re, double im) {
    	double t_0 = cos(re) * (1.0 + ((im * im) * 0.5));
    	double tmp;
    	if (im <= 0.0155) {
    		tmp = t_0;
    	} else if (im <= 1.35e+154) {
    		tmp = cosh(im) * (1.0 + ((re * re) * -0.5));
    	} 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) * (1.0d0 + ((im * im) * 0.5d0))
        if (im <= 0.0155d0) then
            tmp = t_0
        else if (im <= 1.35d+154) then
            tmp = cosh(im) * (1.0d0 + ((re * re) * (-0.5d0)))
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double re, double im) {
    	double t_0 = Math.cos(re) * (1.0 + ((im * im) * 0.5));
    	double tmp;
    	if (im <= 0.0155) {
    		tmp = t_0;
    	} else if (im <= 1.35e+154) {
    		tmp = Math.cosh(im) * (1.0 + ((re * re) * -0.5));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(re, im):
    	t_0 = math.cos(re) * (1.0 + ((im * im) * 0.5))
    	tmp = 0
    	if im <= 0.0155:
    		tmp = t_0
    	elif im <= 1.35e+154:
    		tmp = math.cosh(im) * (1.0 + ((re * re) * -0.5))
    	else:
    		tmp = t_0
    	return tmp
    
    function code(re, im)
    	t_0 = Float64(cos(re) * Float64(1.0 + Float64(Float64(im * im) * 0.5)))
    	tmp = 0.0
    	if (im <= 0.0155)
    		tmp = t_0;
    	elseif (im <= 1.35e+154)
    		tmp = Float64(cosh(im) * Float64(1.0 + Float64(Float64(re * re) * -0.5)));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(re, im)
    	t_0 = cos(re) * (1.0 + ((im * im) * 0.5));
    	tmp = 0.0;
    	if (im <= 0.0155)
    		tmp = t_0;
    	elseif (im <= 1.35e+154)
    		tmp = cosh(im) * (1.0 + ((re * re) * -0.5));
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[re_, im_] := Block[{t$95$0 = N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(N[(im * im), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.0155], t$95$0, If[LessEqual[im, 1.35e+154], N[(N[Cosh[im], $MachinePrecision] * N[(1.0 + N[(N[(re * re), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \cos re \cdot \left(1 + \left(im \cdot im\right) \cdot 0.5\right)\\
    \mathbf{if}\;im \leq 0.0155:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
    \;\;\;\;\cosh im \cdot \left(1 + \left(re \cdot re\right) \cdot -0.5\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if im < 0.0155 or 1.35000000000000003e154 < 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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
      4. Step-by-step derivation
        1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 0.0155 < im < 1.35000000000000003e154

      1. Initial program 100.0%

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos 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) \]
      4. Applied egg-rr100.0%

        \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
      5. 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) \]
      6. Applied egg-rr100.0%

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\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{cosh.f64}\left(im\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{-1}{2}\right)\right)\right) \]
        5. *-lowering-*.f6486.2%

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 0.0155:\\ \;\;\;\;\cos re \cdot \left(1 + \left(im \cdot im\right) \cdot 0.5\right)\\ \mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\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 0.5\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 7: 69.5% accurate, 2.8× speedup?

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

      1. Initial program 100.0%

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

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

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

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

      if 2.00000000000000016e-5 < im < 1.99999999999999985e126

      1. Initial program 100.0%

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\left(\frac{1}{2} \cdot \left(e^{im} + e^{\mathsf{neg}\left(im\right)}\right)\right), \cos 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) \]
      4. Applied egg-rr100.0%

        \[\leadsto \color{blue}{\left(1 \cdot \cosh im\right) \cdot \cos re} \]
      5. 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) \]
      6. Applied egg-rr100.0%

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

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

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

        if 1.99999999999999985e126 < 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 \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)} \]
        4. 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. associate-+r+N/A

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \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), \mathsf{+.f64}\left(\color{blue}{\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)}, 1\right)\right) \]
          2. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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), \frac{-1}{720}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), 1\right)\right) \]
          19. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), 1\right)\right) \]
          20. *-lowering-*.f6481.6%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), 1\right)\right) \]
        8. Simplified81.6%

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

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

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

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

            \[\leadsto {im}^{4} \cdot \left(\frac{1}{24} \cdot \color{blue}{\left(1 + {re}^{2} \cdot \left({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(\left({im}^{4}\right), \color{blue}{\left(\frac{1}{24} \cdot \left(1 + {re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right)\right)\right)}\right) \]
          5. metadata-evalN/A

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

            \[\leadsto \mathsf{*.f64}\left(\left({im}^{2} \cdot {im}^{2}\right), \left(\color{blue}{\frac{1}{24}} \cdot \left(1 + {re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right)\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}{24}} \cdot \left(1 + {re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right)\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}{24} \cdot \left(1 + {re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right)\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}{24} \cdot \left(1 + {re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right)\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}{24} \cdot \left(1 + {re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right)\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}{24} \cdot \left(1 + {re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right)\right)\right)\right) \]
          12. distribute-rgt-inN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(im, im\right)\right), \left(1 \cdot \frac{1}{24} + \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) \cdot \frac{1}{24}}\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}{\left({re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right)\right)} \cdot \frac{1}{24}\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(\left({re}^{2} \cdot \left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right)\right) \cdot \frac{1}{24}\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(\left({re}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {re}^{2}\right) - \frac{1}{2}\right) \cdot {re}^{2}\right) \cdot \frac{1}{24}\right)\right)\right) \]
        11. Simplified81.6%

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

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

      Alternative 8: 67.2% accurate, 2.9× speedup?

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

        1. Initial program 100.0%

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

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

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

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

        if 2.1999999999999999e-5 < 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 \color{blue}{\cos re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right)} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right) + \cos re \]
          3. distribute-lft-inN/A

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \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), \mathsf{+.f64}\left(\color{blue}{\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)\right) \]
          2. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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), \frac{-1}{720}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)\right) \]
          19. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)\right) \]
          20. *-lowering-*.f6466.6%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)\right) \]
        8. Simplified66.6%

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

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

      Alternative 9: 58.0% accurate, 6.4× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\\ \mathbf{if}\;re \leq 1.5 \cdot 10^{+154}:\\ \;\;\;\;\left(t\_0 \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) + \left(1 + \left(im \cdot im\right) \cdot 0.5\right)\right) \cdot \left(1 + re \cdot \left(re \cdot \left(-0.5 + re \cdot \left(re \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.001388888888888889\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot t\_0\right)\right)\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (let* ((t_0 (+ 0.041666666666666664 (* (* im im) 0.001388888888888889))))
         (if (<= re 1.5e+154)
           (*
            (+ (* t_0 (* im (* im (* im im)))) (+ 1.0 (* (* im im) 0.5)))
            (+
             1.0
             (*
              re
              (*
               re
               (+
                -0.5
                (*
                 re
                 (*
                  re
                  (+ 0.041666666666666664 (* (* re re) -0.001388888888888889)))))))))
           (+ 1.0 (* im (* im (+ 0.5 (* im (* im t_0)))))))))
      double code(double re, double im) {
      	double t_0 = 0.041666666666666664 + ((im * im) * 0.001388888888888889);
      	double tmp;
      	if (re <= 1.5e+154) {
      		tmp = ((t_0 * (im * (im * (im * im)))) + (1.0 + ((im * im) * 0.5))) * (1.0 + (re * (re * (-0.5 + (re * (re * (0.041666666666666664 + ((re * re) * -0.001388888888888889))))))));
      	} else {
      		tmp = 1.0 + (im * (im * (0.5 + (im * (im * t_0)))));
      	}
      	return tmp;
      }
      
      real(8) function code(re, im)
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8) :: t_0
          real(8) :: tmp
          t_0 = 0.041666666666666664d0 + ((im * im) * 0.001388888888888889d0)
          if (re <= 1.5d+154) then
              tmp = ((t_0 * (im * (im * (im * im)))) + (1.0d0 + ((im * im) * 0.5d0))) * (1.0d0 + (re * (re * ((-0.5d0) + (re * (re * (0.041666666666666664d0 + ((re * re) * (-0.001388888888888889d0)))))))))
          else
              tmp = 1.0d0 + (im * (im * (0.5d0 + (im * (im * t_0)))))
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double t_0 = 0.041666666666666664 + ((im * im) * 0.001388888888888889);
      	double tmp;
      	if (re <= 1.5e+154) {
      		tmp = ((t_0 * (im * (im * (im * im)))) + (1.0 + ((im * im) * 0.5))) * (1.0 + (re * (re * (-0.5 + (re * (re * (0.041666666666666664 + ((re * re) * -0.001388888888888889))))))));
      	} else {
      		tmp = 1.0 + (im * (im * (0.5 + (im * (im * t_0)))));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	t_0 = 0.041666666666666664 + ((im * im) * 0.001388888888888889)
      	tmp = 0
      	if re <= 1.5e+154:
      		tmp = ((t_0 * (im * (im * (im * im)))) + (1.0 + ((im * im) * 0.5))) * (1.0 + (re * (re * (-0.5 + (re * (re * (0.041666666666666664 + ((re * re) * -0.001388888888888889))))))))
      	else:
      		tmp = 1.0 + (im * (im * (0.5 + (im * (im * t_0)))))
      	return tmp
      
      function code(re, im)
      	t_0 = Float64(0.041666666666666664 + Float64(Float64(im * im) * 0.001388888888888889))
      	tmp = 0.0
      	if (re <= 1.5e+154)
      		tmp = Float64(Float64(Float64(t_0 * Float64(im * Float64(im * Float64(im * im)))) + Float64(1.0 + Float64(Float64(im * im) * 0.5))) * Float64(1.0 + Float64(re * Float64(re * Float64(-0.5 + Float64(re * Float64(re * Float64(0.041666666666666664 + Float64(Float64(re * re) * -0.001388888888888889)))))))));
      	else
      		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(im * Float64(im * t_0))))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	t_0 = 0.041666666666666664 + ((im * im) * 0.001388888888888889);
      	tmp = 0.0;
      	if (re <= 1.5e+154)
      		tmp = ((t_0 * (im * (im * (im * im)))) + (1.0 + ((im * im) * 0.5))) * (1.0 + (re * (re * (-0.5 + (re * (re * (0.041666666666666664 + ((re * re) * -0.001388888888888889))))))));
      	else
      		tmp = 1.0 + (im * (im * (0.5 + (im * (im * t_0)))));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := Block[{t$95$0 = N[(0.041666666666666664 + N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 1.5e+154], N[(N[(N[(t$95$0 * N[(im * N[(im * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(N[(im * im), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(re * N[(re * N[(-0.5 + N[(re * N[(re * N[(0.041666666666666664 + N[(N[(re * re), $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(im * N[(im * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := 0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\\
      \mathbf{if}\;re \leq 1.5 \cdot 10^{+154}:\\
      \;\;\;\;\left(t\_0 \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) + \left(1 + \left(im \cdot im\right) \cdot 0.5\right)\right) \cdot \left(1 + re \cdot \left(re \cdot \left(-0.5 + re \cdot \left(re \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.001388888888888889\right)\right)\right)\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot t\_0\right)\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if re < 1.50000000000000013e154

        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 \color{blue}{\cos re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right)} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right) + \cos re \]
          3. distribute-lft-inN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right) + \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re\right) + \cos re\right)} \]
        5. Simplified90.9%

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \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), \mathsf{+.f64}\left(\color{blue}{\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)\right) \]
          2. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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), \frac{-1}{720}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)\right) \]
          19. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)\right) \]
          20. *-lowering-*.f6465.5%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right), \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, im\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right)\right) \]
        8. Simplified65.5%

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

        if 1.50000000000000013e154 < re

        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 \color{blue}{\cos re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right)} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right) + \cos re \]
          3. distribute-lft-inN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right) + \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re\right) + \cos re\right)} \]
        5. Simplified89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + {im}^{2} \cdot \left({im}^{\left(2 \cdot 2\right)} \cdot \frac{1}{720} + \frac{1}{2}\right)\right)\right) \]
          13. pow-sqrN/A

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

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

            \[\leadsto \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}\right)\right)\right) \]
        8. Simplified35.6%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.5 \cdot 10^{+154}:\\ \;\;\;\;\left(\left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right) \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) + \left(1 + \left(im \cdot im\right) \cdot 0.5\right)\right) \cdot \left(1 + re \cdot \left(re \cdot \left(-0.5 + re \cdot \left(re \cdot \left(0.041666666666666664 + \left(re \cdot re\right) \cdot -0.001388888888888889\right)\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 10: 57.8% accurate, 9.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)\\ \mathbf{if}\;re \leq 1.5 \cdot 10^{+154}:\\ \;\;\;\;t\_0 \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (let* ((t_0
               (+
                1.0
                (*
                 im
                 (*
                  im
                  (+
                   0.5
                   (*
                    im
                    (*
                     im
                     (+
                      0.041666666666666664
                      (* (* im im) 0.001388888888888889))))))))))
         (if (<= re 1.5e+154) (* t_0 (+ 1.0 (* re (* re -0.5)))) t_0)))
      double code(double re, double im) {
      	double t_0 = 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))));
      	double tmp;
      	if (re <= 1.5e+154) {
      		tmp = t_0 * (1.0 + (re * (re * -0.5)));
      	} 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 * (0.041666666666666664d0 + ((im * im) * 0.001388888888888889d0)))))))
          if (re <= 1.5d+154) then
              tmp = t_0 * (1.0d0 + (re * (re * (-0.5d0))))
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double t_0 = 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))));
      	double tmp;
      	if (re <= 1.5e+154) {
      		tmp = t_0 * (1.0 + (re * (re * -0.5)));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(re, im):
      	t_0 = 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))))
      	tmp = 0
      	if re <= 1.5e+154:
      		tmp = t_0 * (1.0 + (re * (re * -0.5)))
      	else:
      		tmp = t_0
      	return tmp
      
      function code(re, im)
      	t_0 = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(im * Float64(im * Float64(0.041666666666666664 + Float64(Float64(im * im) * 0.001388888888888889))))))))
      	tmp = 0.0
      	if (re <= 1.5e+154)
      		tmp = Float64(t_0 * Float64(1.0 + Float64(re * Float64(re * -0.5))));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	t_0 = 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))));
      	tmp = 0.0;
      	if (re <= 1.5e+154)
      		tmp = t_0 * (1.0 + (re * (re * -0.5)));
      	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[(im * N[(im * N[(0.041666666666666664 + N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 1.5e+154], N[(t$95$0 * N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := 1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)\\
      \mathbf{if}\;re \leq 1.5 \cdot 10^{+154}:\\
      \;\;\;\;t\_0 \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if re < 1.50000000000000013e154

        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 \color{blue}{\cos re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right)} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right) + \cos re \]
          3. distribute-lft-inN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right) + \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re\right) + \cos re\right)} \]
        5. Simplified90.9%

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

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

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

        if 1.50000000000000013e154 < re

        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 \color{blue}{\cos re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right)} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right) + \cos re \]
          3. distribute-lft-inN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right) + \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re\right) + \cos re\right)} \]
        5. Simplified89.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + {im}^{2} \cdot \left({im}^{\left(2 \cdot 2\right)} \cdot \frac{1}{720} + \frac{1}{2}\right)\right)\right) \]
          13. pow-sqrN/A

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

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

            \[\leadsto \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}\right)\right)\right) \]
        8. Simplified35.6%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 1.5 \cdot 10^{+154}:\\ \;\;\;\;\left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 11: 59.2% accurate, 11.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 8 \cdot 10^{+128}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(im \cdot im\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= im 8e+128)
         (+
          1.0
          (*
           im
           (*
            im
            (+
             0.5
             (*
              im
              (* im (+ 0.041666666666666664 (* (* im im) 0.001388888888888889))))))))
         (*
          (+ 1.0 (* (* im im) (+ 0.5 (* 0.041666666666666664 (* im im)))))
          (+ 1.0 (* re (* re -0.5))))))
      double code(double re, double im) {
      	double tmp;
      	if (im <= 8e+128) {
      		tmp = 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))));
      	} else {
      		tmp = (1.0 + ((im * im) * (0.5 + (0.041666666666666664 * (im * im))))) * (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 (im <= 8d+128) then
              tmp = 1.0d0 + (im * (im * (0.5d0 + (im * (im * (0.041666666666666664d0 + ((im * im) * 0.001388888888888889d0)))))))
          else
              tmp = (1.0d0 + ((im * im) * (0.5d0 + (0.041666666666666664d0 * (im * im))))) * (1.0d0 + (re * (re * (-0.5d0))))
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double tmp;
      	if (im <= 8e+128) {
      		tmp = 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))));
      	} else {
      		tmp = (1.0 + ((im * im) * (0.5 + (0.041666666666666664 * (im * im))))) * (1.0 + (re * (re * -0.5)));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if im <= 8e+128:
      		tmp = 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))))
      	else:
      		tmp = (1.0 + ((im * im) * (0.5 + (0.041666666666666664 * (im * im))))) * (1.0 + (re * (re * -0.5)))
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if (im <= 8e+128)
      		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(im * Float64(im * Float64(0.041666666666666664 + Float64(Float64(im * im) * 0.001388888888888889))))))));
      	else
      		tmp = Float64(Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(0.041666666666666664 * Float64(im * im))))) * Float64(1.0 + Float64(re * Float64(re * -0.5))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if (im <= 8e+128)
      		tmp = 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))));
      	else
      		tmp = (1.0 + ((im * im) * (0.5 + (0.041666666666666664 * (im * im))))) * (1.0 + (re * (re * -0.5)));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[LessEqual[im, 8e+128], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(im * N[(im * N[(0.041666666666666664 + N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(0.041666666666666664 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(re * N[(re * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;im \leq 8 \cdot 10^{+128}:\\
      \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(1 + \left(im \cdot im\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if im < 8.0000000000000006e128

        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 \color{blue}{\cos re + {im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re + {im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right)} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

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

            \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right) + \cos re \]
          3. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + {im}^{2} \cdot \left({im}^{\left(2 \cdot 2\right)} \cdot \frac{1}{720} + \frac{1}{2}\right)\right)\right) \]
          13. pow-sqrN/A

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

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

            \[\leadsto \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}\right)\right)\right) \]
        8. Simplified55.7%

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

        if 8.0000000000000006e128 < 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 \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)} \]
        4. 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. associate-+r+N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 8 \cdot 10^{+128}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \left(im \cdot im\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right) \cdot \left(1 + re \cdot \left(re \cdot -0.5\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 12: 55.5% accurate, 13.4× speedup?

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

        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 \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)} \]
        4. 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. associate-+r+N/A

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

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

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

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

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

            \[\leadsto \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{2}} + \frac{1}{24} \cdot {im}^{2}\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} + \frac{1}{24} \cdot {im}^{2}\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} + \frac{1}{24} \cdot {im}^{2}\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} + \frac{1}{24} \cdot {im}^{2}\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(\frac{1}{24} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
          7. *-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \color{blue}{\frac{1}{24}}\right)\right)\right)\right)\right) \]
          8. *-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}{\frac{1}{24}}\right)\right)\right)\right)\right) \]
          9. 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), \frac{1}{24}\right)\right)\right)\right)\right) \]
          10. *-lowering-*.f6462.6%

            \[\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), \frac{1}{24}\right)\right)\right)\right)\right) \]
        8. Simplified62.6%

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

        if 2.0999999999999999e25 < re < 1.50000000000000013e154

        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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
        4. Step-by-step derivation
          1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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), \frac{-1}{720}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
          19. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
          20. *-lowering-*.f6430.3%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
        8. Simplified30.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \left(\color{blue}{\frac{-1}{2}} \cdot \frac{1}{2}\right)\right)\right)\right) \]
          15. metadata-eval27.3%

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

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

        if 1.50000000000000013e154 < re

        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 \color{blue}{\cos re} \]
        4. Step-by-step derivation
          1. cos-lowering-cos.f6452.7%

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

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

          \[\leadsto \color{blue}{1 + {re}^{2} \cdot \left(\frac{1}{24} \cdot {re}^{2} - \frac{1}{2}\right)} \]
        7. 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. *-lowering-*.f64N/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\left(\frac{1}{24} \cdot {re}^{2} - \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}{\frac{1}{24} \cdot {re}^{2}} - \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}{\frac{1}{24} \cdot {re}^{2}} - \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(\frac{1}{24} \cdot {re}^{2} + \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(\frac{1}{24} \cdot {re}^{2} + \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}{\frac{1}{24} \cdot {re}^{2}}\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(\frac{1}{24} \cdot {re}^{2}\right)}\right)\right)\right) \]
          9. *-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \left({re}^{2} \cdot \color{blue}{\frac{1}{24}}\right)\right)\right)\right) \]
          10. 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 \frac{1}{24}\right)\right)\right)\right) \]
          11. 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 \frac{1}{24}\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, \color{blue}{\left(re \cdot \frac{1}{24}\right)}\right)\right)\right)\right) \]
          13. *-lowering-*.f6434.4%

            \[\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}{\frac{1}{24}}\right)\right)\right)\right)\right) \]
        8. Simplified34.4%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 2.1 \cdot 10^{+25}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{elif}\;re \leq 1.5 \cdot 10^{+154}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(re \cdot re\right) \cdot \left(-0.5 + re \cdot \left(re \cdot 0.041666666666666664\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 13: 55.5% accurate, 14.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 2.1 \cdot 10^{+25}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{elif}\;re \leq 1.5 \cdot 10^{+154}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= re 2.1e+25)
         (+ 1.0 (* im (* im (+ 0.5 (* 0.041666666666666664 (* im im))))))
         (if (<= re 1.5e+154)
           (* (* im im) (+ 0.5 (* (* re re) -0.25)))
           (* 0.041666666666666664 (* (* re re) (* re re))))))
      double code(double re, double im) {
      	double tmp;
      	if (re <= 2.1e+25) {
      		tmp = 1.0 + (im * (im * (0.5 + (0.041666666666666664 * (im * im)))));
      	} else if (re <= 1.5e+154) {
      		tmp = (im * im) * (0.5 + ((re * re) * -0.25));
      	} 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 <= 2.1d+25) then
              tmp = 1.0d0 + (im * (im * (0.5d0 + (0.041666666666666664d0 * (im * im)))))
          else if (re <= 1.5d+154) then
              tmp = (im * im) * (0.5d0 + ((re * re) * (-0.25d0)))
          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 <= 2.1e+25) {
      		tmp = 1.0 + (im * (im * (0.5 + (0.041666666666666664 * (im * im)))));
      	} else if (re <= 1.5e+154) {
      		tmp = (im * im) * (0.5 + ((re * re) * -0.25));
      	} else {
      		tmp = 0.041666666666666664 * ((re * re) * (re * re));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if re <= 2.1e+25:
      		tmp = 1.0 + (im * (im * (0.5 + (0.041666666666666664 * (im * im)))))
      	elif re <= 1.5e+154:
      		tmp = (im * im) * (0.5 + ((re * re) * -0.25))
      	else:
      		tmp = 0.041666666666666664 * ((re * re) * (re * re))
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if (re <= 2.1e+25)
      		tmp = Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(0.041666666666666664 * Float64(im * im))))));
      	elseif (re <= 1.5e+154)
      		tmp = Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(re * re) * -0.25)));
      	else
      		tmp = Float64(0.041666666666666664 * Float64(Float64(re * re) * Float64(re * re)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if (re <= 2.1e+25)
      		tmp = 1.0 + (im * (im * (0.5 + (0.041666666666666664 * (im * im)))));
      	elseif (re <= 1.5e+154)
      		tmp = (im * im) * (0.5 + ((re * re) * -0.25));
      	else
      		tmp = 0.041666666666666664 * ((re * re) * (re * re));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[LessEqual[re, 2.1e+25], N[(1.0 + N[(im * N[(im * N[(0.5 + N[(0.041666666666666664 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.5e+154], N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.041666666666666664 * N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;re \leq 2.1 \cdot 10^{+25}:\\
      \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right)\\
      
      \mathbf{elif}\;re \leq 1.5 \cdot 10^{+154}:\\
      \;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;0.041666666666666664 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if re < 2.0999999999999999e25

        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 \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)} \]
        4. 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. associate-+r+N/A

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

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

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

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

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

            \[\leadsto \mathsf{+.f64}\left(1, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{\frac{1}{2}} + \frac{1}{24} \cdot {im}^{2}\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} + \frac{1}{24} \cdot {im}^{2}\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} + \frac{1}{24} \cdot {im}^{2}\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} + \frac{1}{24} \cdot {im}^{2}\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(\frac{1}{24} \cdot {im}^{2}\right)}\right)\right)\right)\right) \]
          7. *-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(\frac{1}{2}, \left({im}^{2} \cdot \color{blue}{\frac{1}{24}}\right)\right)\right)\right)\right) \]
          8. *-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}{\frac{1}{24}}\right)\right)\right)\right)\right) \]
          9. 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), \frac{1}{24}\right)\right)\right)\right)\right) \]
          10. *-lowering-*.f6462.6%

            \[\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), \frac{1}{24}\right)\right)\right)\right)\right) \]
        8. Simplified62.6%

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

        if 2.0999999999999999e25 < re < 1.50000000000000013e154

        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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
        4. Step-by-step derivation
          1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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), \frac{-1}{720}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
          19. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
          20. *-lowering-*.f6430.3%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
        8. Simplified30.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \left(\color{blue}{\frac{-1}{2}} \cdot \frac{1}{2}\right)\right)\right)\right) \]
          15. metadata-eval27.3%

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

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

        if 1.50000000000000013e154 < re

        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 \color{blue}{\cos re} \]
        4. Step-by-step derivation
          1. cos-lowering-cos.f6452.7%

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

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

          \[\leadsto \color{blue}{1 + {re}^{2} \cdot \left(\frac{1}{24} \cdot {re}^{2} - \frac{1}{2}\right)} \]
        7. 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. *-lowering-*.f64N/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\left(\frac{1}{24} \cdot {re}^{2} - \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}{\frac{1}{24} \cdot {re}^{2}} - \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}{\frac{1}{24} \cdot {re}^{2}} - \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(\frac{1}{24} \cdot {re}^{2} + \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(\frac{1}{24} \cdot {re}^{2} + \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}{\frac{1}{24} \cdot {re}^{2}}\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(\frac{1}{24} \cdot {re}^{2}\right)}\right)\right)\right) \]
          9. *-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \left({re}^{2} \cdot \color{blue}{\frac{1}{24}}\right)\right)\right)\right) \]
          10. 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 \frac{1}{24}\right)\right)\right)\right) \]
          11. 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 \frac{1}{24}\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, \color{blue}{\left(re \cdot \frac{1}{24}\right)}\right)\right)\right)\right) \]
          13. *-lowering-*.f6434.4%

            \[\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}{\frac{1}{24}}\right)\right)\right)\right)\right) \]
        8. Simplified34.4%

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

          \[\leadsto \color{blue}{\frac{1}{24} \cdot {re}^{4}} \]
        10. 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. *-lowering-*.f64N/A

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right) \]
        11. Simplified34.4%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 2.1 \cdot 10^{+25}:\\ \;\;\;\;1 + im \cdot \left(im \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im \cdot im\right)\right)\right)\\ \mathbf{elif}\;re \leq 1.5 \cdot 10^{+154}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 14: 48.0% accurate, 14.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 2.1 \cdot 10^{+25}:\\ \;\;\;\;1 + \left(im \cdot im\right) \cdot 0.5\\ \mathbf{elif}\;re \leq 1.5 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(re \cdot \left(-0.5 + \left(im \cdot im\right) \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= re 2.1e+25)
         (+ 1.0 (* (* im im) 0.5))
         (if (<= re 1.5e+154)
           (* re (* re (+ -0.5 (* (* im im) -0.25))))
           (* 0.041666666666666664 (* (* re re) (* re re))))))
      double code(double re, double im) {
      	double tmp;
      	if (re <= 2.1e+25) {
      		tmp = 1.0 + ((im * im) * 0.5);
      	} else if (re <= 1.5e+154) {
      		tmp = re * (re * (-0.5 + ((im * im) * -0.25)));
      	} 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 <= 2.1d+25) then
              tmp = 1.0d0 + ((im * im) * 0.5d0)
          else if (re <= 1.5d+154) then
              tmp = re * (re * ((-0.5d0) + ((im * im) * (-0.25d0))))
          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 <= 2.1e+25) {
      		tmp = 1.0 + ((im * im) * 0.5);
      	} else if (re <= 1.5e+154) {
      		tmp = re * (re * (-0.5 + ((im * im) * -0.25)));
      	} else {
      		tmp = 0.041666666666666664 * ((re * re) * (re * re));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if re <= 2.1e+25:
      		tmp = 1.0 + ((im * im) * 0.5)
      	elif re <= 1.5e+154:
      		tmp = re * (re * (-0.5 + ((im * im) * -0.25)))
      	else:
      		tmp = 0.041666666666666664 * ((re * re) * (re * re))
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if (re <= 2.1e+25)
      		tmp = Float64(1.0 + Float64(Float64(im * im) * 0.5));
      	elseif (re <= 1.5e+154)
      		tmp = Float64(re * Float64(re * Float64(-0.5 + Float64(Float64(im * im) * -0.25))));
      	else
      		tmp = Float64(0.041666666666666664 * Float64(Float64(re * re) * Float64(re * re)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if (re <= 2.1e+25)
      		tmp = 1.0 + ((im * im) * 0.5);
      	elseif (re <= 1.5e+154)
      		tmp = re * (re * (-0.5 + ((im * im) * -0.25)));
      	else
      		tmp = 0.041666666666666664 * ((re * re) * (re * re));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[LessEqual[re, 2.1e+25], N[(1.0 + N[(N[(im * im), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.5e+154], N[(re * N[(re * N[(-0.5 + N[(N[(im * im), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.041666666666666664 * N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;re \leq 2.1 \cdot 10^{+25}:\\
      \;\;\;\;1 + \left(im \cdot im\right) \cdot 0.5\\
      
      \mathbf{elif}\;re \leq 1.5 \cdot 10^{+154}:\\
      \;\;\;\;re \cdot \left(re \cdot \left(-0.5 + \left(im \cdot im\right) \cdot -0.25\right)\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;0.041666666666666664 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if re < 2.0999999999999999e25

        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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
        4. Step-by-step derivation
          1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{1 + \frac{1}{2} \cdot {im}^{2}} \]
        7. Step-by-step derivation
          1. +-lowering-+.f64N/A

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

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

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

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

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

        if 2.0999999999999999e25 < re < 1.50000000000000013e154

        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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
        4. Step-by-step derivation
          1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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), \frac{-1}{720}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
          19. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
          20. *-lowering-*.f6430.3%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
        8. Simplified30.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if 1.50000000000000013e154 < re

        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 \color{blue}{\cos re} \]
        4. Step-by-step derivation
          1. cos-lowering-cos.f6452.7%

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

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

          \[\leadsto \color{blue}{1 + {re}^{2} \cdot \left(\frac{1}{24} \cdot {re}^{2} - \frac{1}{2}\right)} \]
        7. 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. *-lowering-*.f64N/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\left(\frac{1}{24} \cdot {re}^{2} - \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}{\frac{1}{24} \cdot {re}^{2}} - \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}{\frac{1}{24} \cdot {re}^{2}} - \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(\frac{1}{24} \cdot {re}^{2} + \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(\frac{1}{24} \cdot {re}^{2} + \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}{\frac{1}{24} \cdot {re}^{2}}\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(\frac{1}{24} \cdot {re}^{2}\right)}\right)\right)\right) \]
          9. *-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \left({re}^{2} \cdot \color{blue}{\frac{1}{24}}\right)\right)\right)\right) \]
          10. 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 \frac{1}{24}\right)\right)\right)\right) \]
          11. 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 \frac{1}{24}\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, \color{blue}{\left(re \cdot \frac{1}{24}\right)}\right)\right)\right)\right) \]
          13. *-lowering-*.f6434.4%

            \[\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}{\frac{1}{24}}\right)\right)\right)\right)\right) \]
        8. Simplified34.4%

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

          \[\leadsto \color{blue}{\frac{1}{24} \cdot {re}^{4}} \]
        10. 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. *-lowering-*.f64N/A

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right) \]
        11. Simplified34.4%

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;re \leq 2.1 \cdot 10^{+25}:\\ \;\;\;\;1 + \left(im \cdot im\right) \cdot 0.5\\ \mathbf{elif}\;re \leq 1.5 \cdot 10^{+154}:\\ \;\;\;\;re \cdot \left(re \cdot \left(-0.5 + \left(im \cdot im\right) \cdot -0.25\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 15: 58.9% accurate, 16.2× speedup?

      \[\begin{array}{l} \\ 1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right) \end{array} \]
      (FPCore (re im)
       :precision binary64
       (+
        1.0
        (*
         im
         (*
          im
          (+
           0.5
           (*
            im
            (* im (+ 0.041666666666666664 (* (* im im) 0.001388888888888889)))))))))
      double code(double re, double im) {
      	return 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))));
      }
      
      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 * (0.041666666666666664d0 + ((im * im) * 0.001388888888888889d0)))))))
      end function
      
      public static double code(double re, double im) {
      	return 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))));
      }
      
      def code(re, im):
      	return 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))))
      
      function code(re, im)
      	return Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(im * Float64(im * Float64(0.041666666666666664 + Float64(Float64(im * im) * 0.001388888888888889))))))))
      end
      
      function tmp = code(re, im)
      	tmp = 1.0 + (im * (im * (0.5 + (im * (im * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))));
      end
      
      code[re_, im_] := N[(1.0 + N[(im * N[(im * N[(0.5 + N[(im * N[(im * N[(0.041666666666666664 + N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\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. Add Preprocessing
      3. Taylor expanded in im around 0

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

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

          \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right) + \frac{1}{2} \cdot \cos re\right) + \cos re \]
        3. distribute-lft-inN/A

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

          \[\leadsto {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot \left({im}^{2} \cdot \cos re\right) + \frac{1}{24} \cdot \cos re\right)\right) + \color{blue}{\left({im}^{2} \cdot \left(\frac{1}{2} \cdot \cos re\right) + \cos re\right)} \]
      5. Simplified90.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + {im}^{2} \cdot \left({im}^{\left(2 \cdot 2\right)} \cdot \frac{1}{720} + \frac{1}{2}\right)\right)\right) \]
        13. pow-sqrN/A

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

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

          \[\leadsto \mathsf{+.f64}\left(1, \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right) + {im}^{2} \cdot \left({im}^{2} \cdot \left(\frac{1}{720} \cdot {im}^{2}\right) + \frac{1}{2}\right)\right)\right) \]
      8. Simplified60.0%

        \[\leadsto \color{blue}{1 + im \cdot \left(im \cdot \left(0.5 + im \cdot \left(im \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right)\right)\right)} \]
      9. Add Preprocessing

      Alternative 16: 49.2% accurate, 19.2× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 280000000:\\ \;\;\;\;1 + \left(im \cdot im\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= im 280000000.0)
         (+ 1.0 (* (* im im) 0.5))
         (* (* im im) (+ 0.5 (* (* re re) -0.25)))))
      double code(double re, double im) {
      	double tmp;
      	if (im <= 280000000.0) {
      		tmp = 1.0 + ((im * im) * 0.5);
      	} else {
      		tmp = (im * im) * (0.5 + ((re * re) * -0.25));
      	}
      	return tmp;
      }
      
      real(8) function code(re, im)
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8) :: tmp
          if (im <= 280000000.0d0) then
              tmp = 1.0d0 + ((im * im) * 0.5d0)
          else
              tmp = (im * im) * (0.5d0 + ((re * re) * (-0.25d0)))
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double tmp;
      	if (im <= 280000000.0) {
      		tmp = 1.0 + ((im * im) * 0.5);
      	} else {
      		tmp = (im * im) * (0.5 + ((re * re) * -0.25));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if im <= 280000000.0:
      		tmp = 1.0 + ((im * im) * 0.5)
      	else:
      		tmp = (im * im) * (0.5 + ((re * re) * -0.25))
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if (im <= 280000000.0)
      		tmp = Float64(1.0 + Float64(Float64(im * im) * 0.5));
      	else
      		tmp = Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(re * re) * -0.25)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if (im <= 280000000.0)
      		tmp = 1.0 + ((im * im) * 0.5);
      	else
      		tmp = (im * im) * (0.5 + ((re * re) * -0.25));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[LessEqual[im, 280000000.0], N[(1.0 + N[(N[(im * im), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;im \leq 280000000:\\
      \;\;\;\;1 + \left(im \cdot im\right) \cdot 0.5\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if im < 2.8e8

        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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
        4. Step-by-step derivation
          1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{1 + \frac{1}{2} \cdot {im}^{2}} \]
        7. Step-by-step derivation
          1. +-lowering-+.f64N/A

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

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

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

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

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

        if 2.8e8 < 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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
        4. Step-by-step derivation
          1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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), \frac{-1}{720}\right)\right)\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
          19. unpow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
          20. *-lowering-*.f6452.4%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \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)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right)\right)\right) \]
        8. Simplified52.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 280000000:\\ \;\;\;\;1 + \left(im \cdot im\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot \left(0.5 + \left(re \cdot re\right) \cdot -0.25\right)\\ \end{array} \]
      5. Add Preprocessing

      Alternative 17: 48.0% accurate, 22.0× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 2.7 \cdot 10^{+135}:\\ \;\;\;\;1 + \left(im \cdot im\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;0.041666666666666664 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= re 2.7e+135)
         (+ 1.0 (* (* im im) 0.5))
         (* 0.041666666666666664 (* (* re re) (* re re)))))
      double code(double re, double im) {
      	double tmp;
      	if (re <= 2.7e+135) {
      		tmp = 1.0 + ((im * im) * 0.5);
      	} 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 <= 2.7d+135) then
              tmp = 1.0d0 + ((im * im) * 0.5d0)
          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 <= 2.7e+135) {
      		tmp = 1.0 + ((im * im) * 0.5);
      	} else {
      		tmp = 0.041666666666666664 * ((re * re) * (re * re));
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if re <= 2.7e+135:
      		tmp = 1.0 + ((im * im) * 0.5)
      	else:
      		tmp = 0.041666666666666664 * ((re * re) * (re * re))
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if (re <= 2.7e+135)
      		tmp = Float64(1.0 + Float64(Float64(im * im) * 0.5));
      	else
      		tmp = Float64(0.041666666666666664 * Float64(Float64(re * re) * Float64(re * re)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if (re <= 2.7e+135)
      		tmp = 1.0 + ((im * im) * 0.5);
      	else
      		tmp = 0.041666666666666664 * ((re * re) * (re * re));
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[LessEqual[re, 2.7e+135], N[(1.0 + N[(N[(im * im), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], N[(0.041666666666666664 * N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;re \leq 2.7 \cdot 10^{+135}:\\
      \;\;\;\;1 + \left(im \cdot im\right) \cdot 0.5\\
      
      \mathbf{else}:\\
      \;\;\;\;0.041666666666666664 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if re < 2.69999999999999985e135

        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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
        4. Step-by-step derivation
          1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{1 + \frac{1}{2} \cdot {im}^{2}} \]
        7. Step-by-step derivation
          1. +-lowering-+.f64N/A

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

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

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

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

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

        if 2.69999999999999985e135 < re

        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 \color{blue}{\cos re} \]
        4. Step-by-step derivation
          1. cos-lowering-cos.f6454.2%

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

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

          \[\leadsto \color{blue}{1 + {re}^{2} \cdot \left(\frac{1}{24} \cdot {re}^{2} - \frac{1}{2}\right)} \]
        7. 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. *-lowering-*.f64N/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({re}^{2}\right), \color{blue}{\left(\frac{1}{24} \cdot {re}^{2} - \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}{\frac{1}{24} \cdot {re}^{2}} - \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}{\frac{1}{24} \cdot {re}^{2}} - \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(\frac{1}{24} \cdot {re}^{2} + \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(\frac{1}{24} \cdot {re}^{2} + \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}{\frac{1}{24} \cdot {re}^{2}}\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(\frac{1}{24} \cdot {re}^{2}\right)}\right)\right)\right) \]
          9. *-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{+.f64}\left(\frac{-1}{2}, \left({re}^{2} \cdot \color{blue}{\frac{1}{24}}\right)\right)\right)\right) \]
          10. 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 \frac{1}{24}\right)\right)\right)\right) \]
          11. 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 \frac{1}{24}\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, \color{blue}{\left(re \cdot \frac{1}{24}\right)}\right)\right)\right)\right) \]
          13. *-lowering-*.f6434.4%

            \[\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}{\frac{1}{24}}\right)\right)\right)\right)\right) \]
        8. Simplified34.4%

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

          \[\leadsto \color{blue}{\frac{1}{24} \cdot {re}^{4}} \]
        10. 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. *-lowering-*.f64N/A

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{*.f64}\left(re, \color{blue}{re}\right)\right)\right) \]
        11. Simplified34.4%

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

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

      Alternative 18: 37.8% accurate, 30.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;im \leq 1.45:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot 0.5\\ \end{array} \end{array} \]
      (FPCore (re im) :precision binary64 (if (<= im 1.45) 1.0 (* (* im im) 0.5)))
      double code(double re, double im) {
      	double tmp;
      	if (im <= 1.45) {
      		tmp = 1.0;
      	} else {
      		tmp = (im * im) * 0.5;
      	}
      	return tmp;
      }
      
      real(8) function code(re, im)
          real(8), intent (in) :: re
          real(8), intent (in) :: im
          real(8) :: tmp
          if (im <= 1.45d0) then
              tmp = 1.0d0
          else
              tmp = (im * im) * 0.5d0
          end if
          code = tmp
      end function
      
      public static double code(double re, double im) {
      	double tmp;
      	if (im <= 1.45) {
      		tmp = 1.0;
      	} else {
      		tmp = (im * im) * 0.5;
      	}
      	return tmp;
      }
      
      def code(re, im):
      	tmp = 0
      	if im <= 1.45:
      		tmp = 1.0
      	else:
      		tmp = (im * im) * 0.5
      	return tmp
      
      function code(re, im)
      	tmp = 0.0
      	if (im <= 1.45)
      		tmp = 1.0;
      	else
      		tmp = Float64(Float64(im * im) * 0.5);
      	end
      	return tmp
      end
      
      function tmp_2 = code(re, im)
      	tmp = 0.0;
      	if (im <= 1.45)
      		tmp = 1.0;
      	else
      		tmp = (im * im) * 0.5;
      	end
      	tmp_2 = tmp;
      end
      
      code[re_, im_] := If[LessEqual[im, 1.45], 1.0, N[(N[(im * im), $MachinePrecision] * 0.5), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;im \leq 1.45:\\
      \;\;\;\;1\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(im \cdot im\right) \cdot 0.5\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if im < 1.44999999999999996

        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 \color{blue}{\cos re} \]
        4. Step-by-step derivation
          1. cos-lowering-cos.f6461.5%

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

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

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

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

          if 1.44999999999999996 < 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 \color{blue}{\cos re + \frac{1}{2} \cdot \left({im}^{2} \cdot \cos re\right)} \]
          4. Step-by-step derivation
            1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{1 + \frac{1}{2} \cdot {im}^{2}} \]
          7. Step-by-step derivation
            1. +-lowering-+.f64N/A

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{1}{2} \cdot {im}^{2}} \]
          10. 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-*.f6447.8%

              \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right) \]
          11. Simplified47.8%

            \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot im\right)} \]
        8. Recombined 2 regimes into one program.
        9. Final simplification37.0%

          \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 1.45:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\left(im \cdot im\right) \cdot 0.5\\ \end{array} \]
        10. Add Preprocessing

        Alternative 19: 46.8% accurate, 44.0× speedup?

        \[\begin{array}{l} \\ 1 + \left(im \cdot im\right) \cdot 0.5 \end{array} \]
        (FPCore (re im) :precision binary64 (+ 1.0 (* (* im im) 0.5)))
        double code(double re, double im) {
        	return 1.0 + ((im * im) * 0.5);
        }
        
        real(8) function code(re, im)
            real(8), intent (in) :: re
            real(8), intent (in) :: im
            code = 1.0d0 + ((im * im) * 0.5d0)
        end function
        
        public static double code(double re, double im) {
        	return 1.0 + ((im * im) * 0.5);
        }
        
        def code(re, im):
        	return 1.0 + ((im * im) * 0.5)
        
        function code(re, im)
        	return Float64(1.0 + Float64(Float64(im * im) * 0.5))
        end
        
        function tmp = code(re, im)
        	tmp = 1.0 + ((im * im) * 0.5);
        end
        
        code[re_, im_] := N[(1.0 + N[(N[(im * im), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        1 + \left(im \cdot im\right) \cdot 0.5
        \end{array}
        
        Derivation
        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{1 + \frac{1}{2} \cdot {im}^{2}} \]
        7. Step-by-step derivation
          1. +-lowering-+.f64N/A

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

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

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

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

          \[\leadsto \color{blue}{1 + 0.5 \cdot \left(im \cdot im\right)} \]
        9. Final simplification46.9%

          \[\leadsto 1 + \left(im \cdot im\right) \cdot 0.5 \]
        10. Add Preprocessing

        Alternative 20: 28.5% 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. Add Preprocessing
        3. Taylor expanded in im around 0

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

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

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

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

            \[\leadsto \color{blue}{1} \]
          2. Add Preprocessing

          Reproduce

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