math.cos on complex, real part

Percentage Accurate: 100.0% → 100.0%
Time: 12.1s
Alternatives: 16
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 16 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, 0.8× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ 0.5 \cdot \left(e^{im\_m} \cdot \cos re + \frac{\cos re}{e^{im\_m}}\right) \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (* 0.5 (+ (* (exp im_m) (cos re)) (/ (cos re) (exp im_m)))))
im_m = fabs(im);
double code(double re, double im_m) {
	return 0.5 * ((exp(im_m) * cos(re)) + (cos(re) / exp(im_m)));
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = 0.5d0 * ((exp(im_m) * cos(re)) + (cos(re) / exp(im_m)))
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	return 0.5 * ((Math.exp(im_m) * Math.cos(re)) + (Math.cos(re) / Math.exp(im_m)));
}
im_m = math.fabs(im)
def code(re, im_m):
	return 0.5 * ((math.exp(im_m) * math.cos(re)) + (math.cos(re) / math.exp(im_m)))
im_m = abs(im)
function code(re, im_m)
	return Float64(0.5 * Float64(Float64(exp(im_m) * cos(re)) + Float64(cos(re) / exp(im_m))))
end
im_m = abs(im);
function tmp = code(re, im_m)
	tmp = 0.5 * ((exp(im_m) * cos(re)) + (cos(re) / exp(im_m)));
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := N[(0.5 * N[(N[(N[Exp[im$95$m], $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[re], $MachinePrecision] / N[Exp[im$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|

\\
0.5 \cdot \left(e^{im\_m} \cdot \cos re + \frac{\cos re}{e^{im\_m}}\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. Step-by-step derivation
    1. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{exp.f64}\left(im\right)\right), \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{exp.f64}\left(im\right)\right)\right)\right) \]
  4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \left(e^{im} \cdot \cos re + \frac{\cos re}{e^{im}}\right)} \]
  8. Add Preprocessing

Alternative 2: 100.0% accurate, 1.5× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \cos re \cdot \cosh im\_m \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m) :precision binary64 (* (cos re) (cosh im_m)))
im_m = fabs(im);
double code(double re, double im_m) {
	return cos(re) * cosh(im_m);
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = cos(re) * cosh(im_m)
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	return Math.cos(re) * Math.cosh(im_m);
}
im_m = math.fabs(im)
def code(re, im_m):
	return math.cos(re) * math.cosh(im_m)
im_m = abs(im)
function code(re, im_m)
	return Float64(cos(re) * cosh(im_m))
end
im_m = abs(im);
function tmp = code(re, im_m)
	tmp = cos(re) * cosh(im_m);
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := N[(N[Cos[re], $MachinePrecision] * N[Cosh[im$95$m], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|

\\
\cos re \cdot \cosh im\_m
\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. Final simplification100.0%

    \[\leadsto \cos re \cdot \cosh im \]
  8. Add Preprocessing

Alternative 3: 96.0% accurate, 1.7× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} t_0 := im\_m \cdot \left(im\_m \cdot \left(im\_m \cdot im\_m\right)\right)\\ t_1 := 1 + \left(0.041666666666666664 + im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\right) \cdot t\_0\\ \mathbf{if}\;im\_m \leq 7 \cdot 10^{+51}:\\ \;\;\;\;\cos re \cdot \frac{t\_1 \cdot t\_1 - t\_0 \cdot 0.25}{t\_1 - 0.5 \cdot \left(im\_m \cdot im\_m\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + \left(im\_m \cdot im\_m\right) \cdot \left(0.041666666666666664 + 0.001388888888888889 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (let* ((t_0 (* im_m (* im_m (* im_m im_m))))
        (t_1
         (+
          1.0
          (*
           (+ 0.041666666666666664 (* im_m (* im_m 0.001388888888888889)))
           t_0))))
   (if (<= im_m 7e+51)
     (*
      (cos re)
      (/ (- (* t_1 t_1) (* t_0 0.25)) (- t_1 (* 0.5 (* im_m im_m)))))
     (*
      (cos re)
      (+
       1.0
       (*
        (* im_m im_m)
        (+
         0.5
         (*
          (* im_m im_m)
          (+
           0.041666666666666664
           (* 0.001388888888888889 (* im_m im_m)))))))))))
im_m = fabs(im);
double code(double re, double im_m) {
	double t_0 = im_m * (im_m * (im_m * im_m));
	double t_1 = 1.0 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * t_0);
	double tmp;
	if (im_m <= 7e+51) {
		tmp = cos(re) * (((t_1 * t_1) - (t_0 * 0.25)) / (t_1 - (0.5 * (im_m * im_m))));
	} else {
		tmp = cos(re) * (1.0 + ((im_m * im_m) * (0.5 + ((im_m * im_m) * (0.041666666666666664 + (0.001388888888888889 * (im_m * im_m)))))));
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = im_m * (im_m * (im_m * im_m))
    t_1 = 1.0d0 + ((0.041666666666666664d0 + (im_m * (im_m * 0.001388888888888889d0))) * t_0)
    if (im_m <= 7d+51) then
        tmp = cos(re) * (((t_1 * t_1) - (t_0 * 0.25d0)) / (t_1 - (0.5d0 * (im_m * im_m))))
    else
        tmp = cos(re) * (1.0d0 + ((im_m * im_m) * (0.5d0 + ((im_m * im_m) * (0.041666666666666664d0 + (0.001388888888888889d0 * (im_m * im_m)))))))
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double t_0 = im_m * (im_m * (im_m * im_m));
	double t_1 = 1.0 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * t_0);
	double tmp;
	if (im_m <= 7e+51) {
		tmp = Math.cos(re) * (((t_1 * t_1) - (t_0 * 0.25)) / (t_1 - (0.5 * (im_m * im_m))));
	} else {
		tmp = Math.cos(re) * (1.0 + ((im_m * im_m) * (0.5 + ((im_m * im_m) * (0.041666666666666664 + (0.001388888888888889 * (im_m * im_m)))))));
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	t_0 = im_m * (im_m * (im_m * im_m))
	t_1 = 1.0 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * t_0)
	tmp = 0
	if im_m <= 7e+51:
		tmp = math.cos(re) * (((t_1 * t_1) - (t_0 * 0.25)) / (t_1 - (0.5 * (im_m * im_m))))
	else:
		tmp = math.cos(re) * (1.0 + ((im_m * im_m) * (0.5 + ((im_m * im_m) * (0.041666666666666664 + (0.001388888888888889 * (im_m * im_m)))))))
	return tmp
im_m = abs(im)
function code(re, im_m)
	t_0 = Float64(im_m * Float64(im_m * Float64(im_m * im_m)))
	t_1 = Float64(1.0 + Float64(Float64(0.041666666666666664 + Float64(im_m * Float64(im_m * 0.001388888888888889))) * t_0))
	tmp = 0.0
	if (im_m <= 7e+51)
		tmp = Float64(cos(re) * Float64(Float64(Float64(t_1 * t_1) - Float64(t_0 * 0.25)) / Float64(t_1 - Float64(0.5 * Float64(im_m * im_m)))));
	else
		tmp = Float64(cos(re) * Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(Float64(im_m * im_m) * Float64(0.041666666666666664 + Float64(0.001388888888888889 * Float64(im_m * im_m))))))));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	t_0 = im_m * (im_m * (im_m * im_m));
	t_1 = 1.0 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * t_0);
	tmp = 0.0;
	if (im_m <= 7e+51)
		tmp = cos(re) * (((t_1 * t_1) - (t_0 * 0.25)) / (t_1 - (0.5 * (im_m * im_m))));
	else
		tmp = cos(re) * (1.0 + ((im_m * im_m) * (0.5 + ((im_m * im_m) * (0.041666666666666664 + (0.001388888888888889 * (im_m * im_m)))))));
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := Block[{t$95$0 = N[(im$95$m * N[(im$95$m * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(0.041666666666666664 + N[(im$95$m * N[(im$95$m * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im$95$m, 7e+51], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(t$95$0 * 0.25), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(0.5 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.041666666666666664 + N[(0.001388888888888889 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
im_m = \left|im\right|

\\
\begin{array}{l}
t_0 := im\_m \cdot \left(im\_m \cdot \left(im\_m \cdot im\_m\right)\right)\\
t_1 := 1 + \left(0.041666666666666664 + im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\right) \cdot t\_0\\
\mathbf{if}\;im\_m \leq 7 \cdot 10^{+51}:\\
\;\;\;\;\cos re \cdot \frac{t\_1 \cdot t\_1 - t\_0 \cdot 0.25}{t\_1 - 0.5 \cdot \left(im\_m \cdot im\_m\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if 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. 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. Simplified92.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. Step-by-step derivation
      1. associate-+r+N/A

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{/.f64}\left(\left(\left(\left(\frac{1}{24} + \left(im \cdot im\right) \cdot \frac{1}{720}\right) \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) + 1\right) \cdot \left(\left(\frac{1}{24} + \left(im \cdot im\right) \cdot \frac{1}{720}\right) \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) + 1\right) - \left(\frac{1}{2} \cdot \left(im \cdot im\right)\right) \cdot \left(\frac{1}{2} \cdot \left(im \cdot im\right)\right)\right), \color{blue}{\left(\left(\left(\frac{1}{24} + \left(im \cdot im\right) \cdot \frac{1}{720}\right) \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) + 1\right) - \frac{1}{2} \cdot \left(im \cdot im\right)\right)}\right)\right) \]
    7. Applied egg-rr75.5%

      \[\leadsto \cos re \cdot \color{blue}{\frac{\left(1 + \left(0.041666666666666664 + im \cdot \left(im \cdot 0.001388888888888889\right)\right) \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right) \cdot \left(1 + \left(0.041666666666666664 + im \cdot \left(im \cdot 0.001388888888888889\right)\right) \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right) - \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot 0.25}{\left(1 + \left(0.041666666666666664 + im \cdot \left(im \cdot 0.001388888888888889\right)\right) \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right) - 0.5 \cdot \left(im \cdot im\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. 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. Simplified100.0%

      \[\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 im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \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)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 95.1% accurate, 1.8× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} t_0 := 0.041666666666666664 + \left(im\_m \cdot im\_m\right) \cdot -0.001388888888888889\\ t_1 := 0.5 \cdot \left(im\_m \cdot im\_m\right) + -1\\ t_2 := im\_m \cdot \left(im\_m \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{if}\;im\_m \leq 5 \cdot 10^{+76}:\\ \;\;\;\;\cos re \cdot \frac{\left(t\_2 \cdot 0.25 + -1\right) \cdot t\_0 + t\_1 \cdot \left(t\_2 \cdot \left(0.001736111111111111 - t\_2 \cdot 1.9290123456790124 \cdot 10^{-6}\right)\right)}{t\_0 \cdot t\_1}\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot \left(im\_m \cdot \left(0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (let* ((t_0 (+ 0.041666666666666664 (* (* im_m im_m) -0.001388888888888889)))
        (t_1 (+ (* 0.5 (* im_m im_m)) -1.0))
        (t_2 (* im_m (* im_m (* im_m im_m)))))
   (if (<= im_m 5e+76)
     (*
      (cos re)
      (/
       (+
        (* (+ (* t_2 0.25) -1.0) t_0)
        (* t_1 (* t_2 (- 0.001736111111111111 (* t_2 1.9290123456790124e-6)))))
       (* t_0 t_1)))
     (* (cos re) (* im_m (* im_m (* 0.041666666666666664 (* im_m im_m))))))))
im_m = fabs(im);
double code(double re, double im_m) {
	double t_0 = 0.041666666666666664 + ((im_m * im_m) * -0.001388888888888889);
	double t_1 = (0.5 * (im_m * im_m)) + -1.0;
	double t_2 = im_m * (im_m * (im_m * im_m));
	double tmp;
	if (im_m <= 5e+76) {
		tmp = cos(re) * (((((t_2 * 0.25) + -1.0) * t_0) + (t_1 * (t_2 * (0.001736111111111111 - (t_2 * 1.9290123456790124e-6))))) / (t_0 * t_1));
	} else {
		tmp = cos(re) * (im_m * (im_m * (0.041666666666666664 * (im_m * im_m))));
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = 0.041666666666666664d0 + ((im_m * im_m) * (-0.001388888888888889d0))
    t_1 = (0.5d0 * (im_m * im_m)) + (-1.0d0)
    t_2 = im_m * (im_m * (im_m * im_m))
    if (im_m <= 5d+76) then
        tmp = cos(re) * (((((t_2 * 0.25d0) + (-1.0d0)) * t_0) + (t_1 * (t_2 * (0.001736111111111111d0 - (t_2 * 1.9290123456790124d-6))))) / (t_0 * t_1))
    else
        tmp = cos(re) * (im_m * (im_m * (0.041666666666666664d0 * (im_m * im_m))))
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double t_0 = 0.041666666666666664 + ((im_m * im_m) * -0.001388888888888889);
	double t_1 = (0.5 * (im_m * im_m)) + -1.0;
	double t_2 = im_m * (im_m * (im_m * im_m));
	double tmp;
	if (im_m <= 5e+76) {
		tmp = Math.cos(re) * (((((t_2 * 0.25) + -1.0) * t_0) + (t_1 * (t_2 * (0.001736111111111111 - (t_2 * 1.9290123456790124e-6))))) / (t_0 * t_1));
	} else {
		tmp = Math.cos(re) * (im_m * (im_m * (0.041666666666666664 * (im_m * im_m))));
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	t_0 = 0.041666666666666664 + ((im_m * im_m) * -0.001388888888888889)
	t_1 = (0.5 * (im_m * im_m)) + -1.0
	t_2 = im_m * (im_m * (im_m * im_m))
	tmp = 0
	if im_m <= 5e+76:
		tmp = math.cos(re) * (((((t_2 * 0.25) + -1.0) * t_0) + (t_1 * (t_2 * (0.001736111111111111 - (t_2 * 1.9290123456790124e-6))))) / (t_0 * t_1))
	else:
		tmp = math.cos(re) * (im_m * (im_m * (0.041666666666666664 * (im_m * im_m))))
	return tmp
im_m = abs(im)
function code(re, im_m)
	t_0 = Float64(0.041666666666666664 + Float64(Float64(im_m * im_m) * -0.001388888888888889))
	t_1 = Float64(Float64(0.5 * Float64(im_m * im_m)) + -1.0)
	t_2 = Float64(im_m * Float64(im_m * Float64(im_m * im_m)))
	tmp = 0.0
	if (im_m <= 5e+76)
		tmp = Float64(cos(re) * Float64(Float64(Float64(Float64(Float64(t_2 * 0.25) + -1.0) * t_0) + Float64(t_1 * Float64(t_2 * Float64(0.001736111111111111 - Float64(t_2 * 1.9290123456790124e-6))))) / Float64(t_0 * t_1)));
	else
		tmp = Float64(cos(re) * Float64(im_m * Float64(im_m * Float64(0.041666666666666664 * Float64(im_m * im_m)))));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	t_0 = 0.041666666666666664 + ((im_m * im_m) * -0.001388888888888889);
	t_1 = (0.5 * (im_m * im_m)) + -1.0;
	t_2 = im_m * (im_m * (im_m * im_m));
	tmp = 0.0;
	if (im_m <= 5e+76)
		tmp = cos(re) * (((((t_2 * 0.25) + -1.0) * t_0) + (t_1 * (t_2 * (0.001736111111111111 - (t_2 * 1.9290123456790124e-6))))) / (t_0 * t_1));
	else
		tmp = cos(re) * (im_m * (im_m * (0.041666666666666664 * (im_m * im_m))));
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := Block[{t$95$0 = N[(0.041666666666666664 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * -0.001388888888888889), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]}, Block[{t$95$2 = N[(im$95$m * N[(im$95$m * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im$95$m, 5e+76], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[(N[(t$95$2 * 0.25), $MachinePrecision] + -1.0), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(t$95$1 * N[(t$95$2 * N[(0.001736111111111111 - N[(t$95$2 * 1.9290123456790124e-6), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(im$95$m * N[(0.041666666666666664 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
im_m = \left|im\right|

\\
\begin{array}{l}
t_0 := 0.041666666666666664 + \left(im\_m \cdot im\_m\right) \cdot -0.001388888888888889\\
t_1 := 0.5 \cdot \left(im\_m \cdot im\_m\right) + -1\\
t_2 := im\_m \cdot \left(im\_m \cdot \left(im\_m \cdot im\_m\right)\right)\\
\mathbf{if}\;im\_m \leq 5 \cdot 10^{+76}:\\
\;\;\;\;\cos re \cdot \frac{\left(t\_2 \cdot 0.25 + -1\right) \cdot t\_0 + t\_1 \cdot \left(t\_2 \cdot \left(0.001736111111111111 - t\_2 \cdot 1.9290123456790124 \cdot 10^{-6}\right)\right)}{t\_0 \cdot t\_1}\\

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


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

    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. Simplified92.3%

      \[\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. Applied egg-rr75.9%

      \[\leadsto \cos re \cdot \color{blue}{\frac{\left(\left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot 0.25 - 1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(im \cdot im\right)\right) + \left(0.5 \cdot \left(im \cdot im\right) - 1\right) \cdot \left(\left(0.001736111111111111 - \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot 1.9290123456790124 \cdot 10^{-6}\right) \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right)}{\left(0.5 \cdot \left(im \cdot im\right) - 1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(im \cdot im\right)\right)}} \]

    if 4.99999999999999991e76 < 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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 95.0% accurate, 2.0× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} t_0 := im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\\ t_1 := im\_m \cdot \left(im\_m \cdot im\_m\right)\\ \mathbf{if}\;im\_m \leq 5 \cdot 10^{+76}:\\ \;\;\;\;\cos re \cdot \left(\frac{\left(im\_m \cdot t\_1\right) \cdot \left(7.233796296296296 \cdot 10^{-5} + t\_1 \cdot \left(t\_1 \cdot 2.6791838134430728 \cdot 10^{-9}\right)\right)}{0.001736111111111111 + t\_0 \cdot \left(t\_0 - 0.041666666666666664\right)} + \left(1 + 0.5 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot \left(im\_m \cdot \left(0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (let* ((t_0 (* im_m (* im_m 0.001388888888888889)))
        (t_1 (* im_m (* im_m im_m))))
   (if (<= im_m 5e+76)
     (*
      (cos re)
      (+
       (/
        (*
         (* im_m t_1)
         (+ 7.233796296296296e-5 (* t_1 (* t_1 2.6791838134430728e-9))))
        (+ 0.001736111111111111 (* t_0 (- t_0 0.041666666666666664))))
       (+ 1.0 (* 0.5 (* im_m im_m)))))
     (* (cos re) (* im_m (* im_m (* 0.041666666666666664 (* im_m im_m))))))))
im_m = fabs(im);
double code(double re, double im_m) {
	double t_0 = im_m * (im_m * 0.001388888888888889);
	double t_1 = im_m * (im_m * im_m);
	double tmp;
	if (im_m <= 5e+76) {
		tmp = cos(re) * ((((im_m * t_1) * (7.233796296296296e-5 + (t_1 * (t_1 * 2.6791838134430728e-9)))) / (0.001736111111111111 + (t_0 * (t_0 - 0.041666666666666664)))) + (1.0 + (0.5 * (im_m * im_m))));
	} else {
		tmp = cos(re) * (im_m * (im_m * (0.041666666666666664 * (im_m * im_m))));
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = im_m * (im_m * 0.001388888888888889d0)
    t_1 = im_m * (im_m * im_m)
    if (im_m <= 5d+76) then
        tmp = cos(re) * ((((im_m * t_1) * (7.233796296296296d-5 + (t_1 * (t_1 * 2.6791838134430728d-9)))) / (0.001736111111111111d0 + (t_0 * (t_0 - 0.041666666666666664d0)))) + (1.0d0 + (0.5d0 * (im_m * im_m))))
    else
        tmp = cos(re) * (im_m * (im_m * (0.041666666666666664d0 * (im_m * im_m))))
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double t_0 = im_m * (im_m * 0.001388888888888889);
	double t_1 = im_m * (im_m * im_m);
	double tmp;
	if (im_m <= 5e+76) {
		tmp = Math.cos(re) * ((((im_m * t_1) * (7.233796296296296e-5 + (t_1 * (t_1 * 2.6791838134430728e-9)))) / (0.001736111111111111 + (t_0 * (t_0 - 0.041666666666666664)))) + (1.0 + (0.5 * (im_m * im_m))));
	} else {
		tmp = Math.cos(re) * (im_m * (im_m * (0.041666666666666664 * (im_m * im_m))));
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	t_0 = im_m * (im_m * 0.001388888888888889)
	t_1 = im_m * (im_m * im_m)
	tmp = 0
	if im_m <= 5e+76:
		tmp = math.cos(re) * ((((im_m * t_1) * (7.233796296296296e-5 + (t_1 * (t_1 * 2.6791838134430728e-9)))) / (0.001736111111111111 + (t_0 * (t_0 - 0.041666666666666664)))) + (1.0 + (0.5 * (im_m * im_m))))
	else:
		tmp = math.cos(re) * (im_m * (im_m * (0.041666666666666664 * (im_m * im_m))))
	return tmp
im_m = abs(im)
function code(re, im_m)
	t_0 = Float64(im_m * Float64(im_m * 0.001388888888888889))
	t_1 = Float64(im_m * Float64(im_m * im_m))
	tmp = 0.0
	if (im_m <= 5e+76)
		tmp = Float64(cos(re) * Float64(Float64(Float64(Float64(im_m * t_1) * Float64(7.233796296296296e-5 + Float64(t_1 * Float64(t_1 * 2.6791838134430728e-9)))) / Float64(0.001736111111111111 + Float64(t_0 * Float64(t_0 - 0.041666666666666664)))) + Float64(1.0 + Float64(0.5 * Float64(im_m * im_m)))));
	else
		tmp = Float64(cos(re) * Float64(im_m * Float64(im_m * Float64(0.041666666666666664 * Float64(im_m * im_m)))));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	t_0 = im_m * (im_m * 0.001388888888888889);
	t_1 = im_m * (im_m * im_m);
	tmp = 0.0;
	if (im_m <= 5e+76)
		tmp = cos(re) * ((((im_m * t_1) * (7.233796296296296e-5 + (t_1 * (t_1 * 2.6791838134430728e-9)))) / (0.001736111111111111 + (t_0 * (t_0 - 0.041666666666666664)))) + (1.0 + (0.5 * (im_m * im_m))));
	else
		tmp = cos(re) * (im_m * (im_m * (0.041666666666666664 * (im_m * im_m))));
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := Block[{t$95$0 = N[(im$95$m * N[(im$95$m * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(im$95$m * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im$95$m, 5e+76], N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[(im$95$m * t$95$1), $MachinePrecision] * N[(7.233796296296296e-5 + N[(t$95$1 * N[(t$95$1 * 2.6791838134430728e-9), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.001736111111111111 + N[(t$95$0 * N[(t$95$0 - 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(0.5 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(im$95$m * N[(0.041666666666666664 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
im_m = \left|im\right|

\\
\begin{array}{l}
t_0 := im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\\
t_1 := im\_m \cdot \left(im\_m \cdot im\_m\right)\\
\mathbf{if}\;im\_m \leq 5 \cdot 10^{+76}:\\
\;\;\;\;\cos re \cdot \left(\frac{\left(im\_m \cdot t\_1\right) \cdot \left(7.233796296296296 \cdot 10^{-5} + t\_1 \cdot \left(t\_1 \cdot 2.6791838134430728 \cdot 10^{-9}\right)\right)}{0.001736111111111111 + t\_0 \cdot \left(t\_0 - 0.041666666666666664\right)} + \left(1 + 0.5 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\\

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


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

    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. Simplified92.3%

      \[\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. Step-by-step derivation
      1. flip3-+N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \mathsf{+.f64}\left(\left(\frac{{\frac{1}{24}}^{3} + {\left(\left(im \cdot im\right) \cdot \frac{1}{720}\right)}^{3}}{\frac{1}{24} \cdot \frac{1}{24} + \left(\left(\left(im \cdot im\right) \cdot \frac{1}{720}\right) \cdot \left(\left(im \cdot im\right) \cdot \frac{1}{720}\right) - \frac{1}{24} \cdot \left(\left(im \cdot im\right) \cdot \frac{1}{720}\right)\right)} \cdot \left(im \cdot \left(im \cdot \left(im \cdot 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. associate-*l/N/A

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

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

      \[\leadsto \cos re \cdot \left(\color{blue}{\frac{\left(7.233796296296296 \cdot 10^{-5} + \left(im \cdot \left(im \cdot im\right)\right) \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot 2.6791838134430728 \cdot 10^{-9}\right)\right) \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)}{0.001736111111111111 + \left(im \cdot \left(im \cdot 0.001388888888888889\right)\right) \cdot \left(im \cdot \left(im \cdot 0.001388888888888889\right) - 0.041666666666666664\right)}} + \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)\right) \]

    if 4.99999999999999991e76 < 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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 94.9% accurate, 2.4× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} t_0 := \cos re \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + \left(im\_m \cdot im\_m\right) \cdot \left(0.041666666666666664 + 0.001388888888888889 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right)\\ \mathbf{if}\;im\_m \leq 470:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 9.5 \cdot 10^{+48}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (let* ((t_0
         (*
          (cos re)
          (+
           1.0
           (*
            (* im_m im_m)
            (+
             0.5
             (*
              (* im_m im_m)
              (+
               0.041666666666666664
               (* 0.001388888888888889 (* im_m im_m))))))))))
   (if (<= im_m 470.0)
     t_0
     (if (<= im_m 9.5e+48)
       (+
        (*
         (* re re)
         (*
          -0.5
          (+
           1.0
           (* (* im_m im_m) (+ 0.5 (* 0.041666666666666664 (* im_m im_m)))))))
        (+
         1.0
         (*
          re
          (/
           re
           (/
            (/ (* re re) (+ 0.5 (* im_m (* im_m 0.041666666666666664))))
            (* im_m im_m))))))
       t_0))))
im_m = fabs(im);
double code(double re, double im_m) {
	double t_0 = cos(re) * (1.0 + ((im_m * im_m) * (0.5 + ((im_m * im_m) * (0.041666666666666664 + (0.001388888888888889 * (im_m * im_m)))))));
	double tmp;
	if (im_m <= 470.0) {
		tmp = t_0;
	} else if (im_m <= 9.5e+48) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos(re) * (1.0d0 + ((im_m * im_m) * (0.5d0 + ((im_m * im_m) * (0.041666666666666664d0 + (0.001388888888888889d0 * (im_m * im_m)))))))
    if (im_m <= 470.0d0) then
        tmp = t_0
    else if (im_m <= 9.5d+48) then
        tmp = ((re * re) * ((-0.5d0) * (1.0d0 + ((im_m * im_m) * (0.5d0 + (0.041666666666666664d0 * (im_m * im_m))))))) + (1.0d0 + (re * (re / (((re * re) / (0.5d0 + (im_m * (im_m * 0.041666666666666664d0)))) / (im_m * im_m)))))
    else
        tmp = t_0
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double t_0 = Math.cos(re) * (1.0 + ((im_m * im_m) * (0.5 + ((im_m * im_m) * (0.041666666666666664 + (0.001388888888888889 * (im_m * im_m)))))));
	double tmp;
	if (im_m <= 470.0) {
		tmp = t_0;
	} else if (im_m <= 9.5e+48) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	t_0 = math.cos(re) * (1.0 + ((im_m * im_m) * (0.5 + ((im_m * im_m) * (0.041666666666666664 + (0.001388888888888889 * (im_m * im_m)))))))
	tmp = 0
	if im_m <= 470.0:
		tmp = t_0
	elif im_m <= 9.5e+48:
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))))
	else:
		tmp = t_0
	return tmp
im_m = abs(im)
function code(re, im_m)
	t_0 = Float64(cos(re) * Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(Float64(im_m * im_m) * Float64(0.041666666666666664 + Float64(0.001388888888888889 * Float64(im_m * im_m))))))))
	tmp = 0.0
	if (im_m <= 470.0)
		tmp = t_0;
	elseif (im_m <= 9.5e+48)
		tmp = Float64(Float64(Float64(re * re) * Float64(-0.5 * Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(0.041666666666666664 * Float64(im_m * im_m))))))) + Float64(1.0 + Float64(re * Float64(re / Float64(Float64(Float64(re * re) / Float64(0.5 + Float64(im_m * Float64(im_m * 0.041666666666666664)))) / Float64(im_m * im_m))))));
	else
		tmp = t_0;
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	t_0 = cos(re) * (1.0 + ((im_m * im_m) * (0.5 + ((im_m * im_m) * (0.041666666666666664 + (0.001388888888888889 * (im_m * im_m)))))));
	tmp = 0.0;
	if (im_m <= 470.0)
		tmp = t_0;
	elseif (im_m <= 9.5e+48)
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := Block[{t$95$0 = N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.041666666666666664 + N[(0.001388888888888889 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im$95$m, 470.0], t$95$0, If[LessEqual[im$95$m, 9.5e+48], N[(N[(N[(re * re), $MachinePrecision] * N[(-0.5 * N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(0.041666666666666664 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(re * N[(re / N[(N[(N[(re * re), $MachinePrecision] / N[(0.5 + N[(im$95$m * N[(im$95$m * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
im_m = \left|im\right|

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

\mathbf{elif}\;im\_m \leq 9.5 \cdot 10^{+48}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if im < 470 or 9.4999999999999997e48 < 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. Simplified96.1%

      \[\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 im around 0

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(re\right), \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)}\right) \]
    7. Step-by-step derivation
      1. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 470 < im < 9.4999999999999997e48

    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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. *-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(\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. 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(\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) \]
      5. *-lowering-*.f6431.0%

        \[\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(\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) \]
    8. Simplified31.0%

      \[\leadsto \color{blue}{\left(1 + \left(re \cdot re\right) \cdot -0.5\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 re around inf

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\left(\frac{-1}{2} \cdot \left({re}^{2} \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)\right)\right)\right), \color{blue}{\left({re}^{2} \cdot \left(\frac{1}{{re}^{2}} + \frac{{im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)}{{re}^{2}}\right)\right)}\right) \]
    11. Simplified29.7%

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\right) + \left(1 + \left(re \cdot re\right) \cdot \frac{\left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)}{re \cdot re}\right)} \]
    12. Step-by-step derivation
      1. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{24}\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot \frac{\left(im \cdot im\right) \cdot \left(\frac{1}{2} + \left(im \cdot im\right) \cdot \frac{1}{24}\right)}{re \cdot re}\right), \color{blue}{re}\right)\right)\right) \]
    13. Applied egg-rr58.3%

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

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

Alternative 7: 90.4% accurate, 2.5× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(im\_m \cdot im\_m + 2\right)\\ \mathbf{if}\;im\_m \leq 370:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;im\_m \leq 5.5 \cdot 10^{+60}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\ \mathbf{elif}\;im\_m \leq 2 \cdot 10^{+154}:\\ \;\;\;\;1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + \left(0.041666666666666664 + im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\right) \cdot \left(im\_m \cdot im\_m\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (let* ((t_0 (* (* 0.5 (cos re)) (+ (* im_m im_m) 2.0))))
   (if (<= im_m 370.0)
     t_0
     (if (<= im_m 5.5e+60)
       (+
        (*
         (* re re)
         (*
          -0.5
          (+
           1.0
           (* (* im_m im_m) (+ 0.5 (* 0.041666666666666664 (* im_m im_m)))))))
        (+
         1.0
         (*
          re
          (/
           re
           (/
            (/ (* re re) (+ 0.5 (* im_m (* im_m 0.041666666666666664))))
            (* im_m im_m))))))
       (if (<= im_m 2e+154)
         (+
          1.0
          (*
           (* im_m im_m)
           (+
            0.5
            (*
             (+ 0.041666666666666664 (* im_m (* im_m 0.001388888888888889)))
             (* im_m im_m)))))
         t_0)))))
im_m = fabs(im);
double code(double re, double im_m) {
	double t_0 = (0.5 * cos(re)) * ((im_m * im_m) + 2.0);
	double tmp;
	if (im_m <= 370.0) {
		tmp = t_0;
	} else if (im_m <= 5.5e+60) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else if (im_m <= 2e+154) {
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (0.5d0 * cos(re)) * ((im_m * im_m) + 2.0d0)
    if (im_m <= 370.0d0) then
        tmp = t_0
    else if (im_m <= 5.5d+60) then
        tmp = ((re * re) * ((-0.5d0) * (1.0d0 + ((im_m * im_m) * (0.5d0 + (0.041666666666666664d0 * (im_m * im_m))))))) + (1.0d0 + (re * (re / (((re * re) / (0.5d0 + (im_m * (im_m * 0.041666666666666664d0)))) / (im_m * im_m)))))
    else if (im_m <= 2d+154) then
        tmp = 1.0d0 + ((im_m * im_m) * (0.5d0 + ((0.041666666666666664d0 + (im_m * (im_m * 0.001388888888888889d0))) * (im_m * im_m))))
    else
        tmp = t_0
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double t_0 = (0.5 * Math.cos(re)) * ((im_m * im_m) + 2.0);
	double tmp;
	if (im_m <= 370.0) {
		tmp = t_0;
	} else if (im_m <= 5.5e+60) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else if (im_m <= 2e+154) {
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
	} else {
		tmp = t_0;
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	t_0 = (0.5 * math.cos(re)) * ((im_m * im_m) + 2.0)
	tmp = 0
	if im_m <= 370.0:
		tmp = t_0
	elif im_m <= 5.5e+60:
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))))
	elif im_m <= 2e+154:
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))))
	else:
		tmp = t_0
	return tmp
im_m = abs(im)
function code(re, im_m)
	t_0 = Float64(Float64(0.5 * cos(re)) * Float64(Float64(im_m * im_m) + 2.0))
	tmp = 0.0
	if (im_m <= 370.0)
		tmp = t_0;
	elseif (im_m <= 5.5e+60)
		tmp = Float64(Float64(Float64(re * re) * Float64(-0.5 * Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(0.041666666666666664 * Float64(im_m * im_m))))))) + Float64(1.0 + Float64(re * Float64(re / Float64(Float64(Float64(re * re) / Float64(0.5 + Float64(im_m * Float64(im_m * 0.041666666666666664)))) / Float64(im_m * im_m))))));
	elseif (im_m <= 2e+154)
		tmp = Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(Float64(0.041666666666666664 + Float64(im_m * Float64(im_m * 0.001388888888888889))) * Float64(im_m * im_m)))));
	else
		tmp = t_0;
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	t_0 = (0.5 * cos(re)) * ((im_m * im_m) + 2.0);
	tmp = 0.0;
	if (im_m <= 370.0)
		tmp = t_0;
	elseif (im_m <= 5.5e+60)
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	elseif (im_m <= 2e+154)
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[(im$95$m * im$95$m), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im$95$m, 370.0], t$95$0, If[LessEqual[im$95$m, 5.5e+60], N[(N[(N[(re * re), $MachinePrecision] * N[(-0.5 * N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(0.041666666666666664 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(re * N[(re / N[(N[(N[(re * re), $MachinePrecision] / N[(0.5 + N[(im$95$m * N[(im$95$m * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 2e+154], N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(N[(0.041666666666666664 + N[(im$95$m * N[(im$95$m * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
im_m = \left|im\right|

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

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

\mathbf{elif}\;im\_m \leq 2 \cdot 10^{+154}:\\
\;\;\;\;1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + \left(0.041666666666666664 + im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\right) \cdot \left(im\_m \cdot im\_m\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if im < 370 or 2.00000000000000007e154 < im

    1. Initial program 100.0%

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

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

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

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

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

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

    if 370 < im < 5.5000000000000001e60

    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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. *-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(\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. 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(\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) \]
      5. *-lowering-*.f6427.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(\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) \]
    8. Simplified27.9%

      \[\leadsto \color{blue}{\left(1 + \left(re \cdot re\right) \cdot -0.5\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 re around inf

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\left(\frac{-1}{2} \cdot \left({re}^{2} \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)\right)\right)\right), \color{blue}{\left({re}^{2} \cdot \left(\frac{1}{{re}^{2}} + \frac{{im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)}{{re}^{2}}\right)\right)}\right) \]
    11. Simplified26.0%

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\right) + \left(1 + \left(re \cdot re\right) \cdot \frac{\left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)}{re \cdot re}\right)} \]
    12. Step-by-step derivation
      1. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{24}\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot \frac{\left(im \cdot im\right) \cdot \left(\frac{1}{2} + \left(im \cdot im\right) \cdot \frac{1}{24}\right)}{re \cdot re}\right), \color{blue}{re}\right)\right)\right) \]
    13. Applied egg-rr63.5%

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

    if 5.5000000000000001e60 < im < 2.00000000000000007e154

    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. Simplified100.0%

      \[\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. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f6485.7%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
    8. Simplified85.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 93.7% accurate, 2.5× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} t_0 := 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\\ t_1 := 1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + t\_0\right)\\ \mathbf{if}\;im\_m \leq 480:\\ \;\;\;\;\cos re \cdot t\_1\\ \mathbf{elif}\;im\_m \leq 2.6 \cdot 10^{+77}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot t\_1\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot \left(im\_m \cdot t\_0\right)\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (let* ((t_0 (* 0.041666666666666664 (* im_m im_m)))
        (t_1 (+ 1.0 (* (* im_m im_m) (+ 0.5 t_0)))))
   (if (<= im_m 480.0)
     (* (cos re) t_1)
     (if (<= im_m 2.6e+77)
       (+
        (* (* re re) (* -0.5 t_1))
        (+
         1.0
         (*
          re
          (/
           re
           (/
            (/ (* re re) (+ 0.5 (* im_m (* im_m 0.041666666666666664))))
            (* im_m im_m))))))
       (* (cos re) (* im_m (* im_m t_0)))))))
im_m = fabs(im);
double code(double re, double im_m) {
	double t_0 = 0.041666666666666664 * (im_m * im_m);
	double t_1 = 1.0 + ((im_m * im_m) * (0.5 + t_0));
	double tmp;
	if (im_m <= 480.0) {
		tmp = cos(re) * t_1;
	} else if (im_m <= 2.6e+77) {
		tmp = ((re * re) * (-0.5 * t_1)) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = cos(re) * (im_m * (im_m * t_0));
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 0.041666666666666664d0 * (im_m * im_m)
    t_1 = 1.0d0 + ((im_m * im_m) * (0.5d0 + t_0))
    if (im_m <= 480.0d0) then
        tmp = cos(re) * t_1
    else if (im_m <= 2.6d+77) then
        tmp = ((re * re) * ((-0.5d0) * t_1)) + (1.0d0 + (re * (re / (((re * re) / (0.5d0 + (im_m * (im_m * 0.041666666666666664d0)))) / (im_m * im_m)))))
    else
        tmp = cos(re) * (im_m * (im_m * t_0))
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double t_0 = 0.041666666666666664 * (im_m * im_m);
	double t_1 = 1.0 + ((im_m * im_m) * (0.5 + t_0));
	double tmp;
	if (im_m <= 480.0) {
		tmp = Math.cos(re) * t_1;
	} else if (im_m <= 2.6e+77) {
		tmp = ((re * re) * (-0.5 * t_1)) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = Math.cos(re) * (im_m * (im_m * t_0));
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	t_0 = 0.041666666666666664 * (im_m * im_m)
	t_1 = 1.0 + ((im_m * im_m) * (0.5 + t_0))
	tmp = 0
	if im_m <= 480.0:
		tmp = math.cos(re) * t_1
	elif im_m <= 2.6e+77:
		tmp = ((re * re) * (-0.5 * t_1)) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))))
	else:
		tmp = math.cos(re) * (im_m * (im_m * t_0))
	return tmp
im_m = abs(im)
function code(re, im_m)
	t_0 = Float64(0.041666666666666664 * Float64(im_m * im_m))
	t_1 = Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + t_0)))
	tmp = 0.0
	if (im_m <= 480.0)
		tmp = Float64(cos(re) * t_1);
	elseif (im_m <= 2.6e+77)
		tmp = Float64(Float64(Float64(re * re) * Float64(-0.5 * t_1)) + Float64(1.0 + Float64(re * Float64(re / Float64(Float64(Float64(re * re) / Float64(0.5 + Float64(im_m * Float64(im_m * 0.041666666666666664)))) / Float64(im_m * im_m))))));
	else
		tmp = Float64(cos(re) * Float64(im_m * Float64(im_m * t_0)));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	t_0 = 0.041666666666666664 * (im_m * im_m);
	t_1 = 1.0 + ((im_m * im_m) * (0.5 + t_0));
	tmp = 0.0;
	if (im_m <= 480.0)
		tmp = cos(re) * t_1;
	elseif (im_m <= 2.6e+77)
		tmp = ((re * re) * (-0.5 * t_1)) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	else
		tmp = cos(re) * (im_m * (im_m * t_0));
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := Block[{t$95$0 = N[(0.041666666666666664 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im$95$m, 480.0], N[(N[Cos[re], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[im$95$m, 2.6e+77], N[(N[(N[(re * re), $MachinePrecision] * N[(-0.5 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(re * N[(re / N[(N[(N[(re * re), $MachinePrecision] / N[(0.5 + N[(im$95$m * N[(im$95$m * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(im$95$m * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
im_m = \left|im\right|

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

\mathbf{elif}\;im\_m \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot t\_1\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\

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


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

    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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2}\right)\right) \cdot \cos re + \left(im \cdot \left(\frac{1}{2} \cdot im\right) + 1\right) \cdot \cos re \]
    5. Simplified92.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)} \]

    if 480 < im < 2.6000000000000002e77

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in 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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. *-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(\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. 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(\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) \]
      5. *-lowering-*.f6423.0%

        \[\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(\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) \]
    8. Simplified23.0%

      \[\leadsto \color{blue}{\left(1 + \left(re \cdot re\right) \cdot -0.5\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 re around inf

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\left(\frac{-1}{2} \cdot \left({re}^{2} \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)\right)\right)\right), \color{blue}{\left({re}^{2} \cdot \left(\frac{1}{{re}^{2}} + \frac{{im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)}{{re}^{2}}\right)\right)}\right) \]
    11. Simplified20.8%

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\right) + \left(1 + \left(re \cdot re\right) \cdot \frac{\left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)}{re \cdot re}\right)} \]
    12. Step-by-step derivation
      1. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{24}\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot \frac{\left(im \cdot im\right) \cdot \left(\frac{1}{2} + \left(im \cdot im\right) \cdot \frac{1}{24}\right)}{re \cdot re}\right), \color{blue}{re}\right)\right)\right) \]
    13. Applied egg-rr60.8%

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

    if 2.6000000000000002e77 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. 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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 93.5% accurate, 2.5× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} t_0 := 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\\ \mathbf{if}\;im\_m \leq 480:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im\_m \cdot im\_m + 2\right)\\ \mathbf{elif}\;im\_m \leq 2.6 \cdot 10^{+77}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + t\_0\right)\right)\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\ \mathbf{else}:\\ \;\;\;\;\cos re \cdot \left(im\_m \cdot \left(im\_m \cdot t\_0\right)\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (let* ((t_0 (* 0.041666666666666664 (* im_m im_m))))
   (if (<= im_m 480.0)
     (* (* 0.5 (cos re)) (+ (* im_m im_m) 2.0))
     (if (<= im_m 2.6e+77)
       (+
        (* (* re re) (* -0.5 (+ 1.0 (* (* im_m im_m) (+ 0.5 t_0)))))
        (+
         1.0
         (*
          re
          (/
           re
           (/
            (/ (* re re) (+ 0.5 (* im_m (* im_m 0.041666666666666664))))
            (* im_m im_m))))))
       (* (cos re) (* im_m (* im_m t_0)))))))
im_m = fabs(im);
double code(double re, double im_m) {
	double t_0 = 0.041666666666666664 * (im_m * im_m);
	double tmp;
	if (im_m <= 480.0) {
		tmp = (0.5 * cos(re)) * ((im_m * im_m) + 2.0);
	} else if (im_m <= 2.6e+77) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + t_0))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = cos(re) * (im_m * (im_m * t_0));
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 0.041666666666666664d0 * (im_m * im_m)
    if (im_m <= 480.0d0) then
        tmp = (0.5d0 * cos(re)) * ((im_m * im_m) + 2.0d0)
    else if (im_m <= 2.6d+77) then
        tmp = ((re * re) * ((-0.5d0) * (1.0d0 + ((im_m * im_m) * (0.5d0 + t_0))))) + (1.0d0 + (re * (re / (((re * re) / (0.5d0 + (im_m * (im_m * 0.041666666666666664d0)))) / (im_m * im_m)))))
    else
        tmp = cos(re) * (im_m * (im_m * t_0))
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double t_0 = 0.041666666666666664 * (im_m * im_m);
	double tmp;
	if (im_m <= 480.0) {
		tmp = (0.5 * Math.cos(re)) * ((im_m * im_m) + 2.0);
	} else if (im_m <= 2.6e+77) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + t_0))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = Math.cos(re) * (im_m * (im_m * t_0));
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	t_0 = 0.041666666666666664 * (im_m * im_m)
	tmp = 0
	if im_m <= 480.0:
		tmp = (0.5 * math.cos(re)) * ((im_m * im_m) + 2.0)
	elif im_m <= 2.6e+77:
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + t_0))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))))
	else:
		tmp = math.cos(re) * (im_m * (im_m * t_0))
	return tmp
im_m = abs(im)
function code(re, im_m)
	t_0 = Float64(0.041666666666666664 * Float64(im_m * im_m))
	tmp = 0.0
	if (im_m <= 480.0)
		tmp = Float64(Float64(0.5 * cos(re)) * Float64(Float64(im_m * im_m) + 2.0));
	elseif (im_m <= 2.6e+77)
		tmp = Float64(Float64(Float64(re * re) * Float64(-0.5 * Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + t_0))))) + Float64(1.0 + Float64(re * Float64(re / Float64(Float64(Float64(re * re) / Float64(0.5 + Float64(im_m * Float64(im_m * 0.041666666666666664)))) / Float64(im_m * im_m))))));
	else
		tmp = Float64(cos(re) * Float64(im_m * Float64(im_m * t_0)));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	t_0 = 0.041666666666666664 * (im_m * im_m);
	tmp = 0.0;
	if (im_m <= 480.0)
		tmp = (0.5 * cos(re)) * ((im_m * im_m) + 2.0);
	elseif (im_m <= 2.6e+77)
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + t_0))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	else
		tmp = cos(re) * (im_m * (im_m * t_0));
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := Block[{t$95$0 = N[(0.041666666666666664 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im$95$m, 480.0], N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[(im$95$m * im$95$m), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 2.6e+77], N[(N[(N[(re * re), $MachinePrecision] * N[(-0.5 * N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(re * N[(re / N[(N[(N[(re * re), $MachinePrecision] / N[(0.5 + N[(im$95$m * N[(im$95$m * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(im$95$m * N[(im$95$m * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
im_m = \left|im\right|

\\
\begin{array}{l}
t_0 := 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\\
\mathbf{if}\;im\_m \leq 480:\\
\;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(im\_m \cdot im\_m + 2\right)\\

\mathbf{elif}\;im\_m \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + t\_0\right)\right)\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

    if 480 < im < 2.6000000000000002e77

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in 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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. *-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(\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. 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(\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) \]
      5. *-lowering-*.f6423.0%

        \[\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(\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) \]
    8. Simplified23.0%

      \[\leadsto \color{blue}{\left(1 + \left(re \cdot re\right) \cdot -0.5\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 re around inf

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\left(\frac{-1}{2} \cdot \left({re}^{2} \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)\right)\right)\right), \color{blue}{\left({re}^{2} \cdot \left(\frac{1}{{re}^{2}} + \frac{{im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)}{{re}^{2}}\right)\right)}\right) \]
    11. Simplified20.8%

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\right) + \left(1 + \left(re \cdot re\right) \cdot \frac{\left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)}{re \cdot re}\right)} \]
    12. Step-by-step derivation
      1. associate-*l*N/A

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(re, re\right), \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{24}\right)\right)\right)\right)\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left(re \cdot \frac{\left(im \cdot im\right) \cdot \left(\frac{1}{2} + \left(im \cdot im\right) \cdot \frac{1}{24}\right)}{re \cdot re}\right), \color{blue}{re}\right)\right)\right) \]
    13. Applied egg-rr60.8%

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

    if 2.6000000000000002e77 < im

    1. Initial program 100.0%

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \]
    2. 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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 84.1% accurate, 2.9× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} \mathbf{if}\;im\_m \leq 0.0016:\\ \;\;\;\;\cos re\\ \mathbf{elif}\;im\_m \leq 4 \cdot 10^{+59}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + \left(0.041666666666666664 + im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\right) \cdot \left(im\_m \cdot im\_m\right)\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (if (<= im_m 0.0016)
   (cos re)
   (if (<= im_m 4e+59)
     (+
      (*
       (* re re)
       (*
        -0.5
        (+
         1.0
         (* (* im_m im_m) (+ 0.5 (* 0.041666666666666664 (* im_m im_m)))))))
      (+
       1.0
       (*
        re
        (/
         re
         (/
          (/ (* re re) (+ 0.5 (* im_m (* im_m 0.041666666666666664))))
          (* im_m im_m))))))
     (+
      1.0
      (*
       (* im_m im_m)
       (+
        0.5
        (*
         (+ 0.041666666666666664 (* im_m (* im_m 0.001388888888888889)))
         (* im_m im_m))))))))
im_m = fabs(im);
double code(double re, double im_m) {
	double tmp;
	if (im_m <= 0.0016) {
		tmp = cos(re);
	} else if (im_m <= 4e+59) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 0.0016d0) then
        tmp = cos(re)
    else if (im_m <= 4d+59) then
        tmp = ((re * re) * ((-0.5d0) * (1.0d0 + ((im_m * im_m) * (0.5d0 + (0.041666666666666664d0 * (im_m * im_m))))))) + (1.0d0 + (re * (re / (((re * re) / (0.5d0 + (im_m * (im_m * 0.041666666666666664d0)))) / (im_m * im_m)))))
    else
        tmp = 1.0d0 + ((im_m * im_m) * (0.5d0 + ((0.041666666666666664d0 + (im_m * (im_m * 0.001388888888888889d0))) * (im_m * im_m))))
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double tmp;
	if (im_m <= 0.0016) {
		tmp = Math.cos(re);
	} else if (im_m <= 4e+59) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	tmp = 0
	if im_m <= 0.0016:
		tmp = math.cos(re)
	elif im_m <= 4e+59:
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))))
	else:
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))))
	return tmp
im_m = abs(im)
function code(re, im_m)
	tmp = 0.0
	if (im_m <= 0.0016)
		tmp = cos(re);
	elseif (im_m <= 4e+59)
		tmp = Float64(Float64(Float64(re * re) * Float64(-0.5 * Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(0.041666666666666664 * Float64(im_m * im_m))))))) + Float64(1.0 + Float64(re * Float64(re / Float64(Float64(Float64(re * re) / Float64(0.5 + Float64(im_m * Float64(im_m * 0.041666666666666664)))) / Float64(im_m * im_m))))));
	else
		tmp = Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(Float64(0.041666666666666664 + Float64(im_m * Float64(im_m * 0.001388888888888889))) * Float64(im_m * im_m)))));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	tmp = 0.0;
	if (im_m <= 0.0016)
		tmp = cos(re);
	elseif (im_m <= 4e+59)
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	else
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := If[LessEqual[im$95$m, 0.0016], N[Cos[re], $MachinePrecision], If[LessEqual[im$95$m, 4e+59], N[(N[(N[(re * re), $MachinePrecision] * N[(-0.5 * N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(0.041666666666666664 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(re * N[(re / N[(N[(N[(re * re), $MachinePrecision] / N[(0.5 + N[(im$95$m * N[(im$95$m * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(N[(0.041666666666666664 + N[(im$95$m * N[(im$95$m * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
im_m = \left|im\right|

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

\mathbf{elif}\;im\_m \leq 4 \cdot 10^{+59}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\

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


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

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

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

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

    if 0.00160000000000000008 < im < 3.99999999999999989e59

    1. Initial program 99.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. *-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(\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. 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(\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) \]
      5. *-lowering-*.f6422.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(\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) \]
    8. Simplified22.9%

      \[\leadsto \color{blue}{\left(1 + \left(re \cdot re\right) \cdot -0.5\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 re around inf

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\left(\frac{-1}{2} \cdot \left({re}^{2} \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)\right)\right)\right), \color{blue}{\left({re}^{2} \cdot \left(\frac{1}{{re}^{2}} + \frac{{im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)}{{re}^{2}}\right)\right)}\right) \]
    11. Simplified20.8%

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\right) + \left(1 + \left(re \cdot re\right) \cdot \frac{\left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)}{re \cdot re}\right)} \]
    12. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

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

    if 3.99999999999999989e59 < 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. Simplified100.0%

      \[\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. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f6476.6%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
    8. Simplified76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 62.2% accurate, 6.0× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} \mathbf{if}\;im\_m \leq 0.0016:\\ \;\;\;\;1 + 0.5 \cdot \left(im\_m \cdot im\_m\right)\\ \mathbf{elif}\;im\_m \leq 1.36 \cdot 10^{+60}:\\ \;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\ \mathbf{else}:\\ \;\;\;\;1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + \left(0.041666666666666664 + im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\right) \cdot \left(im\_m \cdot im\_m\right)\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (if (<= im_m 0.0016)
   (+ 1.0 (* 0.5 (* im_m im_m)))
   (if (<= im_m 1.36e+60)
     (+
      (*
       (* re re)
       (*
        -0.5
        (+
         1.0
         (* (* im_m im_m) (+ 0.5 (* 0.041666666666666664 (* im_m im_m)))))))
      (+
       1.0
       (*
        re
        (/
         re
         (/
          (/ (* re re) (+ 0.5 (* im_m (* im_m 0.041666666666666664))))
          (* im_m im_m))))))
     (+
      1.0
      (*
       (* im_m im_m)
       (+
        0.5
        (*
         (+ 0.041666666666666664 (* im_m (* im_m 0.001388888888888889)))
         (* im_m im_m))))))))
im_m = fabs(im);
double code(double re, double im_m) {
	double tmp;
	if (im_m <= 0.0016) {
		tmp = 1.0 + (0.5 * (im_m * im_m));
	} else if (im_m <= 1.36e+60) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 0.0016d0) then
        tmp = 1.0d0 + (0.5d0 * (im_m * im_m))
    else if (im_m <= 1.36d+60) then
        tmp = ((re * re) * ((-0.5d0) * (1.0d0 + ((im_m * im_m) * (0.5d0 + (0.041666666666666664d0 * (im_m * im_m))))))) + (1.0d0 + (re * (re / (((re * re) / (0.5d0 + (im_m * (im_m * 0.041666666666666664d0)))) / (im_m * im_m)))))
    else
        tmp = 1.0d0 + ((im_m * im_m) * (0.5d0 + ((0.041666666666666664d0 + (im_m * (im_m * 0.001388888888888889d0))) * (im_m * im_m))))
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double tmp;
	if (im_m <= 0.0016) {
		tmp = 1.0 + (0.5 * (im_m * im_m));
	} else if (im_m <= 1.36e+60) {
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	} else {
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	tmp = 0
	if im_m <= 0.0016:
		tmp = 1.0 + (0.5 * (im_m * im_m))
	elif im_m <= 1.36e+60:
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))))
	else:
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))))
	return tmp
im_m = abs(im)
function code(re, im_m)
	tmp = 0.0
	if (im_m <= 0.0016)
		tmp = Float64(1.0 + Float64(0.5 * Float64(im_m * im_m)));
	elseif (im_m <= 1.36e+60)
		tmp = Float64(Float64(Float64(re * re) * Float64(-0.5 * Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(0.041666666666666664 * Float64(im_m * im_m))))))) + Float64(1.0 + Float64(re * Float64(re / Float64(Float64(Float64(re * re) / Float64(0.5 + Float64(im_m * Float64(im_m * 0.041666666666666664)))) / Float64(im_m * im_m))))));
	else
		tmp = Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(Float64(0.041666666666666664 + Float64(im_m * Float64(im_m * 0.001388888888888889))) * Float64(im_m * im_m)))));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	tmp = 0.0;
	if (im_m <= 0.0016)
		tmp = 1.0 + (0.5 * (im_m * im_m));
	elseif (im_m <= 1.36e+60)
		tmp = ((re * re) * (-0.5 * (1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))))) + (1.0 + (re * (re / (((re * re) / (0.5 + (im_m * (im_m * 0.041666666666666664)))) / (im_m * im_m)))));
	else
		tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := If[LessEqual[im$95$m, 0.0016], N[(1.0 + N[(0.5 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im$95$m, 1.36e+60], N[(N[(N[(re * re), $MachinePrecision] * N[(-0.5 * N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(0.041666666666666664 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(re * N[(re / N[(N[(N[(re * re), $MachinePrecision] / N[(0.5 + N[(im$95$m * N[(im$95$m * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(N[(0.041666666666666664 + N[(im$95$m * N[(im$95$m * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
im_m = \left|im\right|

\\
\begin{array}{l}
\mathbf{if}\;im\_m \leq 0.0016:\\
\;\;\;\;1 + 0.5 \cdot \left(im\_m \cdot im\_m\right)\\

\mathbf{elif}\;im\_m \leq 1.36 \cdot 10^{+60}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right)\right)\right) + \left(1 + re \cdot \frac{re}{\frac{\frac{re \cdot re}{0.5 + im\_m \cdot \left(im\_m \cdot 0.041666666666666664\right)}}{im\_m \cdot im\_m}}\right)\\

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


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

    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. Simplified95.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 \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. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f6462.0%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
    8. Simplified62.0%

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

      \[\leadsto \color{blue}{1 + \frac{1}{2} \cdot {im}^{2}} \]
    10. 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-*.f6457.6%

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

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

    if 0.00160000000000000008 < im < 1.36000000000000002e60

    1. Initial program 99.8%

      \[\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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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. *-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(\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. 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(\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) \]
      5. *-lowering-*.f6422.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(\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) \]
    8. Simplified22.9%

      \[\leadsto \color{blue}{\left(1 + \left(re \cdot re\right) \cdot -0.5\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 re around inf

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\left(\frac{-1}{2} \cdot \left({re}^{2} \cdot \left(1 + {im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)\right)\right)\right), \color{blue}{\left({re}^{2} \cdot \left(\frac{1}{{re}^{2}} + \frac{{im}^{2} \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {im}^{2}\right)}{{re}^{2}}\right)\right)}\right) \]
    11. Simplified20.8%

      \[\leadsto \color{blue}{\left(re \cdot re\right) \cdot \left(-0.5 \cdot \left(1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right)\right) + \left(1 + \left(re \cdot re\right) \cdot \frac{\left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)}{re \cdot re}\right)} \]
    12. Step-by-step derivation
      1. associate-*l*N/A

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

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

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

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

    if 1.36000000000000002e60 < 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. Simplified100.0%

      \[\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. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f6476.6%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
    8. Simplified76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 59.3% accurate, 16.2× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ 1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + \left(0.041666666666666664 + im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\right) \cdot \left(im\_m \cdot im\_m\right)\right) \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (+
  1.0
  (*
   (* im_m im_m)
   (+
    0.5
    (*
     (+ 0.041666666666666664 (* im_m (* im_m 0.001388888888888889)))
     (* im_m im_m))))))
im_m = fabs(im);
double code(double re, double im_m) {
	return 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = 1.0d0 + ((im_m * im_m) * (0.5d0 + ((0.041666666666666664d0 + (im_m * (im_m * 0.001388888888888889d0))) * (im_m * im_m))))
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	return 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
}
im_m = math.fabs(im)
def code(re, im_m):
	return 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))))
im_m = abs(im)
function code(re, im_m)
	return Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(Float64(0.041666666666666664 + Float64(im_m * Float64(im_m * 0.001388888888888889))) * Float64(im_m * im_m)))))
end
im_m = abs(im);
function tmp = code(re, im_m)
	tmp = 1.0 + ((im_m * im_m) * (0.5 + ((0.041666666666666664 + (im_m * (im_m * 0.001388888888888889))) * (im_m * im_m))));
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(N[(0.041666666666666664 + N[(im$95$m * N[(im$95$m * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|

\\
1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + \left(0.041666666666666664 + im\_m \cdot \left(im\_m \cdot 0.001388888888888889\right)\right) \cdot \left(im\_m \cdot im\_m\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. Simplified93.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. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f6462.8%

      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
  8. Simplified62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(im \cdot im\right) \cdot \left(0.041666666666666664 + im \cdot \left(im \cdot 0.001388888888888889\right)\right)\right)} \]
  12. Final simplification62.8%

    \[\leadsto 1 + \left(im \cdot im\right) \cdot \left(0.5 + \left(0.041666666666666664 + im \cdot \left(im \cdot 0.001388888888888889\right)\right) \cdot \left(im \cdot im\right)\right) \]
  13. Add Preprocessing

Alternative 13: 56.4% accurate, 23.7× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ 1 + \left(im\_m \cdot im\_m\right) \cdot \left(0.5 + 0.041666666666666664 \cdot \left(im\_m \cdot im\_m\right)\right) \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (+ 1.0 (* (* im_m im_m) (+ 0.5 (* 0.041666666666666664 (* im_m im_m))))))
im_m = fabs(im);
double code(double re, double im_m) {
	return 1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))));
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    code = 1.0d0 + ((im_m * im_m) * (0.5d0 + (0.041666666666666664d0 * (im_m * im_m))))
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	return 1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))));
}
im_m = math.fabs(im)
def code(re, im_m):
	return 1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))))
im_m = abs(im)
function code(re, im_m)
	return Float64(1.0 + Float64(Float64(im_m * im_m) * Float64(0.5 + Float64(0.041666666666666664 * Float64(im_m * im_m)))))
end
im_m = abs(im);
function tmp = code(re, im_m)
	tmp = 1.0 + ((im_m * im_m) * (0.5 + (0.041666666666666664 * (im_m * im_m))));
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := N[(1.0 + N[(N[(im$95$m * im$95$m), $MachinePrecision] * N[(0.5 + N[(0.041666666666666664 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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. *-lowering-*.f64N/A

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(1, \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)\right) \]
  8. Simplified60.9%

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

Alternative 14: 47.4% accurate, 30.8× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ \begin{array}{l} \mathbf{if}\;im\_m \leq 24:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im\_m \cdot im\_m\right)\\ \end{array} \end{array} \]
im_m = (fabs.f64 im)
(FPCore (re im_m)
 :precision binary64
 (if (<= im_m 24.0) 1.0 (* 0.5 (* im_m im_m))))
im_m = fabs(im);
double code(double re, double im_m) {
	double tmp;
	if (im_m <= 24.0) {
		tmp = 1.0;
	} else {
		tmp = 0.5 * (im_m * im_m);
	}
	return tmp;
}
im_m = abs(im)
real(8) function code(re, im_m)
    real(8), intent (in) :: re
    real(8), intent (in) :: im_m
    real(8) :: tmp
    if (im_m <= 24.0d0) then
        tmp = 1.0d0
    else
        tmp = 0.5d0 * (im_m * im_m)
    end if
    code = tmp
end function
im_m = Math.abs(im);
public static double code(double re, double im_m) {
	double tmp;
	if (im_m <= 24.0) {
		tmp = 1.0;
	} else {
		tmp = 0.5 * (im_m * im_m);
	}
	return tmp;
}
im_m = math.fabs(im)
def code(re, im_m):
	tmp = 0
	if im_m <= 24.0:
		tmp = 1.0
	else:
		tmp = 0.5 * (im_m * im_m)
	return tmp
im_m = abs(im)
function code(re, im_m)
	tmp = 0.0
	if (im_m <= 24.0)
		tmp = 1.0;
	else
		tmp = Float64(0.5 * Float64(im_m * im_m));
	end
	return tmp
end
im_m = abs(im);
function tmp_2 = code(re, im_m)
	tmp = 0.0;
	if (im_m <= 24.0)
		tmp = 1.0;
	else
		tmp = 0.5 * (im_m * im_m);
	end
	tmp_2 = tmp;
end
im_m = N[Abs[im], $MachinePrecision]
code[re_, im$95$m_] := If[LessEqual[im$95$m, 24.0], 1.0, N[(0.5 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
im_m = \left|im\right|

\\
\begin{array}{l}
\mathbf{if}\;im\_m \leq 24:\\
\;\;\;\;1\\

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


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

    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.f6472.4%

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

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

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

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

      if 24 < 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. Simplified87.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 {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. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
        12. *-lowering-*.f6467.8%

          \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
      8. Simplified67.8%

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

        \[\leadsto \color{blue}{1 + \frac{1}{2} \cdot {im}^{2}} \]
      10. 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-*.f6435.5%

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

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

        \[\leadsto \color{blue}{\frac{1}{2} \cdot {im}^{2}} \]
      13. 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-*.f6435.5%

          \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, \color{blue}{im}\right)\right) \]
      14. Simplified35.5%

        \[\leadsto \color{blue}{0.5 \cdot \left(im \cdot im\right)} \]
    8. Recombined 2 regimes into one program.
    9. Add Preprocessing

    Alternative 15: 47.6% accurate, 44.0× speedup?

    \[\begin{array}{l} im_m = \left|im\right| \\ 1 + 0.5 \cdot \left(im\_m \cdot im\_m\right) \end{array} \]
    im_m = (fabs.f64 im)
    (FPCore (re im_m) :precision binary64 (+ 1.0 (* 0.5 (* im_m im_m))))
    im_m = fabs(im);
    double code(double re, double im_m) {
    	return 1.0 + (0.5 * (im_m * im_m));
    }
    
    im_m = abs(im)
    real(8) function code(re, im_m)
        real(8), intent (in) :: re
        real(8), intent (in) :: im_m
        code = 1.0d0 + (0.5d0 * (im_m * im_m))
    end function
    
    im_m = Math.abs(im);
    public static double code(double re, double im_m) {
    	return 1.0 + (0.5 * (im_m * im_m));
    }
    
    im_m = math.fabs(im)
    def code(re, im_m):
    	return 1.0 + (0.5 * (im_m * im_m))
    
    im_m = abs(im)
    function code(re, im_m)
    	return Float64(1.0 + Float64(0.5 * Float64(im_m * im_m)))
    end
    
    im_m = abs(im);
    function tmp = code(re, im_m)
    	tmp = 1.0 + (0.5 * (im_m * im_m));
    end
    
    im_m = N[Abs[im], $MachinePrecision]
    code[re_, im$95$m_] := N[(1.0 + N[(0.5 * N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    im_m = \left|im\right|
    
    \\
    1 + 0.5 \cdot \left(im\_m \cdot im\_m\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. Simplified93.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. +-lowering-+.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
      12. *-lowering-*.f6462.8%

        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(im, im\right)\right), \mathsf{*.f64}\left(\mathsf{pow.f64}\left(im, 4\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
    8. Simplified62.8%

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

      \[\leadsto \color{blue}{1 + \frac{1}{2} \cdot {im}^{2}} \]
    10. 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-*.f6452.4%

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

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

    Alternative 16: 29.4% accurate, 308.0× speedup?

    \[\begin{array}{l} im_m = \left|im\right| \\ 1 \end{array} \]
    im_m = (fabs.f64 im)
    (FPCore (re im_m) :precision binary64 1.0)
    im_m = fabs(im);
    double code(double re, double im_m) {
    	return 1.0;
    }
    
    im_m = abs(im)
    real(8) function code(re, im_m)
        real(8), intent (in) :: re
        real(8), intent (in) :: im_m
        code = 1.0d0
    end function
    
    im_m = Math.abs(im);
    public static double code(double re, double im_m) {
    	return 1.0;
    }
    
    im_m = math.fabs(im)
    def code(re, im_m):
    	return 1.0
    
    im_m = abs(im)
    function code(re, im_m)
    	return 1.0
    end
    
    im_m = abs(im);
    function tmp = code(re, im_m)
    	tmp = 1.0;
    end
    
    im_m = N[Abs[im], $MachinePrecision]
    code[re_, im$95$m_] := 1.0
    
    \begin{array}{l}
    im_m = \left|im\right|
    
    \\
    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.f6457.5%

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

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

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

        \[\leadsto \color{blue}{1} \]
      2. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2024156 
      (FPCore (re im)
        :name "math.cos on complex, real part"
        :precision binary64
        (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))