math.cos on complex, real part

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

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.5× speedup?

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

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

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

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

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

      \[\leadsto \left(\left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re \]
    4. div-invN/A

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

      \[\leadsto \frac{e^{im} + e^{\mathsf{neg}\left(im\right)}}{2} \cdot \cos re \]
    6. cosh-defN/A

      \[\leadsto \cosh im \cdot \cos \color{blue}{re} \]
    7. *-lowering-*.f64N/A

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

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

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

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

Alternative 2: 95.2% accurate, 1.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\cosh im\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.982999999999999985 < (cos.f64 re)

    1. Initial program 100.0%

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

        \[\leadsto \left(\left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re \]
      4. div-invN/A

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

        \[\leadsto \frac{e^{im} + e^{\mathsf{neg}\left(im\right)}}{2} \cdot \cos re \]
      6. cosh-defN/A

        \[\leadsto \cosh im \cdot \cos \color{blue}{re} \]
      7. *-lowering-*.f64N/A

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

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

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

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

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

        \[\leadsto \cosh im \cdot \color{blue}{1} \]
      2. Step-by-step derivation
        1. *-rgt-identityN/A

          \[\leadsto \cosh im \]
        2. cosh-lowering-cosh.f6499.9%

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

        \[\leadsto \color{blue}{\cosh im} \]
    7. Recombined 2 regimes into one program.
    8. Final simplification98.1%

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

    Alternative 3: 93.0% accurate, 1.4× speedup?

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

      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. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 0.982999999999999985 < (cos.f64 re)

      1. Initial program 100.0%

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

          \[\leadsto \left(\left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re \]
        4. div-invN/A

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

          \[\leadsto \frac{e^{im} + e^{\mathsf{neg}\left(im\right)}}{2} \cdot \cos re \]
        6. cosh-defN/A

          \[\leadsto \cosh im \cdot \cos \color{blue}{re} \]
        7. *-lowering-*.f64N/A

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

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

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

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

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

          \[\leadsto \cosh im \cdot \color{blue}{1} \]
        2. Step-by-step derivation
          1. *-rgt-identityN/A

            \[\leadsto \cosh im \]
          2. cosh-lowering-cosh.f6499.9%

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

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

      Alternative 4: 84.3% accurate, 2.6× speedup?

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

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

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

        if 1.29999999999999989e-4 < im < 1.50000000000000009e153

        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. metadata-evalN/A

            \[\leadsto \left(\left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re \]
          4. div-invN/A

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

            \[\leadsto \frac{e^{im} + e^{\mathsf{neg}\left(im\right)}}{2} \cdot \cos re \]
          6. cosh-defN/A

            \[\leadsto \cosh im \cdot \cos \color{blue}{re} \]
          7. *-lowering-*.f64N/A

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

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

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

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

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

            \[\leadsto \cosh im \cdot \color{blue}{1} \]
          2. Step-by-step derivation
            1. *-rgt-identityN/A

              \[\leadsto \cosh im \]
            2. cosh-lowering-cosh.f6470.2%

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

            \[\leadsto \color{blue}{\cosh im} \]
        7. Recombined 2 regimes into one program.
        8. Final simplification83.7%

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

        Alternative 5: 68.3% accurate, 2.9× speedup?

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

          1. Initial program 100.0%

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

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

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

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

          if 1.15e-4 < im

          1. Initial program 100.0%

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

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

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

              \[\leadsto \left(\left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re \]
            4. div-invN/A

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

              \[\leadsto \frac{e^{im} + e^{\mathsf{neg}\left(im\right)}}{2} \cdot \cos re \]
            6. cosh-defN/A

              \[\leadsto \cosh im \cdot \cos \color{blue}{re} \]
            7. *-lowering-*.f64N/A

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

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

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

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

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

              \[\leadsto \cosh im \cdot \color{blue}{1} \]
            2. Step-by-step derivation
              1. *-rgt-identityN/A

                \[\leadsto \cosh im \]
              2. cosh-lowering-cosh.f6477.5%

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

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

          Alternative 6: 64.9% accurate, 2.9× speedup?

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

            1. Initial program 100.0%

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

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

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

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

            if 6.9999999999999994e-5 < im

            1. Initial program 100.0%

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(\left(im \cdot im\right) \cdot \left(\color{blue}{1} + \frac{1}{12} \cdot {im}^{2}\right)\right)\right)\right) \]
              3. associate-*l*N/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}{\left(im \cdot \left(1 + \frac{1}{12} \cdot {im}^{2}\right)\right)}\right)\right)\right) \]
              4. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(re, \mathsf{*.f64}\left(re, \mathsf{+.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\left(re \cdot re\right), \frac{1}{48}\right)\right)\right)\right)\right), \mathsf{+.f64}\left(2, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{12}\right)\right)\right)\right)\right)\right) \]
              13. *-lowering-*.f6465.9%

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

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

          Alternative 7: 59.0% accurate, 16.2× speedup?

          \[\begin{array}{l} \\ 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) \end{array} \]
          (FPCore (re im)
           :precision binary64
           (+
            1.0
            (*
             (* im im)
             (+
              0.5
              (*
               (* im im)
               (+ 0.041666666666666664 (* (* im im) 0.001388888888888889)))))))
          double code(double re, double im) {
          	return 1.0 + ((im * im) * (0.5 + ((im * im) * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))));
          }
          
          real(8) function code(re, im)
              real(8), intent (in) :: re
              real(8), intent (in) :: im
              code = 1.0d0 + ((im * im) * (0.5d0 + ((im * im) * (0.041666666666666664d0 + ((im * im) * 0.001388888888888889d0)))))
          end function
          
          public static double code(double re, double im) {
          	return 1.0 + ((im * im) * (0.5 + ((im * im) * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))));
          }
          
          def code(re, im):
          	return 1.0 + ((im * im) * (0.5 + ((im * im) * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))))
          
          function code(re, im)
          	return Float64(1.0 + Float64(Float64(im * im) * Float64(0.5 + Float64(Float64(im * im) * Float64(0.041666666666666664 + Float64(Float64(im * im) * 0.001388888888888889))))))
          end
          
          function tmp = code(re, im)
          	tmp = 1.0 + ((im * im) * (0.5 + ((im * im) * (0.041666666666666664 + ((im * im) * 0.001388888888888889)))));
          end
          
          code[re_, im_] := N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.5 + N[(N[(im * im), $MachinePrecision] * N[(0.041666666666666664 + N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          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)
          \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. metadata-evalN/A

              \[\leadsto \left(\left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re \]
            4. div-invN/A

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

              \[\leadsto \frac{e^{im} + e^{\mathsf{neg}\left(im\right)}}{2} \cdot \cos re \]
            6. cosh-defN/A

              \[\leadsto \cosh im \cdot \cos \color{blue}{re} \]
            7. *-lowering-*.f64N/A

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

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

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

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

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

              \[\leadsto \cosh im \cdot \color{blue}{1} \]
            2. 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)} \]
            3. 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. *-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(\left({im}^{2}\right), \color{blue}{\frac{1}{720}}\right)\right)\right)\right)\right)\right) \]
              12. 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}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right) \]
              13. *-lowering-*.f6459.4%

                \[\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(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right) \]
            4. Simplified59.4%

              \[\leadsto \color{blue}{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)} \]
            5. Add Preprocessing

            Alternative 8: 58.8% accurate, 18.1× speedup?

            \[\begin{array}{l} \\ 1 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\right)\right) \end{array} \]
            (FPCore (re im)
             :precision binary64
             (+
              1.0
              (*
               (* im im)
               (* (* im im) (+ 0.041666666666666664 (* (* im im) 0.001388888888888889))))))
            double code(double re, double im) {
            	return 1.0 + ((im * im) * ((im * im) * (0.041666666666666664 + ((im * im) * 0.001388888888888889))));
            }
            
            real(8) function code(re, im)
                real(8), intent (in) :: re
                real(8), intent (in) :: im
                code = 1.0d0 + ((im * im) * ((im * im) * (0.041666666666666664d0 + ((im * im) * 0.001388888888888889d0))))
            end function
            
            public static double code(double re, double im) {
            	return 1.0 + ((im * im) * ((im * im) * (0.041666666666666664 + ((im * im) * 0.001388888888888889))));
            }
            
            def code(re, im):
            	return 1.0 + ((im * im) * ((im * im) * (0.041666666666666664 + ((im * im) * 0.001388888888888889))))
            
            function code(re, im)
            	return Float64(1.0 + Float64(Float64(im * im) * Float64(Float64(im * im) * Float64(0.041666666666666664 + Float64(Float64(im * im) * 0.001388888888888889)))))
            end
            
            function tmp = code(re, im)
            	tmp = 1.0 + ((im * im) * ((im * im) * (0.041666666666666664 + ((im * im) * 0.001388888888888889))));
            end
            
            code[re_, im_] := N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * N[(0.041666666666666664 + N[(N[(im * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            1 + \left(im \cdot im\right) \cdot \left(\left(im \cdot im\right) \cdot \left(0.041666666666666664 + \left(im \cdot im\right) \cdot 0.001388888888888889\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. 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. metadata-evalN/A

                \[\leadsto \left(\left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re \]
              4. div-invN/A

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

                \[\leadsto \frac{e^{im} + e^{\mathsf{neg}\left(im\right)}}{2} \cdot \cos re \]
              6. cosh-defN/A

                \[\leadsto \cosh im \cdot \cos \color{blue}{re} \]
              7. *-lowering-*.f64N/A

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

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

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

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

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

                \[\leadsto \cosh im \cdot \color{blue}{1} \]
              2. 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)} \]
              3. 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. *-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(\left({im}^{2}\right), \color{blue}{\frac{1}{720}}\right)\right)\right)\right)\right)\right) \]
                12. 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}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right) \]
                13. *-lowering-*.f6459.4%

                  \[\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(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right) \]
              4. Simplified59.4%

                \[\leadsto \color{blue}{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)} \]
              5. Taylor expanded in im around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \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) \]
                16. +-lowering-+.f64N/A

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

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

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

                  \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
                20. *-lowering-*.f6459.0%

                  \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right) \]
              7. Simplified59.0%

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

              Alternative 9: 51.4% accurate, 19.2× speedup?

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

                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-*.f6483.7%

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

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

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

                    \[\leadsto \frac{1}{2} \cdot 2 + \color{blue}{\frac{1}{2} \cdot {im}^{2}} \]
                  2. metadata-evalN/A

                    \[\leadsto 1 + \color{blue}{\frac{1}{2}} \cdot {im}^{2} \]
                  3. +-lowering-+.f64N/A

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

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

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

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

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

                if 2 < 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. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto {im}^{\left(3 + 1\right)} \cdot \left(\frac{1}{24} + \frac{1}{2} \cdot \frac{1}{{im}^{2}}\right) \]
                  2. pow-plusN/A

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

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

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

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

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

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

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

                    \[\leadsto {im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2} + \frac{1}{2} \cdot \color{blue}{\left(\frac{1}{{im}^{2}} \cdot {im}^{2}\right)}\right) \]
                  10. lft-mult-inverseN/A

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

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

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

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

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

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

                    \[\leadsto \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) \]
                  17. *-commutativeN/A

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

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

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

                    \[\leadsto \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) \]
                11. Simplified65.8%

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

              Alternative 10: 38.1% accurate, 20.5× speedup?

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

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

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

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

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

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

                  if 4.2000000000000001e32 < im < 1.65999999999999992e131

                  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.f643.1%

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\frac{-1}{2} \cdot {re}^{2}} \]
                  10. Step-by-step derivation
                    1. *-lowering-*.f64N/A

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

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

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

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

                  if 1.65999999999999992e131 < 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. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto {im}^{\left(3 + 1\right)} \cdot \left(\frac{1}{24} + \frac{1}{2} \cdot \frac{1}{{im}^{2}}\right) \]
                    2. pow-plusN/A

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

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

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

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

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

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

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

                      \[\leadsto {im}^{2} \cdot \left(\frac{1}{24} \cdot {im}^{2} + \frac{1}{2} \cdot \color{blue}{\left(\frac{1}{{im}^{2}} \cdot {im}^{2}\right)}\right) \]
                    10. lft-mult-inverseN/A

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

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

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

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

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

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

                      \[\leadsto \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) \]
                    17. *-commutativeN/A

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

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

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

                      \[\leadsto \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) \]
                  11. Simplified87.2%

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

                    \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \color{blue}{\frac{1}{2}}\right) \]
                  13. Step-by-step derivation
                    1. Simplified73.4%

                      \[\leadsto \left(im \cdot im\right) \cdot \color{blue}{0.5} \]
                  14. Recombined 3 regimes into one program.
                  15. Final simplification39.9%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;im \leq 4.2 \cdot 10^{+32}:\\ \;\;\;\;1\\ \mathbf{elif}\;im \leq 1.66 \cdot 10^{+131}:\\ \;\;\;\;\left(re \cdot re\right) \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(im \cdot im\right)\\ \end{array} \]
                  16. Add Preprocessing

                  Alternative 11: 58.8% accurate, 20.5× speedup?

                  \[\begin{array}{l} \\ 1 + \left(im \cdot im\right) \cdot \left(0.001388888888888889 \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right) \end{array} \]
                  (FPCore (re im)
                   :precision binary64
                   (+ 1.0 (* (* im im) (* 0.001388888888888889 (* im (* im (* im im)))))))
                  double code(double re, double im) {
                  	return 1.0 + ((im * im) * (0.001388888888888889 * (im * (im * (im * im)))));
                  }
                  
                  real(8) function code(re, im)
                      real(8), intent (in) :: re
                      real(8), intent (in) :: im
                      code = 1.0d0 + ((im * im) * (0.001388888888888889d0 * (im * (im * (im * im)))))
                  end function
                  
                  public static double code(double re, double im) {
                  	return 1.0 + ((im * im) * (0.001388888888888889 * (im * (im * (im * im)))));
                  }
                  
                  def code(re, im):
                  	return 1.0 + ((im * im) * (0.001388888888888889 * (im * (im * (im * im)))))
                  
                  function code(re, im)
                  	return Float64(1.0 + Float64(Float64(im * im) * Float64(0.001388888888888889 * Float64(im * Float64(im * Float64(im * im))))))
                  end
                  
                  function tmp = code(re, im)
                  	tmp = 1.0 + ((im * im) * (0.001388888888888889 * (im * (im * (im * im)))));
                  end
                  
                  code[re_, im_] := N[(1.0 + N[(N[(im * im), $MachinePrecision] * N[(0.001388888888888889 * N[(im * N[(im * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  1 + \left(im \cdot im\right) \cdot \left(0.001388888888888889 \cdot \left(im \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right)
                  \end{array}
                  
                  Derivation
                  1. Initial program 100.0%

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

                      \[\leadsto \left(\left(e^{\mathsf{neg}\left(im\right)} + e^{im}\right) \cdot \frac{1}{2}\right) \cdot \cos re \]
                    4. div-invN/A

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

                      \[\leadsto \frac{e^{im} + e^{\mathsf{neg}\left(im\right)}}{2} \cdot \cos re \]
                    6. cosh-defN/A

                      \[\leadsto \cosh im \cdot \cos \color{blue}{re} \]
                    7. *-lowering-*.f64N/A

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

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

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

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

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

                      \[\leadsto \cosh im \cdot \color{blue}{1} \]
                    2. 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)} \]
                    3. 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. *-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(\left({im}^{2}\right), \color{blue}{\frac{1}{720}}\right)\right)\right)\right)\right)\right) \]
                      12. 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}, \mathsf{*.f64}\left(\left(im \cdot im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right) \]
                      13. *-lowering-*.f6459.4%

                        \[\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(\mathsf{*.f64}\left(im, im\right), \frac{1}{720}\right)\right)\right)\right)\right)\right) \]
                    4. Simplified59.4%

                      \[\leadsto \color{blue}{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)} \]
                    5. Taylor expanded in im around inf

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 12: 51.4% accurate, 22.0× speedup?

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

                      1. Initial program 100.0%

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

                        \[\leadsto \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-*.f6483.7%

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

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

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

                          \[\leadsto \frac{1}{2} \cdot 2 + \color{blue}{\frac{1}{2} \cdot {im}^{2}} \]
                        2. metadata-evalN/A

                          \[\leadsto 1 + \color{blue}{\frac{1}{2}} \cdot {im}^{2} \]
                        3. +-lowering-+.f64N/A

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

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

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

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

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

                      if 3.5 < im

                      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\frac{1}{24} \cdot {im}^{4}} \]
                      10. Step-by-step derivation
                        1. *-lowering-*.f64N/A

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

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

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

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

                          \[\leadsto \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(im, \color{blue}{\left({im}^{3}\right)}\right)\right) \]
                        6. cube-multN/A

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

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

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

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

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

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

                    Alternative 13: 55.8% accurate, 23.7× speedup?

                    \[\begin{array}{l} \\ 1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\right)\right) \end{array} \]
                    (FPCore (re im)
                     :precision binary64
                     (+ 1.0 (* im (* im (+ 0.5 (* (* im im) 0.041666666666666664))))))
                    double code(double re, double im) {
                    	return 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
                    }
                    
                    real(8) function code(re, im)
                        real(8), intent (in) :: re
                        real(8), intent (in) :: im
                        code = 1.0d0 + (im * (im * (0.5d0 + ((im * im) * 0.041666666666666664d0))))
                    end function
                    
                    public static double code(double re, double im) {
                    	return 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
                    }
                    
                    def code(re, im):
                    	return 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))))
                    
                    function code(re, im)
                    	return Float64(1.0 + Float64(im * Float64(im * Float64(0.5 + Float64(Float64(im * im) * 0.041666666666666664)))))
                    end
                    
                    function tmp = code(re, im)
                    	tmp = 1.0 + (im * (im * (0.5 + ((im * im) * 0.041666666666666664))));
                    end
                    
                    code[re_, im_] := N[(1.0 + N[(im * N[(im * N[(0.5 + N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    1 + im \cdot \left(im \cdot \left(0.5 + \left(im \cdot im\right) \cdot 0.041666666666666664\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. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 14: 55.7% accurate, 28.0× speedup?

                    \[\begin{array}{l} \\ 1 + im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.041666666666666664\right)\right) \end{array} \]
                    (FPCore (re im)
                     :precision binary64
                     (+ 1.0 (* im (* im (* (* im im) 0.041666666666666664)))))
                    double code(double re, double im) {
                    	return 1.0 + (im * (im * ((im * im) * 0.041666666666666664)));
                    }
                    
                    real(8) function code(re, im)
                        real(8), intent (in) :: re
                        real(8), intent (in) :: im
                        code = 1.0d0 + (im * (im * ((im * im) * 0.041666666666666664d0)))
                    end function
                    
                    public static double code(double re, double im) {
                    	return 1.0 + (im * (im * ((im * im) * 0.041666666666666664)));
                    }
                    
                    def code(re, im):
                    	return 1.0 + (im * (im * ((im * im) * 0.041666666666666664)))
                    
                    function code(re, im)
                    	return Float64(1.0 + Float64(im * Float64(im * Float64(Float64(im * im) * 0.041666666666666664))))
                    end
                    
                    function tmp = code(re, im)
                    	tmp = 1.0 + (im * (im * ((im * im) * 0.041666666666666664)));
                    end
                    
                    code[re_, im_] := N[(1.0 + N[(im * N[(im * N[(N[(im * im), $MachinePrecision] * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    1 + im \cdot \left(im \cdot \left(\left(im \cdot im\right) \cdot 0.041666666666666664\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. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(im, \mathsf{*.f64}\left(\mathsf{*.f64}\left(im, im\right), \frac{1}{24}\right)\right)\right)\right) \]
                    11. Simplified57.9%

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

                    Alternative 15: 30.6% accurate, 30.8× speedup?

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

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

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

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

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

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

                        if 4.79999999999999983e32 < 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} \]
                        4. Step-by-step derivation
                          1. cos-lowering-cos.f643.1%

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

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

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

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

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

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

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

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

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

                          \[\leadsto \color{blue}{\frac{-1}{2} \cdot {re}^{2}} \]
                        10. Step-by-step derivation
                          1. *-lowering-*.f64N/A

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

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

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

                          \[\leadsto \color{blue}{-0.5 \cdot \left(re \cdot re\right)} \]
                      8. Recombined 2 regimes into one program.
                      9. Final simplification29.7%

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

                      Alternative 16: 47.0% accurate, 44.0× speedup?

                      \[\begin{array}{l} \\ 1 + 0.5 \cdot \left(im \cdot im\right) \end{array} \]
                      (FPCore (re im) :precision binary64 (+ 1.0 (* 0.5 (* im im))))
                      double code(double re, double im) {
                      	return 1.0 + (0.5 * (im * im));
                      }
                      
                      real(8) function code(re, im)
                          real(8), intent (in) :: re
                          real(8), intent (in) :: im
                          code = 1.0d0 + (0.5d0 * (im * im))
                      end function
                      
                      public static double code(double re, double im) {
                      	return 1.0 + (0.5 * (im * im));
                      }
                      
                      def code(re, im):
                      	return 1.0 + (0.5 * (im * im))
                      
                      function code(re, im)
                      	return Float64(1.0 + Float64(0.5 * Float64(im * im)))
                      end
                      
                      function tmp = code(re, im)
                      	tmp = 1.0 + (0.5 * (im * im));
                      end
                      
                      code[re_, im_] := N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      1 + 0.5 \cdot \left(im \cdot im\right)
                      \end{array}
                      
                      Derivation
                      1. Initial program 100.0%

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

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

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

                          \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{cos.f64}\left(re\right)\right), \mathsf{+.f64}\left(2, \left(im \cdot \color{blue}{im}\right)\right)\right) \]
                        3. *-lowering-*.f6475.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. Simplified75.4%

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

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

                          \[\leadsto \frac{1}{2} \cdot 2 + \color{blue}{\frac{1}{2} \cdot {im}^{2}} \]
                        2. metadata-evalN/A

                          \[\leadsto 1 + \color{blue}{\frac{1}{2}} \cdot {im}^{2} \]
                        3. +-lowering-+.f64N/A

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

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

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

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

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

                      Alternative 17: 27.9% accurate, 308.0× speedup?

                      \[\begin{array}{l} \\ 1 \end{array} \]
                      (FPCore (re im) :precision binary64 1.0)
                      double code(double re, double im) {
                      	return 1.0;
                      }
                      
                      real(8) function code(re, im)
                          real(8), intent (in) :: re
                          real(8), intent (in) :: im
                          code = 1.0d0
                      end function
                      
                      public static double code(double re, double im) {
                      	return 1.0;
                      }
                      
                      def code(re, im):
                      	return 1.0
                      
                      function code(re, im)
                      	return 1.0
                      end
                      
                      function tmp = code(re, im)
                      	tmp = 1.0;
                      end
                      
                      code[re_, im_] := 1.0
                      
                      \begin{array}{l}
                      
                      \\
                      1
                      \end{array}
                      
                      Derivation
                      1. Initial program 100.0%

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

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

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

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

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

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

                        Reproduce

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